1717 - uv.lock
1818 - ' **.pyi?'
1919 push :
20+ branches-ignore :
21+ - translations
2022 paths : *on_paths
2123 workflow_dispatch :
2224
23- concurrency :
24- group : ${{ github.workflow }}-${{ github.ref }}
25- cancel-in-progress : true
26-
2725defaults :
2826 run :
2927 shell : sh
3028
3129jobs :
3230 run-conditions :
31+ permissions :
32+ pull-requests : read
33+
3334 name : Run Conditions
3435 runs-on : ubuntu-latest
3536 outputs :
@@ -38,14 +39,25 @@ jobs:
3839 ruff : ${{ steps.run-conditions.outputs.ruff }}
3940 steps :
4041 - name : Checkout repository
42+ if : github.event_name != 'pull_request'
4143 uses : actions/checkout@v7
4244 with :
43- fetch-depth : 0
45+ # Largest positive number; infinite depth.
46+ # Using 0 would grab all branches.
47+ # See: https://github.com/actions/checkout/issues/520
48+ # See: https://stackoverflow.com/questions/6802145/how-to-convert-a-git-shallow-clone-to-a-full-clone/6802238#6802238
49+ # `git fetch --unshallow` as suggested in later answers would be an extra operation.
50+ fetch-depth : ' 2147483647'
4451
4552 - name : Check changed files
4653 id : changed-files
4754 uses : tj-actions/changed-files@v47.0.6
4855 with :
56+ fail_on_initial_diff_error : ' true'
57+ fail_on_submodule_diff_error : ' true'
58+ skip_initial_fetch : ' true'
59+
60+ # WARNING: Does not support `?` glob operand!
4961 files_yaml : |
5062 generic:
5163 - .github/workflows/checks_python.yml
@@ -65,14 +77,42 @@ jobs:
6577
6678 - name : Set run conditions
6779 id : run-conditions
80+ env :
81+ CHANGED_GENERIC : ${{ steps.changed-files.outputs.generic_any_changed }}
82+ CHANGED_PYRIGHT : ${{ steps.changed-files.outputs.pyright_any_changed }}
83+ CHANGED_PYTEST : ${{ steps.changed-files.outputs.pytest_any_changed }}
84+ CHANGED_RUFF : ${{ steps.changed-files.outputs.ruff_any_changed }}
6885 run : |
86+ pyright=false
87+ pytest=false
88+ ruff=false
89+ if [ "${CHANGED_GENERIC}" = true ]; then
90+ pyright=true
91+ pytest=true
92+ ruff=true
93+ else
94+ if [ "${CHANGED_PYRIGHT}" = true ]; then
95+ pyright=true
96+ fi
97+ if [ "${CHANGED_PYTEST}" = true ]; then
98+ pytest=true
99+ fi
100+ if [ "${CHANGED_RUFF}" = true ]; then
101+ ruff=true
102+ fi
103+ fi
104+
69105 cat <<EOF >>"${GITHUB_OUTPUT}"
70- pyright=${{ steps.changed-files.outputs.generic_any_changed || steps.changed-files.outputs.pyright_any_changed } }
71- pytest=${{ steps.changed-files.outputs.generic_any_changed || steps.changed-files.outputs.pytest_any_changed } }
72- ruff=${{ steps.changed-files.outputs.generic_any_changed || steps.changed-files.outputs.ruff_any_changed } }
106+ pyright=${pyright }
107+ pytest=${pytest }
108+ ruff=${ruff }
73109 EOF
74110
75111 check-pyright :
112+ concurrency :
113+ group : pyright-${{ github.workflow }}-${{ github.ref }}
114+ cancel-in-progress : true
115+
76116 name : Pyright
77117 needs : run-conditions
78118 if : needs.run-conditions.outputs.pyright == 'true'
93133 run : pyright
94134
95135 check-pytest :
136+ concurrency :
137+ group : ${{ matrix.os }}-pytest-${{ github.workflow }}-${{ github.ref }}
138+ cancel-in-progress : true
96139 strategy :
97140 fail-fast : false
98141 matrix :
@@ -155,6 +198,10 @@ jobs:
155198 run : pytest
156199
157200 check-ruff :
201+ concurrency :
202+ group : ruff-${{ github.workflow }}-${{ github.ref }}
203+ cancel-in-progress : true
204+
158205 name : Ruff
159206 needs : run-conditions
160207 if : needs.run-conditions.outputs.ruff == 'true'
0 commit comments