Skip to content

Commit a270fe2

Browse files
committed
run mypy even if ruff fails
Because all the checks are performed in the same job and github actions will stop at the first step failure within a job, if one of the ruff checks (formatting or checking) fails then mypy does not run at all, which is undesirable. Turns out the steps have an implicit `if success()` if no [status check function][check] (`success`, `failure`, `always`, `cancelled`) is used to guard the step. Thus by gating on `always` and possibly explicitly checking the conclusion of specific checks it becomes possible to run `mypy` even though `ruff check` failed, but not run it if *installing* mypy failed. [check]: https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
1 parent 63eda17 commit a270fe2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,30 @@ on:
1515
jobs:
1616
checks:
1717
runs-on: ubuntu-latest
18-
strategy:
19-
fail-fast: false
2018
steps:
2119
- name: Checkout working copy
2220
uses: actions/checkout@v4
2321
- name: ruff check
2422
uses: chartboost/ruff-action@v1
2523
- name: ruff format
24+
if: always()
2625
uses: chartboost/ruff-action@v1
2726
with:
2827
args: format --diff
2928
- name: Set up Python
29+
id: setup_python
30+
if: always()
3031
uses: actions/setup-python@v5
3132
with:
3233
python-version: "3.x"
3334
- name: Install mypy
35+
id: install_mypy
36+
if: ${{ always() && steps.setup_python.conclusion == 'success' }}
3437
run: |
3538
python -mpip install --upgrade pip
3639
python -mpip install mypy types-PyYaml
3740
- name: mypy
41+
if: ${{ always() && steps.install_mypy.conclusion == 'success' }}
3842
run: mypy
3943

4044
# REPLACE BY: job which python -mbuild, and uploads the sdist and wheel to artifacts

0 commit comments

Comments
 (0)