Skip to content

Commit

Permalink
Merge pull request #7 from mgvalverde/workflows
Browse files Browse the repository at this point in the history
chore: add workflows
  • Loading branch information
mgvalverde authored Aug 30, 2024
2 parents 633cbac + 05a2eb5 commit b500886
Show file tree
Hide file tree
Showing 4 changed files with 314 additions and 1 deletion.
145 changes: 145 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Release
run-name: Release 🚀

on:
push:
branches:
- main

permissions:
contents: read

env:
POETRY_VERSION: "1.8.3"
PYTHON_VERSION: "3.9"


jobs:

build:
name: Build and Release
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

outputs:
target_version: ${{ steps.export_version.outputs.target_version }}

steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry v${{ env.POETRY_VERSION }}
run: pipx install poetry==${{ env.POETRY_VERSION }}

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Python Semantic Release to prepare release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: 'error'

- name: Save Tag reference
id: export_version
run: echo "target_version=$(git describe --exact-match | cut -c2-)" >> $GITHUB_OUTPUT


publish-to-test-pypi:
name: Publish to Test PyPI
runs-on: ubuntu-latest
needs:
- build

permissions:
id-token: write
contents: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

test-installation-testpypi:
name: Test installation from Test PyPI
runs-on: ubuntu-latest
needs:
- build
- publish-to-test-pypi
steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Installation test (with retry)
uses: nick-fields/retry@v2
env:
TARGET_VERSION: ${{needs.build.outputs.target_version}}
with:
timeout_minutes: 5
max_attempts: 3
command: |
pip install -i https://test.pypi.org/simple/ omegaconf_cloud_resolvers[aws,gcp]=="${TARGET_VERSION}"
python -c "import omegaconf_cloud_resolvers; print('Base import: OK')"
python -c "from omegaconf_cloud_resolvers.resolvers.aws import AWSParameterStoreResolver; print('AWS import: OK')"
python -c "from omegaconf_cloud_resolvers.resolvers.gcp import GCPSecretManagerResolver; print('GCP import: OK')"
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- test-installation-testpypi

permissions:
id-token: write
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-docs:
name: Publish Docs
uses: ./.github/workflows/release_docs.yml

needs:
- build
- test-installation-testpypi

permissions:
id-token: write
contents: write

with:
ref_tag: "v${{needs.build.outputs.target_version}}"


62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test Package
run-name: Test Package 🔧

on:
pull_request:
branches:
- main
- develop

workflow_dispatch:

env:
POETRY_VERSION: "1.8.3"
PCKG_SRC: "omegaconf_cloud_resolvers"


defaults:
run:
shell: bash

jobs:

ci:
name: Continuous Integration
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: poetry install --all-extras

- name: Lint with ruff
run: poetry run ruff check . --exit-non-zero-on-fix --show-fixes

- name: Lint with bandit
run: poetry run bandit -r . -x "./.venv/*,./tests/*,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg" --quiet

- name: Test with pytest
run: poetry run pytest tests/ --cov=${{env.PCKG_SRC}} --cov-report=xml # store in cov

- name: Archive code coverage html report #
if: ${{ matrix.python-version == '3.9'}}
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: htmlcov

- name: Test build docs
run: poetry run mkdocs build
107 changes: 106 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gcp = ["google-cloud-secret-manager"]
moto = { extras = ["secretsmanager", "ssm"], version = "^5.0.13" }
pytest-mock = "^3.14.0"
pytest = "^8.3.2"
pytest-cov = "^5.0.0"
ruff = "^0.6.2"
bandit = "^1.7.9"
mkdocs = "^1.6.0"
Expand Down

0 comments on commit b500886

Please sign in to comment.