Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,25 @@ jobs:

- name: Install required Python packages
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev-noxfile]
python -m pip install --upgrade pip uv
python -m uv pip install -e .[dev-noxfile]
pip freeze

# Restore pytest cache only for pytest_min session to use the cache
- name: Restore pytest cache
if: ${{ matrix.nox-session == 'pytest_min' }}
uses: actions/cache/restore@v4
id: restore-pytest-cache
with:
path: .pytest_cache
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-no-cache
restore-keys: |
${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-

- name: Create nox venv
env:
NOX_SESSION: ${{ matrix.nox-session }}
run: nox --install-only -e "$NOX_SESSION"
run: nox -db uv --install-only -e "$NOX_SESSION"

- name: Print pip freeze for nox venv (debug)
env:
Expand All @@ -74,12 +85,26 @@ jobs:
pip freeze
deactivate

# Run nox session
- name: Run nox
env:
NOX_SESSION: ${{ matrix.nox-session }}
run: nox -R -e "$NOX_SESSION"
run: |
if [ "$NOX_SESSION" = "pytest_min" ]; then
nox -db uv -R -e "$NOX_SESSION" -- --ff -o cache_dir=.pytest_cache
else
nox -db uv -R -e "$NOX_SESSION"
fi
timeout-minutes: 10

# Save pytest cache only for pytest_min session
- name: Save pytest cache
if: always() && matrix.nox-session == 'pytest_min'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think matrix.nox-session will be interpreted as a string rather than being evaluated as a variable without ${{ }}, thus the condition will be always false

Suggested change
if: always() && matrix.nox-session == 'pytest_min'
if: always() && ${{ matrix.nox-session == "pytest_min" }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's actually working, I tested this PR extensively :)

image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see it works.
I read the docs too and that confirms it too, though there are exceptions for cases that this won't work.

When you use expressions in an if conditional, you can, optionally, omit the ${{ }} expression syntax because GitHub Actions automatically evaluates the if conditional as an expression. However, this exception does not apply everywhere.

You must always use the ${{ }} expression syntax or escape with '', "", or () when the expression starts with !, since ! is reserved notation in YAML format. For example:

I've also seen in line 66 it is written if: ${{ matrix.nox-session == 'pytest_min' }} and ideally we should be consistent on how these statements are written.
IMO it feels safer to always use ${{ }}, and I agree it doesn't look good

uses: actions/cache/save@v4
with:
path: .pytest_cache
key: ${{ runner.os }}-pytest-cache-${{ matrix.os }}-${{ matrix.python }}-${{ github.ref_name }}-${{ github.run_number }}

# This job runs if all the `nox` matrix jobs ran and succeeded.
# It is only used to have a single job that we can require in branch
# protection rules, so we don't have to update the protection rules each time
Expand Down
Loading