Skip to content

Commit e532142

Browse files
committed
fix(ci): tolerate absent secrets and run setup before clippy
Fork pull requests receive no secrets, so secret-env now warns and skips a missing name instead of failing every leg, matching the inline jobs it replaces. rust-tests runs setup-script and teardown-script around clippy too, since build scripts such as blasthttp's vendored OpenSSL run during clippy.
1 parent bc01e9c commit e532142

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎.github/workflows/python-tests.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ jobs:
9595
python3 - <<'PY'
9696
import json, os, secrets
9797
values, names = json.loads(os.environ["SECRETS"]), json.loads(os.environ["NAMES"])
98-
missing = [n for n in names if n not in values]
99-
if missing:
100-
raise SystemExit(f"secrets not passed by caller: {missing}")
98+
for n in names:
99+
if not values.get(n):
100+
print(f"::warning::secret {n} is unavailable, as on fork pull requests")
101101
with open(os.environ["GITHUB_ENV"], "a") as env:
102-
for n in names:
102+
for n in filter(values.get, names):
103103
delim = secrets.token_hex(16)
104104
env.write(f"{n}<<{delim}\n{values[n]}\n{delim}\n")
105105
PY

‎.github/workflows/rust-tests.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
type: string
1515
default: ""
1616
setup-script:
17-
description: Repository script run before the test. It may append to $GITHUB_ENV.
17+
description: Repository script run before clippy and before the test. It may append to $GITHUB_ENV.
1818
type: string
1919
default: ""
2020
teardown-script:
@@ -40,11 +40,19 @@ jobs:
4040
with:
4141
workspaces: ${{ inputs.working-directory }}
4242
- run: cargo fmt --all -- --check
43+
- if: inputs.setup-script != ''
44+
env:
45+
SCRIPT: ${{ inputs.setup-script }}
46+
run: '"./$SCRIPT"'
4347
- env:
4448
CARGO_ARGS: ${{ inputs.cargo-args }}
4549
run: |
4650
read -ra args <<<"$CARGO_ARGS"
4751
cargo clippy --all-targets "${args[@]}" -- -D warnings
52+
- if: always() && inputs.teardown-script != ''
53+
env:
54+
SCRIPT: ${{ inputs.teardown-script }}
55+
run: '"./$SCRIPT"'
4856

4957
test:
5058
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)