diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 40e04e32..6b25244e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -61,6 +61,14 @@ jobs: echo "git_commit: $GIT_COMMIT" echo "cpython_release: $CPYTHON_RELEASE" + { + echo "| Variable | Value |" + echo "| --------------- | -------------------- |" + echo "| git_remote | \`$GIT_REMOTE\` |" + echo "| git_commit | \`$GIT_COMMIT\` |" + echo "| cpython_release | \`$CPYTHON_RELEASE\` |" + } >> "$GITHUB_STEP_SUMMARY" + - name: "Checkout python/release-tools" uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -89,7 +97,20 @@ jobs: - name: "Select jobs" id: select-jobs run: | - ./select_jobs.py "$CPYTHON_RELEASE" | tee -a "$GITHUB_OUTPUT" + test_flag="" + if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then + test_flag="--test" + fi + output=$(./select_jobs.py $test_flag "$CPYTHON_RELEASE") + echo "$output" | tee -a "$GITHUB_OUTPUT" + + { + echo "| Job | Enabled |" + echo "| ------- | ------- |" + echo "$output" | while IFS='=' read -r key value; do + echo "| $key | $value |" + done + } >> "$GITHUB_STEP_SUMMARY" build-source: runs-on: ubuntu-24.04 diff --git a/select_jobs.py b/select_jobs.py index db2130b7..255b95e0 100755 --- a/select_jobs.py +++ b/select_jobs.py @@ -12,9 +12,22 @@ def output(key: str, value: bool) -> None: def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("version", type=Tag) + parser.add_argument( + "--test", + action="store_true", + help="Enable all jobs for testing", + ) args = parser.parse_args() version = args.version + if args.test: + # When testing the workflow itself (push/PR), + # enable all jobs for full coverage. + output("docs", True) + output("android", True) + output("ios", True) + return + # Docs are only built for stable releases or release candidates. output("docs", version.level in ["rc", "f"]) diff --git a/tests/test_select_jobs.py b/tests/test_select_jobs.py index 7b3148bc..670d630b 100644 --- a/tests/test_select_jobs.py +++ b/tests/test_select_jobs.py @@ -38,3 +38,28 @@ def test_select_jobs( ios={ios} """ ) + + +@pytest.mark.parametrize( + "version", + [ + "3.13.0a1", + "3.13.0", + "3.14.0b2", + "3.15.0a1", + ], +) +def test_select_jobs_test_mode( + version: str, + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], +) -> None: + monkeypatch.setattr(sys, "argv", ["select_jobs.py", "--test", version]) + select_jobs.main() + assert capsys.readouterr().out == dedent( + """\ + docs=true + android=true + ios=true + """ + )