From 9acf33865e86bbc636d607fbb5479ab52df4406a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Magalh=C3=A3es?= Date: Sat, 21 Dec 2024 16:41:25 +0000 Subject: [PATCH 1/4] chore: improve cache keys for venv and poetry --- .github/actions/install-canvas/action.yml | 2 +- .github/actions/install-python-and-poetry/action.yml | 10 ++++++++-- .pre-commit-config.yaml | 2 +- .python-version | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/actions/install-canvas/action.yml b/.github/actions/install-canvas/action.yml index 39986785..9fa450f0 100644 --- a/.github/actions/install-canvas/action.yml +++ b/.github/actions/install-canvas/action.yml @@ -11,7 +11,7 @@ runs: uses: actions/cache@v4 with: path: .venv - key: project-dependencies-${{ hashFiles('**/poetry.lock') }} + key: ${{runner.os}}-py${{env.PYTHON_VERSION}}-venv-${{ hashFiles('**/poetry.lock') }} # Install project dependencies (bypassing the project, because we don't want to cache the Canvas code). - name: Install Dependencies diff --git a/.github/actions/install-python-and-poetry/action.yml b/.github/actions/install-python-and-poetry/action.yml index cbad3706..db138e4b 100644 --- a/.github/actions/install-python-and-poetry/action.yml +++ b/.github/actions/install-python-and-poetry/action.yml @@ -18,12 +18,18 @@ runs: using: "composite" steps: - name: Set up Python - uses: actions/setup-python@v4 + id: python-setup + uses: actions/setup-python@v5 with: python-version: ${{inputs.PYTHON_VERSION}} python-version-file: ".python-version" check-latest: ${{inputs.CHECK_LATEST}} + - name: Set Python version in the environment + run: | + echo "PYTHON_VERSION=${{ steps.python-setup.outputs.python-version }}" >> $GITHUB_ENV + shell: bash + # Cache the installation of Poetry itself. # This prevents the workflow from installing Poetry every time, which can be slow. - name: Cache poetry install @@ -31,7 +37,7 @@ runs: uses: actions/cache@v4 with: path: ~/.local - key: poetry-${{inputs.POETRY_VERSION}} + key: ${{runner.os}}-py${{steps.python-setup.outputs.python-version}}-poetry-${{inputs.POETRY_VERSION}} # Install Poetry, make sure the .venv is in the project, so it's easily cached. - name: Install poetry diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 39ab8724..ea9b0e22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: )$ - repo: https://github.com/python-poetry/poetry - rev: 1.8.0 + rev: 1.8.5 hooks: - id: poetry-check files: ^(.*/)?(poetry\.lock|pyproject\.toml)$ diff --git a/.python-version b/.python-version index e4fba218..2c073331 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.12 +3.11 From 2c5592254eb2408da41fced83d466819af3ae3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Magalh=C3=A3es?= Date: Sat, 21 Dec 2024 18:28:07 +0000 Subject: [PATCH 2/4] restore update for python-semantic-release --- poetry.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 01a293a6..5f852e72 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "annotated-types" @@ -1787,13 +1787,13 @@ yaml = ["PyYaml (>=6.0.1)"] [[package]] name = "python-semantic-release" -version = "9.14.0" +version = "9.15.2" description = "Automatic Semantic Versioning for Python projects" optional = false python-versions = ">=3.8" files = [ - {file = "python_semantic_release-9.14.0-py3-none-any.whl", hash = "sha256:f089a6ad976e909d5f87015e9f541f9fd503d3db41653efaf0157d874902e519"}, - {file = "python_semantic_release-9.14.0.tar.gz", hash = "sha256:5b69a626458bfb50686d27d9713160eb2bf9897b0c17985f1c68d7316b8e07b6"}, + {file = "python_semantic_release-9.15.2-py3-none-any.whl", hash = "sha256:14b5003862c88b2f9aca8fe97d06bf8da6db1b11473eb8c84af7e34ac956fd4f"}, + {file = "python_semantic_release-9.15.2.tar.gz", hash = "sha256:241d95dc1bfafbf0442fa5ad63fc5bd345716514fa4703b302ddae4cffa934e1"}, ] [package.dependencies] @@ -1814,8 +1814,8 @@ tomlkit = ">=0.11,<1.0" build = ["build (>=1.2,<2.0)"] dev = ["pre-commit (>=3.5,<4.0)", "ruff (==0.6.1)", "tox (>=4.11,<5.0)"] docs = ["Sphinx (>=6.0,<7.0)", "furo (>=2024.1,<2025.0)", "sphinx-autobuild (==2024.2.4)", "sphinxcontrib-apidoc (==0.5.0)"] -mypy = ["mypy (==1.13.0)", "types-requests (>=2.32.0,<2.33.0)"] -test = ["coverage[toml] (>=7.0,<8.0)", "pytest (>=8.3,<9.0)", "pytest-clarity (>=1.0,<2.0)", "pytest-cov (>=5.0,<6.0)", "pytest-env (>=1.0,<2.0)", "pytest-lazy-fixtures (>=1.1.1,<1.2.0)", "pytest-mock (>=3.0,<4.0)", "pytest-order (>=1.3,<2.0)", "pytest-pretty (>=1.2,<2.0)", "pytest-xdist (>=3.0,<4.0)", "pyyaml (>=6.0,<7.0)", "requests-mock (>=1.10,<2.0)", "responses (>=0.25.0,<0.26.0)"] +mypy = ["mypy (==1.13.0)", "types-pyyaml (>=6.0,<7.0)", "types-requests (>=2.32.0,<2.33.0)"] +test = ["coverage[toml] (>=7.0,<8.0)", "filelock (>=3.15,<4.0)", "flatdict (>=4.0,<5.0)", "freezegun (>=1.5,<2.0)", "pytest (>=8.3,<9.0)", "pytest-clarity (>=1.0,<2.0)", "pytest-cov (>=5.0,<6.0)", "pytest-env (>=1.0,<2.0)", "pytest-lazy-fixtures (>=1.1.1,<1.2.0)", "pytest-mock (>=3.0,<4.0)", "pytest-order (>=1.3,<2.0)", "pytest-pretty (>=1.2,<2.0)", "pytest-xdist (>=3.0,<4.0)", "pyyaml (>=6.0,<7.0)", "requests-mock (>=1.10,<2.0)", "responses (>=0.25.0,<0.26.0)"] [[package]] name = "python-slugify" From dc7b6bee342ac7931867d53dc9e9d138a5986d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Magalh=C3=A3es?= Date: Thu, 26 Dec 2024 17:14:38 +0000 Subject: [PATCH 3/4] add support for python 3.12 --- .pre-commit-config.yaml | 2 +- .python-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea9b0e22..cb19c2c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.11 + python: python3.12 exclude: | (?x)( CHANGELOG.md| diff --git a/.python-version b/.python-version index 2c073331..e4fba218 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11 +3.12 From 7724b6961336847a88acdf3427f6de1e12a6e747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Magalh=C3=A3es?= Date: Fri, 27 Dec 2024 11:13:01 +0000 Subject: [PATCH 4/4] run build and test with python 3.11 and 3.12 --- .github/workflows/build-and-test.yml | 18 ++++++++++++++++++ .github/workflows/publish-and-release.yml | 12 ------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d9e6e46b..50f1ce65 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,9 +9,14 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + strategy: + matrix: + version: [ 3.11, 3.12 ] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install-python-and-poetry + with: + PYTHON_VERSION: ${{ matrix.version }} - uses: ./.github/actions/install-canvas # Run Pytest unit tests via Poetry. @@ -24,8 +29,21 @@ jobs: # Run Pytest integration tests via Poetry. - name: Run Pytest integration tests + if: matrix.version == '3.12' env: INTEGRATION_TEST_URL: "https://plugin-testing.canvasmedical.com" INTEGRATION_TEST_CLIENT_ID: ${{ secrets.INTEGRATION_TEST_CLIENT_ID }} INTEGRATION_TEST_CLIENT_SECRET: ${{ secrets.INTEGRATION_TEST_CLIENT_SECRET }} run: poetry run pytest -m "integtest" --ff --verbosity 2 + + - name: Install pipx + run: pip install pipx + shell: bash + + - name: Test the distribution + run: | + poetry build + pipx install dist/*.whl + canvas --version + rm -rf dist/ + shell: bash diff --git a/.github/workflows/publish-and-release.yml b/.github/workflows/publish-and-release.yml index 487f34f6..0f0aac84 100644 --- a/.github/workflows/publish-and-release.yml +++ b/.github/workflows/publish-and-release.yml @@ -30,18 +30,6 @@ jobs: - uses: ./.github/actions/install-python-and-poetry - uses: ./.github/actions/install-canvas - - name: Install pipx - run: pip install pipx - shell: bash - - - name: Test the distribution - run: | - poetry build - pipx install dist/*.whl - canvas --version - rm -rf dist/ - shell: bash - - name: Python Semantic Release id: release env: