Skip to content

Commit e265fa5

Browse files
committed
Rename to "context" from "change-detection"
1 parent f45c009 commit e265fa5

File tree

3 files changed

+58
-66
lines changed

3 files changed

+58
-66
lines changed

.github/workflows/build.yml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ env:
2222
FORCE_COLOR: 1
2323

2424
jobs:
25-
check_source:
25+
build-context:
2626
name: Change detection
2727
# To use boolean outputs from this job, parse them as JSON.
2828
# Here's some examples:
2929
#
30-
# if: fromJSON(needs.check_source.outputs.run-docs)
30+
# if: fromJSON(needs.build-context.outputs.run-docs)
3131
#
3232
# ${{
33-
# fromJSON(needs.check_source.outputs.run-tests)
33+
# fromJSON(needs.build-context.outputs.run-tests)
3434
# && 'truthy-branch'
3535
# || 'falsy-branch'
3636
# }}
@@ -39,8 +39,8 @@ jobs:
3939

4040
check-docs:
4141
name: Docs
42-
needs: check_source
43-
if: fromJSON(needs.check_source.outputs.run-docs)
42+
needs: build-context
43+
if: fromJSON(needs.build-context.outputs.run-docs)
4444
uses: ./.github/workflows/reusable-docs.yml
4545

4646
check_autoconf_regen:
@@ -51,8 +51,8 @@ jobs:
5151
container:
5252
image: ghcr.io/python/autoconf:2025.01.02.12581854023
5353
timeout-minutes: 60
54-
needs: check_source
55-
if: needs.check_source.outputs.run-tests == 'true'
54+
needs: build-context
55+
if: needs.build-context.outputs.run-tests == 'true'
5656
steps:
5757
- name: Install Git
5858
run: |
@@ -94,8 +94,8 @@ jobs:
9494
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
9595
runs-on: ubuntu-24.04
9696
timeout-minutes: 60
97-
needs: check_source
98-
if: needs.check_source.outputs.run-tests == 'true'
97+
needs: build-context
98+
if: needs.build-context.outputs.run-tests == 'true'
9999
steps:
100100
- uses: actions/checkout@v4
101101
with:
@@ -110,7 +110,7 @@ jobs:
110110
with:
111111
path: config.cache
112112
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
113-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config-hash }}-${{ env.pythonLocation }}
113+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
114114
- name: Install Dependencies
115115
run: sudo ./.github/workflows/posix-deps-apt.sh
116116
- name: Add ccache to PATH
@@ -153,8 +153,8 @@ jobs:
153153
name: >-
154154
Windows
155155
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
156-
needs: check_source
157-
if: fromJSON(needs.check_source.outputs.run-tests)
156+
needs: build-context
157+
if: fromJSON(needs.build-context.outputs.run-tests)
158158
strategy:
159159
fail-fast: false
160160
matrix:
@@ -184,8 +184,8 @@ jobs:
184184
build_windows_msi:
185185
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
186186
Windows MSI${{ '' }}
187-
needs: check_source
188-
if: fromJSON(needs.check_source.outputs.run-windows-msi)
187+
needs: build-context
188+
if: fromJSON(needs.build-context.outputs.run-windows-msi)
189189
strategy:
190190
matrix:
191191
arch:
@@ -200,8 +200,8 @@ jobs:
200200
name: >-
201201
macOS
202202
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
203-
needs: check_source
204-
if: needs.check_source.outputs.run-tests == 'true'
203+
needs: build-context
204+
if: needs.build-context.outputs.run-tests == 'true'
205205
strategy:
206206
fail-fast: false
207207
matrix:
@@ -226,7 +226,7 @@ jobs:
226226
free-threading: true
227227
uses: ./.github/workflows/reusable-macos.yml
228228
with:
229-
config_hash: ${{ needs.check_source.outputs.config-hash }}
229+
config_hash: ${{ needs.build-context.outputs.config-hash }}
230230
free-threading: ${{ matrix.free-threading }}
231231
os: ${{ matrix.os }}
232232

