|
34 | 34 | jobs: |
35 | 35 | build: |
36 | 36 | runs-on: ${{ matrix.os }} |
37 | | - timeout-minutes: 40 |
| 37 | + # A cold `prepare-envs` over the whole workspace plus the full check suite does |
| 38 | + # not fit in 40 minutes on the slower matrix legs. The venvs cache keeps the |
| 39 | + # happy path short; this budget only covers the cold run. |
| 40 | + timeout-minutes: 120 |
38 | 41 | strategy: |
39 | 42 | fail-fast: false |
40 | 43 | matrix: |
|
71 | 74 | fi |
72 | 75 |
|
73 | 76 | - name: Set up Python ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} |
74 | | - uses: actions/setup-python@v5 |
| 77 | + uses: actions/setup-python@v6 |
75 | 78 | with: |
76 | 79 | python-version: ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} |
77 | 80 |
|
|
81 | 84 | # skip reinstalling whenever a restored venv already looks valid, so a stale |
82 | 85 | # partial-match restore could mask a dependency that was added since the cache |
83 | 86 | # was written. |
84 | | - - name: Cache all venvs |
85 | | - uses: actions/cache@v4 |
| 87 | + - name: Restore venvs cache |
| 88 | + id: venvs_cache |
| 89 | + uses: actions/cache/restore@v5 |
86 | 90 | with: |
87 | 91 | path: | |
88 | 92 | .venvs |
@@ -169,18 +173,33 @@ jobs: |
169 | 173 |
|
170 | 174 | # TODO: try to replace by finecode action |
171 | 175 | - name: Store the distribution packages |
172 | | - uses: actions/upload-artifact@v5 |
| 176 | + uses: actions/upload-artifact@v6 |
173 | 177 | if: runner.os == 'Linux' |
174 | 178 | with: |
175 | 179 | name: python-package-distributions |
176 | 180 | path: dist/ |
177 | 181 |
|
| 182 | + # Save the venvs explicitly instead of relying on actions/cache's own post-step: |
| 183 | + # that post-step skips the save when the job fails, which throws away a perfectly |
| 184 | + # good cold install just because a later check or test failed. The only |
| 185 | + # precondition here is that the install itself succeeded; on an exact key match |
| 186 | + # there is nothing new to save. |
| 187 | + - name: Save venvs cache |
| 188 | + if: ${{ always() && steps.install.outcome == 'success' && steps.venvs_cache.outputs.cache-hit != 'true' }} |
| 189 | + uses: actions/cache/save@v5 |
| 190 | + with: |
| 191 | + path: | |
| 192 | + .venvs |
| 193 | + **/.venvs |
| 194 | + key: ${{ runner.os }}-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml') }} |
| 195 | + |
178 | 196 | audit-private: |
179 | 197 | name: Audit (private layer) |
180 | 198 | runs-on: ubuntu-24.04 |
181 | | - # The `build` job's 40min budget is not enough: this job pays a cold |
182 | | - # prepare-envs over ~74 projects and then a workspace-wide audit_code, which |
183 | | - # is slow by design (see docs/guides/developing-finecode.md "Running checks"). |
| 199 | + # This job pays a cold prepare-envs over ~74 projects and then a |
| 200 | + # workspace-wide audit_code, which is slow by design (see |
| 201 | + # docs/guides/developing-finecode.md "Running checks"), so it carries its own |
| 202 | + # budget rather than inheriting the build matrix's. |
184 | 203 | timeout-minutes: 60 |
185 | 204 | # `secrets` is NOT available in jobs.<job_id>.if -- only github, needs, |
186 | 205 | # vars, inputs. An unavailable context evaluates to empty, so a secrets test |
@@ -219,7 +238,7 @@ jobs: |
219 | 238 |
|
220 | 239 | - name: Set up Python ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} |
221 | 240 | if: env.HAS_PRIVATE_CLONE_APP == 'true' |
222 | | - uses: actions/setup-python@v5 |
| 241 | + uses: actions/setup-python@v6 |
223 | 242 | with: |
224 | 243 | python-version: ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} |
225 | 244 |
|
@@ -257,16 +276,18 @@ jobs: |
257 | 276 | if: env.HAS_PRIVATE_CLONE_APP == 'true' |
258 | 277 | run: cp .github/ci/finecode-user.ci.toml finecode-user.toml |
259 | 278 |
|
260 | | - - name: Cache all venvs |
| 279 | + - name: Restore venvs cache |
| 280 | + id: venvs_cache |
261 | 281 | if: env.HAS_PRIVATE_CLONE_APP == 'true' |
262 | | - uses: actions/cache@v4 |
| 282 | + uses: actions/cache/restore@v5 |
263 | 283 | with: |
264 | 284 | path: | |
265 | 285 | .venvs |
266 | 286 | **/.venvs |
267 | 287 | key: ${{ runner.os }}-private-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml', 'finecode-user.toml') }} |
268 | 288 |
|
269 | 289 | - name: Install dependencies |
| 290 | + id: install |
270 | 291 | if: env.HAS_PRIVATE_CLONE_APP == 'true' |
271 | 292 | run: | |
272 | 293 | # CI must exercise this branch's local source, so finecode and its sibling |
@@ -303,3 +324,14 @@ jobs: |
303 | 324 | source .venvs/dev_workspace/bin/activate |
304 | 325 | python -m finecode run --log-level="$FINECODE_LOG_LEVEL" run_tests |
305 | 326 | shell: bash |
| 327 | + |
| 328 | + # See the matching step in the `build` job for the rationale: save the venvs |
| 329 | + # whenever the install succeeded, even if a later check, audit or test failed. |
| 330 | + - name: Save venvs cache |
| 331 | + if: ${{ always() && env.HAS_PRIVATE_CLONE_APP == 'true' && steps.install.outcome == 'success' && steps.venvs_cache.outputs.cache-hit != 'true' }} |
| 332 | + uses: actions/cache/save@v5 |
| 333 | + with: |
| 334 | + path: | |
| 335 | + .venvs |
| 336 | + **/.venvs |
| 337 | + key: ${{ runner.os }}-private-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml', 'finecode-user.toml') }} |
0 commit comments