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,20 +39,32 @@ 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
5264 - pyproject.toml
5365 - uv.lock
54- - '**.pyi?'
66+ - '**.py'
67+ - '**.pyi'
5568 pyright:
5669 - .github/actions/setup-python/action.yml
5770 pytest:
@@ -65,14 +78,42 @@ jobs:
6578
6679 - name : Set run conditions
6780 id : run-conditions
81+ env :
82+ CHANGED_GENERIC : ${{ steps.changed-files.outputs.generic_any_changed }}
83+ CHANGED_PYRIGHT : ${{ steps.changed-files.outputs.pyright_any_changed }}
84+ CHANGED_PYTEST : ${{ steps.changed-files.outputs.pytest_any_changed }}
85+ CHANGED_RUFF : ${{ steps.changed-files.outputs.ruff_any_changed }}
6886 run : |
87+ pyright=false
88+ pytest=false
89+ ruff=false
90+ if [ "${CHANGED_GENERIC}" = true ]; then
91+ pyright=true
92+ pytest=true
93+ ruff=true
94+ else
95+ if [ "${CHANGED_PYRIGHT}" = true ]; then
96+ pyright=true
97+ fi
98+ if [ "${CHANGED_PYTEST}" = true ]; then
99+ pytest=true
100+ fi
101+ if [ "${CHANGED_RUFF}" = true ]; then
102+ ruff=true
103+ fi
104+ fi
105+
69106 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 } }
107+ pyright=${pyright }
108+ pytest=${pytest }
109+ ruff=${ruff }
73110 EOF
74111
75112 check-pyright :
113+ concurrency :
114+ group : pyright-${{ github.workflow }}-${{ github.ref }}
115+ cancel-in-progress : true
116+
76117 name : Pyright
77118 needs : run-conditions
78119 if : needs.run-conditions.outputs.pyright == 'true'
93134 run : pyright
94135
95136 check-pytest :
137+ concurrency :
138+ group : ${{ matrix.os }}-pytest-${{ github.workflow }}-${{ github.ref }}
139+ cancel-in-progress : true
96140 strategy :
97141 fail-fast : false
98142 matrix :
@@ -155,6 +199,10 @@ jobs:
155199 run : pytest
156200
157201 check-ruff :
202+ concurrency :
203+ group : ruff-${{ github.workflow }}-${{ github.ref }}
204+ cancel-in-progress : true
205+
158206 name : Ruff
159207 needs : run-conditions
160208 if : needs.run-conditions.outputs.ruff == 'true'
0 commit comments