@@ -235,8 +235,8 @@ jobs:
235235
Ubuntu
236236
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
237237
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
238-
needs: check_source
239-
if: needs.check_source.outputs.run-tests == 'true'
238+
needs: build-context
239+
if: needs.build-context.outputs.run-tests == 'true'
240240
strategy:
241241
matrix:
242242
bolt:
@@ -257,7 +257,7 @@ jobs:
257257
bolt: true
258258
uses: ./.github/workflows/reusable-ubuntu.yml
259259
with:
260-
config_hash: ${{ needs.check_source.outputs.config-hash }}
260+
config_hash: ${{ needs.build-context.outputs.config-hash }}
261261
bolt-optimizations: ${{ matrix.bolt }}
262262
free-threading: ${{ matrix.free-threading }}
263263
os: ${{ matrix.os }}
@@ -266,8 +266,8 @@ jobs:
266266
name: 'Ubuntu SSL tests with OpenSSL'
267267
runs-on: ${{ matrix.os }}
268268
timeout-minutes: 60
269-
needs: check_source
270-
if: needs.check_source.outputs.run-tests == 'true'
269+
needs: build-context
270+
if: needs.build-context.outputs.run-tests == 'true'
271271
strategy:
272272
fail-fast: false
273273
matrix:
@@ -289,7 +289,7 @@ jobs:
289289
uses: actions/cache@v4
290290
with:
291291
path: config.cache
292-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config-hash }}
292+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
293293
- name: Register gcc problem matcher
294294
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
295295
- name: Install Dependencies
@@ -326,18 +326,18 @@ jobs:
326326

327327
build_wasi:
328328
name: 'WASI'
329-
needs: check_source
330-
if: needs.check_source.outputs.run-tests == 'true'
329+
needs: build-context
330+
if: needs.build-context.outputs.run-tests == 'true'
331331
uses: ./.github/workflows/reusable-wasi.yml
332332
with:
333-
config_hash: ${{ needs.check_source.outputs.config-hash }}
333+
config_hash: ${{ needs.build-context.outputs.config-hash }}
334334

335335
test_hypothesis:
336336
name: "Hypothesis tests on Ubuntu"
337337
runs-on: ubuntu-24.04
338338
timeout-minutes: 60
339-
needs: check_source
340-
if: needs.check_source.outputs.run-tests == 'true'
339+
needs: build-context
340+
if: needs.build-context.outputs.run-tests == 'true'
341341
env:
342342
OPENSSL_VER: 3.0.15
343343
PYTHONSTRICTEXTENSIONBUILD: 1
@@ -384,7 +384,7 @@ jobs:
384384
uses: actions/cache@v4
385385
with:
386386
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
387-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config-hash }}
387+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
388388
- name: Configure CPython out-of-tree
389389
working-directory: ${{ env.CPYTHON_BUILDDIR }}
390390
run: |
@@ -452,8 +452,8 @@ jobs:
452452
name: 'Address sanitizer'
453453
runs-on: ${{ matrix.os }}
454454
timeout-minutes: 60
455-
needs: check_source
456-
if: needs.check_source.outputs.run-tests == 'true'
455+
needs: build-context
456+
if: needs.build-context.outputs.run-tests == 'true'
457457
strategy:
458458
matrix:
459459
os: [ubuntu-24.04]
@@ -471,7 +471,7 @@ jobs:
471471
uses: actions/cache@v4
472472
with:
473473
path: config.cache
474-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config-hash }}
474+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
475475
- name: Register gcc problem matcher
476476
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
477477
- name: Install Dependencies
@@ -515,23 +515,23 @@ jobs:
515515
name: >-
516516
Thread sanitizer
517517
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
518-
needs: check_source
519-
if: needs.check_source.outputs.run-tests == 'true'
518+
needs: build-context
519+
if: needs.build-context.outputs.run-tests == 'true'
520520
strategy:
521521
matrix:
522522
free-threading:
523523
- false
524524
- true
525525
uses: ./.github/workflows/reusable-tsan.yml
526526
with:
527-
config_hash: ${{ needs.check_source.outputs.config-hash }}
527+
config_hash: ${{ needs.build-context.outputs.config-hash }}
528528
free-threading: ${{ matrix.free-threading }}
529529

530530
cross-build-linux:
531531
name: Cross build Linux
532532
runs-on: ubuntu-latest
533-
needs: check_source
534-
if: needs.check_source.outputs.run-tests == 'true'
533+
needs: build-context
534+
if: needs.build-context.outputs.run-tests == 'true'
535535
steps:
536536
- uses: actions/checkout@v4
537537
with:
@@ -542,7 +542,7 @@ jobs:
542542
uses: actions/cache@v4
543543
with:
544544
path: config.cache
545-
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config-hash }}
545+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.build-context.outputs.config-hash }}
546546
- name: Register gcc problem matcher
547547
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
548548
- name: Set build dir
@@ -571,8 +571,8 @@ jobs:
571571
name: CIFuzz
572572
runs-on: ubuntu-latest
573573
timeout-minutes: 60
574-
needs: check_source
575-
if: needs.check_source.outputs.run-ci-fuzz == 'true'
574+
needs: build-context
575+
if: needs.build-context.outputs.run-ci-fuzz == 'true'
576576
permissions:
577577
security-events: write
578578
strategy:
@@ -611,7 +611,7 @@ jobs:
611611
if: always()
612612

