Skip to content

Commit 4069c5f

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 4069c5f

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

‎.github/workflows/build.yml

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

0 commit comments

Comments
 (0)