From 5c1502037c1448f700657091c21e92513270a6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Magalh=C3=A3es?= Date: Mon, 14 Oct 2024 10:44:21 +0100 Subject: [PATCH] chore(ci): improve build and test workflow (#125) --- .github/actions/install-canvas/action.yml | 25 +++++++++++++++++++ .../install-python-and-poetry/action.yml | 4 +-- .github/workflows/build-and-test.yml | 6 +---- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 .github/actions/install-canvas/action.yml diff --git a/.github/actions/install-canvas/action.yml b/.github/actions/install-canvas/action.yml new file mode 100644 index 00000000..39986785 --- /dev/null +++ b/.github/actions/install-canvas/action.yml @@ -0,0 +1,25 @@ +name: "Install Canvas" +description: "Installs Canvas dependencies" + + +runs: + using: "composite" + steps: + # Cache the project dependencies (everything in pyproject.toml). + - name: Cache project dependencies + id: cache-deps + uses: actions/cache@v4 + with: + path: .venv + key: project-dependencies-${{ hashFiles('**/poetry.lock') }} + + # Install project dependencies (bypassing the project, because we don't want to cache the Canvas code). + - name: Install Dependencies + run: poetry install --no-interaction --no-root + shell: bash + if: steps.cache-deps.outputs.cache-hit != 'true' + + # Install the project to make sure everything works and is synced. + - name: Install Canvas + shell: bash + run: poetry install --no-interaction diff --git a/.github/actions/install-python-and-poetry/action.yml b/.github/actions/install-python-and-poetry/action.yml index 687b98e2..cbad3706 100644 --- a/.github/actions/install-python-and-poetry/action.yml +++ b/.github/actions/install-python-and-poetry/action.yml @@ -5,7 +5,7 @@ inputs: POETRY_VERSION: description: "Poetry version to install" required: false - default: "1.7.1" + default: "1.8.3" PYTHON_VERSION: description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset." required: false @@ -28,7 +28,7 @@ runs: # This prevents the workflow from installing Poetry every time, which can be slow. - name: Cache poetry install id: cache-poetry - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.local key: poetry-${{inputs.POETRY_VERSION}} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 54d09151..d9e6e46b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,12 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/install-python-and-poetry - - - name: Install canvas-plugins - shell: bash - run: poetry install --no-interaction + - uses: ./.github/actions/install-canvas # Run Pytest unit tests via Poetry. - name: Run Pytest unit tests