diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 948cd2f..560f723 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -8,16 +8,44 @@ on: pull_request: branches: [ main ] workflow_dispatch: + inputs: + upgraded: + description: "Include upgraded dependencies in build matrix" + default: false + type: boolean schedule: - cron: "0 0 * * *" jobs: - build: + info: + name: Collect information & changes data + outputs: + dependencies: ${{ steps.info.outputs.dependencies }} + runs-on: ubuntu-latest + steps: + - name: Collect information + id: info + run: | + dependencies='["pinned", "upgraded"]' + + if [[ "${{ github.event_name }}" == "push" ]] || \ + [[ "${{ github.event_name }}" == "pull_request" ]] || \ + [[ "${{ github.event.inputs.upgraded }}" == "false" ]]; + then + dependencies='["pinned"]' + fi + # Output & sent to GitHub Actions + echo "dependencies: ${dependencies}" + echo "dependencies=${dependencies}" >> $GITHUB_OUTPUT + build: runs-on: ubuntu-latest + needs: + - info strategy: fail-fast: false matrix: + dependencies: ${{ fromJSON(needs.info.outputs.dependencies) }} python-version: ["3.12"] steps: @@ -29,7 +57,21 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + + if [[ "${{ matrix.dependencies }}" == "upgraded" ]]; + then + echo "unpinning dependencies" + ./script/unfreeze + fi + pip install -r requirements.test.txt + + if [[ "${{ matrix.dependencies }}" == "upgraded" ]]; + then + ./script/freeze + echo "dependency changes after upgrade:" + git diff requirements.test.txt + fi - name: Test with pytest run: | pytest diff --git a/script/unfreeze b/script/unfreeze new file mode 100755 index 0000000..c1ae38a --- /dev/null +++ b/script/unfreeze @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +cat requirements.test.txt | \ + sed 's/==.*//' > requirements.test.txt.tmp && \ + mv requirements.test.txt.tmp requirements.test.txt