613613
needs:
614-
- check_source # Transitive dependency, needed to access `run-tests` value
614+
- build-context # Transitive dependency, needed to access `run-tests` value
615615
- check-docs
616616
- check_autoconf_regen
617617
- check_generated_files
@@ -639,14 +639,14 @@ jobs:
639639
test_hypothesis,
640640
allowed-skips: >-
641641
${{
642-
!fromJSON(needs.check_source.outputs.run-docs)
642+
!fromJSON(needs.build-context.outputs.run-docs)
643643
&& '
644644
check-docs,
645645
'
646646
|| ''
647647
}}
648648
${{
649-
needs.check_source.outputs.run-tests != 'true'
649+
needs.build-context.outputs.run-tests != 'true'
650650
&& '
651651
check_autoconf_regen,
652652
check_generated_files,
@@ -662,7 +662,7 @@ jobs:
662662
|| ''
663663
}}
664664
${{
665-
!fromJSON(needs.check_source.outputs.run-ci-fuzz)
665+
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
666666
&& '
667667
cifuzz,
668668
'

.github/workflows/reusable-change-detection.yml renamed to .github/workflows/reusable-context.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
name: Reusable change detection
1+
name: Reusable build context
22

33
on: # yamllint disable-line rule:truthy
44
workflow_call:
55
outputs:
6-
# Some of the referenced steps set outputs conditionally and there may be
7-
# cases when referencing them evaluates to empty strings. It is nice to
8-
# work with proper booleans so they have to be evaluated through JSON
9-
# conversion in the expressions. However, empty strings used like that
10-
# may trigger all sorts of undefined and hard-to-debug behaviors in
11-
# GitHub Actions CI/CD. To help with this, all of the outputs set here
12-
# that are meant to be used as boolean flags (and not arbitrary strings),
13-
# MUST have fallbacks with default values set. A common pattern would be
14-
# to add ` || false` to all such expressions here, in the output
15-
# definitions. They can then later be safely used through the following
16-
# idiom in job conditionals and other expressions. Here's some examples:
6+
# Every referenced step MUST always its set output variable,
7+
# either via ``Tools/build/compute-changes.py`` or in this workflow file.
8+
# Boolean outputs (generally prefixed ``run-``) can then later be used
9+
# safely through the following idiom in job conditionals and other
10+
# expressions. Here's some examples:
1711
#
18-
# if: fromJSON(needs.change-detection.outputs.run-docs)
12+
# if: fromJSON(needs.build-context.outputs.run-tests)
1913
#
2014
# ${{
21-
# fromJSON(needs.change-detection.outputs.run-tests)
15+
# fromJSON(needs.build-context.outputs.run-tests)
2216
# && 'truthy-branch'
2317
# || 'falsy-branch'
2418
# }}
@@ -28,22 +22,20 @@ on: # yamllint disable-line rule:truthy
2822
value: ${{ jobs.compute-changes.outputs.config-hash }} # str
2923
run-docs:
3024
description: Whether to build the docs
31-
value: ${{ jobs.compute-changes.outputs.run-docs || false }} # bool
25+
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
3226
run-tests:
3327
description: Whether to run the regular tests
34-
value: ${{ jobs.compute-changes.outputs.run-tests || false }} # bool
28+
value: ${{ jobs.compute-changes.outputs.run-tests }} # bool
3529
run-windows-msi:
3630
description: Whether to run the MSI installer smoke tests
37-
value: >- # bool
38-
${{ jobs.compute-changes.outputs.run-windows-msi || false }}
31+
value: ${{ jobs.compute-changes.outputs.run-windows-msi }} # bool
3932
run-ci-fuzz:
4033
description: Whether to run the CIFuzz job
41-
value: >- # bool
42-
${{ jobs.compute-changes.outputs.run-ci-fuzz || false }}
34+
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
4335

4436
jobs:
4537
compute-changes:
46-
name: Compute changed files
38+
name: Create context from changed files
4739
runs-on: ubuntu-latest
4840
timeout-minutes: 10
4941
outputs:

Tools/build/compute-changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Determine which GitHub Actions workflows to run.
22
3-
Called by ``.github/workflows/reusable-change-detection.yml``.
3+
Called by ``.github/workflows/reusable-context.yml``.
44
We only want to run tests on PRs when related files are changed,
55
or when someone triggers a manual workflow run.
66
This improves developer experience by not doing (slow)

0 commit comments

Comments
 (0)