Skip to content

Commit 911e78f

Browse files
committed
🧪🚑 Fix using check_source flags as bool
Previously, those flags would sometimes end up having empty string values, which tends to break evaluating them as JSON. This patch adds `false` fallbacks to all such outputs. This allows feeding them to `fromJSON()` without a fear of them causing surprising internal behaviors in the GitHub Actions CI/CD workflows platform itself [[1]]. The behavior observed was that some skipped jobs wouldn't show up in the workflow sidebar view at all, would display in the graph view as `Waiting for pending jobs` and in the `${{ needs }}` context, they would have a `result: failure` entry [[2]]. This should help make PRs like #121831 mergeable again. [1]: #121766 (comment) [2]: https://github.com/python/cpython/actions/runs/9950331379/job/27501637459?pr=121831#step:2:244
1 parent f27593a commit 911e78f

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

‎.github/workflows/build.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,33 @@ jobs:
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 10
2929
outputs:
30+
# NOTE: Some of the referenced steps set outputs conditionally and there
31+
# NOTE: may be cases when referencing them evaluates to empty strings. It
32+
# NOTE: is nice to work with proper booleans so they have to be evaluated
33+
# NOTE: through JSON conversion in the expressions. However, empty
34+
# NOTE: strings used like that may trigger all sorts of undefined and
35+
# NOTE: hard-to-debug behaviors in GitHub Actions CI/CD. To help with
36+
# NOTE: this, all of the outputs set here that are meant to be used as
37+
# NOTE: boolean flags (and not arbitrary strings), MUST have fallbacks
38+
# NOTE: with default values set. A common pattert would be to add
39+
# NOTE: ` || false` to all such expressions here, in the output
40+
# NOTE: definitions. They can then later be safely used through the
41+
# NOTE: following idiom in job conditionals and other expressions. Here's
42+
# NOTE: some examples:
43+
# NOTE:
44+
# NOTE: if: fromJSON(needs.check_source.outputs.run-docs)
45+
# NOTE:
46+
# NOTE: ${{
47+
# NOTE: fromJSON(needs.check_source.outputs.run_tests)
48+
# NOTE: && 'truthy-branch'
49+
# NOTE: || 'falsy-branch'
50+
# NOTE: }}
51+
# NOTE:
3052
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
31-
run_tests: ${{ steps.check.outputs.run_tests }}
32-
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
33-
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
34-
config_hash: ${{ steps.config_hash.outputs.hash }}
53+
run_tests: ${{ steps.check.outputs.run_tests || false }}
54+
run_hypothesis: ${{ steps.check.outputs.run_hypothesis || false }}
55+
run_cifuzz: ${{ steps.check.outputs.run_cifuzz || false }}
56+
config_hash: ${{ steps.config_hash.outputs.hash }} # str
3557
steps:
3658
- uses: actions/checkout@v4
3759
- name: Check for source changes

0 commit comments

Comments
 (0)