Skip to content

Commit 28d824d

Browse files
authored
Select all jobs when testing (#368)
1 parent dea2a74 commit 28d824d

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

.github/workflows/build-release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ jobs:
6161
echo "git_commit: $GIT_COMMIT"
6262
echo "cpython_release: $CPYTHON_RELEASE"
6363
64+
{
65+
echo "| Variable | Value |"
66+
echo "| --------------- | -------------------- |"
67+
echo "| git_remote | \`$GIT_REMOTE\` |"
68+
echo "| git_commit | \`$GIT_COMMIT\` |"
69+
echo "| cpython_release | \`$CPYTHON_RELEASE\` |"
70+
} >> "$GITHUB_STEP_SUMMARY"
71+
6472
- name: "Checkout python/release-tools"
6573
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6674
with:
@@ -89,7 +97,20 @@ jobs:
8997
- name: "Select jobs"
9098
id: select-jobs
9199
run: |
92-
./select_jobs.py "$CPYTHON_RELEASE" | tee -a "$GITHUB_OUTPUT"
100+
test_flag=""
101+
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
102+
test_flag="--test"
103+
fi
104+
output=$(./select_jobs.py $test_flag "$CPYTHON_RELEASE")
105+
echo "$output" | tee -a "$GITHUB_OUTPUT"
106+
107+
{
108+
echo "| Job | Enabled |"
109+
echo "| ------- | ------- |"
110+
echo "$output" | while IFS='=' read -r key value; do
111+
echo "| $key | $value |"
112+
done
113+
} >> "$GITHUB_STEP_SUMMARY"
93114
94115
build-source:
95116
runs-on: ubuntu-24.04

select_jobs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@ def output(key: str, value: bool) -> None:
1212
def main() -> None:
1313
parser = argparse.ArgumentParser()
1414
parser.add_argument("version", type=Tag)
15+
parser.add_argument(
16+
"--test",
17+
action="store_true",
18+
help="Enable all jobs for testing",
19+
)
1520
args = parser.parse_args()
1621
version = args.version
1722

23+
if args.test:
24+
# When testing the workflow itself (push/PR),
25+
# enable all jobs for full coverage.
26+
output("docs", True)
27+
output("android", True)
28+
output("ios", True)
29+
return
30+
1831
# Docs are only built for stable releases or release candidates.
1932
output("docs", version.level in ["rc", "f"])
2033

tests/test_select_jobs.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,28 @@ def test_select_jobs(
3838
ios={ios}
3939
"""
4040
)
41+
42+
43+
@pytest.mark.parametrize(
44+
"version",
45+
[
46+
"3.13.0a1",
47+
"3.13.0",
48+
"3.14.0b2",
49+
"3.15.0a1",
50+
],
51+
)
52+
def test_select_jobs_test_mode(
53+
version: str,
54+
monkeypatch: pytest.MonkeyPatch,
55+
capsys: pytest.CaptureFixture[str],
56+
) -> None:
57+
monkeypatch.setattr(sys, "argv", ["select_jobs.py", "--test", version])
58+
select_jobs.main()
59+
assert capsys.readouterr().out == dedent(
60+
"""\
61+
docs=true
62+
android=true
63+
ios=true
64+
"""
65+
)

0 commit comments

Comments
 (0)