Skip to content

The agent that grows with you

ci: skip R2-dependent jobs when release-signing secrets are absent

ethernet3dc75f5ab750
diff --git a/.github/workflows/archive-inputs.yml b/.github/workflows/archive-inputs.yml
index 3e69a582255..5e4ba176c40 100644
--- a/.github/workflows/archive-inputs.yml
+++ b/.github/workflows/archive-inputs.yml
@@ -38,5 +38,12 @@ jobs:
ref: ${{ inputs.sha || github.sha }}
persist-credentials: false
# Runner Python is intentional: the toolchain's upstream may be gone.
+ # A job-level `if` cannot read `secrets`; the job env can. Forks and a
+ # repo whose release-signing environment is not provisioned yet must
+ # skip the archive, not turn main red.
- name: Verify and archive every pinned input
+ if: env.CLOUDFLARE_R2_ACCOUNT_ID != ''
run: python3 -m scripts.ci.archive_inputs
+ - name: Report the unprovisioned archive
+ if: env.CLOUDFLARE_R2_ACCOUNT_ID == ''
+ run: echo "::notice::CLOUDFLARE_R2_* secrets are not configured; pinned inputs were not archived."
diff --git a/.github/workflows/canary-release.yml b/.github/workflows/canary-release.yml
index 78692dcf668..aa005b4fb70 100644
--- a/.github/workflows/canary-release.yml
+++ b/.github/workflows/canary-release.yml
@@ -70,6 +70,14 @@ jobs:
# runs in its own workflow run now, so this no longer waits on it —
# the window is 14 days, far wider than any build.
if: always() && needs.tag.result != 'cancelled'
+ # Job-level so the R2 prune step can gate on `env` (a step `if` cannot
+ # read `secrets`): an unprovisioned release-signing environment skips
+ # the R2 prune instead of failing the nightly.
+ env:
+ CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}
+ CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
+ CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
+ CLOUDFLARE_R2_BUCKET: ${{ vars.CLOUDFLARE_R2_BUCKET }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
@@ -80,12 +88,9 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/release.py --prune-canaries --publish --remote origin
- uses: ./.github/actions/setup-pm
+ if: env.CLOUDFLARE_R2_ACCOUNT_ID != ''
with:
cache-python: false
- name: Prune R2 canary objects
- env:
- CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}
- CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
- CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
- CLOUDFLARE_R2_BUCKET: ${{ vars.CLOUDFLARE_R2_BUCKET }}
+ if: env.CLOUDFLARE_R2_ACCOUNT_ID != ''
run: python -m scripts.ci.python_packages ruamel.yaml==0.18.17 -- -m scripts.releases.r2 prune-canaries --keep-days 14
diff --git a/.github/workflows/termux-verify.yml b/.github/workflows/termux-verify.yml
index e952724002e..9f2ee8c6daa 100644
--- a/.github/workflows/termux-verify.yml
+++ b/.github/workflows/termux-verify.yml
@@ -2,11 +2,17 @@ name: Termux verification
on:
push:
- branches: [ethie/cli-bundles]
+ branches: [main]
paths:
- 'scripts/termux/**'
- 'pm/**'
- - 'tests/test_termux*'
+ - 'tests/scripts/test_termux*'
+ - '.github/workflows/termux-verify.yml'
+ pull_request:
+ paths:
+ - 'scripts/termux/**'
+ - 'pm/**'
+ - 'tests/scripts/test_termux*'
- '.github/workflows/termux-verify.yml'
workflow_dispatch:
workflow_call:
@@ -81,9 +87,32 @@ jobs:
npm run check --workspace ui-tui
npm run build --workspace ui-tui
+ # A job-level `if` cannot read `secrets`, so the gate is a job that exports
+ # whether the release-signing environment is provisioned. Without R2 the
+ # bionic verification below cannot fetch its pinned inputs; skipping it
+ # keeps a fork or an unprovisioned main green instead of red.
+ r2-provisioned:
+ name: Detect R2 credentials
+ if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
+ runs-on: ubuntu-24.04
+ environment: release-signing
+ timeout-minutes: 5
+ outputs:
+ configured: ${{ steps.check.outputs.configured }}
+ steps:
+ - id: check
+ env:
+ CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}
+ run: |
+ echo "configured=${CLOUDFLARE_R2_ACCOUNT_ID:+true}" >> "$GITHUB_OUTPUT"
+ [ -n "$CLOUDFLARE_R2_ACCOUNT_ID" ] || echo "::notice::CLOUDFLARE_R2_* secrets are not configured; the bionic runtime verification is skipped."
+
native-runtime:
name: Verify bionic runtime tools
- if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
+ needs: r2-provisioned
+ # A stable-release candidate run still fails loudly on missing R2: the
+ # release must not pass on a skipped verification.
+ if: needs.r2-provisioned.outputs.configured == 'true' || inputs.release == true
runs-on: ubuntu-24.04-arm
environment: release-signing
timeout-minutes: 45
diff --git a/tests/ci/test_termux_input_archive.py b/tests/ci/test_termux_input_archive.py
index 034e86d3e5e..05a799223cc 100644
--- a/tests/ci/test_termux_input_archive.py
+++ b/tests/ci/test_termux_input_archive.py
@@ -8,6 +8,7 @@ from ruamel.yaml import YAML
ROOT = Path(__file__).resolve().parents[2]
R2_ENV = {"CLOUDFLARE_R2_ACCOUNT_ID", "CLOUDFLARE_R2_ACCESS_KEY_ID", "CLOUDFLARE_R2_SECRET_ACCESS_KEY", "CLOUDFLARE_R2_BUCKET"}
+R2_GATE = "env.CLOUDFLARE_R2_ACCOUNT_ID != ''"
def load(name):
@@ -40,7 +41,9 @@ def test_archive_gate_uses_bootstrap_python_and_trusted_exact_revision():
assert job["environment"] == "release-signing"
assert R2_ENV <= job["env"].keys()
assert not any(s.get("uses") == "./.github/actions/setup-pm" for s in job["steps"])
- assert job["steps"][-1]["run"] == "python3 -m scripts.ci.archive_inputs"
+ (archive,) = [s for s in job["steps"] if s.get("run") == "python3 -m scripts.ci.archive_inputs"]
+ # Pushes to main without R2 credentials skip the archive rather than fail.
+ assert archive["if"] == R2_GATE
checkout = job["steps"][0]
assert checkout["with"]["ref"] == "${{ inputs.sha || github.sha }}"
release = load("desktop-bundled-release.yml")["jobs"]
@@ -65,3 +68,19 @@ def test_archive_gate_uses_bootstrap_python_and_trusted_exact_revision():
archive_index, archive = next((i, s) for i, s in enumerate(steps) if "setup_toolchain.py\" archive-inputs" in s.get("run", ""))
assert archive["if"] == "inputs.archive-inputs == 'true'"
assert archive_index < next(i for i, s in enumerate(steps) if s.get("id") == "install")
+
+
+def test_scheduled_and_main_r2_consumers_skip_without_credentials():
+ """Only explicit release runs may fail on missing R2; main and the nightly stay green."""
+ prune = load("canary-release.yml")["jobs"]["prune"]
+ assert R2_ENV <= prune["env"].keys()
+ r2_steps = [s for s in prune["steps"] if "scripts.releases.r2" in s.get("run", "")]
+ assert r2_steps and all(s["if"] == R2_GATE for s in r2_steps)
+
+ termux = load("termux-verify.yml")
+ assert termux["on"]["push"]["branches"] == ["main"] and "pull_request" in termux["on"]
+ native = termux["jobs"]["native-runtime"]
+ gate = termux["jobs"][native["needs"]]
+ assert gate["environment"] == "release-signing"
+ assert native["if"] == f"needs.{native['needs']}.outputs.configured == 'true' || inputs.release == true"
+