From 6673e63ad20fc3b800bd433a0bb7c9180547d0c2 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:06:35 +0000 Subject: [PATCH 1/2] CI: macOS and Windows cache entries are named by the dependency settings alone, so next restores main's The macOS and Windows legs cache dependencies only, but their entries were named by the hash of every profile override, workspace crates' included. next's cargo-ci.toml and cargo-dev.toml set other workspace-crate levels than main's, so next's pushes never found main's entries and built every dependency from source (Windows 40-52 minutes, macOS 29-36, against 10-15 with an entry). `deps-profile` hashes `[profile.dev]` and `[profile.dev.package."*"]` of both files; every other override names a workspace crate (test_profile_overrides_name_only_workspace_members). It is the same on main, next and #3405 today. The Linux leg, which keeps workspace crates, keeps the full hash. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/workspace.yml | 18 +++++++++++++++++- scripts/test-workspace-tests.py | 8 ++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index bc6077bfa..e1891613b 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -44,6 +44,7 @@ jobs: filter: ${{ steps.select.outputs.filter }} audit: ${{ steps.audit.outputs.audit }} profile: ${{ steps.audit.outputs.profile }} + deps-profile: ${{ steps.audit.outputs.deps-profile }} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 @@ -67,6 +68,10 @@ jobs: # passes (scripts/ci-workspace-tests.sh), which names the Workspace legs' cache entries: # rust-cache's key does not hash these files, and an entry built with other overrides would be # rebuilt in full on every run. Other events than a pull request check out only these files. + # The macOS and Windows legs cache dependencies only, so `deps-profile` hashes only the + # settings that reach a dependency: `[profile.dev]` and `[profile.dev.package."*"]`. Every + # other override names a workspace crate (scripts/test-workspace-tests.py), so changing one + # keeps those entries, and next's runs restore main's. - uses: actions/checkout@v7.0.1 if: github.event_name != 'pull_request' with: @@ -83,6 +88,16 @@ jobs: run: | echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT" echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" + echo "deps-profile=$(python3 -I - <<'PY' + import hashlib, json, tomllib + kept = [] + for path in (".config/cargo-dev.toml", ".config/cargo-ci.toml"): + with open(path, "rb") as file: + dev = tomllib.load(file)["profile"]["dev"] + kept.append([dev, dev.pop("package", {}).get("*", {})]) + print(hashlib.sha256(json.dumps(kept, sort_keys=True).encode()).hexdigest()[:12]) + PY + )" >> "$GITHUB_OUTPUT" # The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each # main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo @@ -172,7 +187,8 @@ jobs: with: os: '["windows-latest","macos-latest"]' lint-cache: false - cache-version: *cache-version + # Named by the dependency settings alone (`deps-profile`), so next restores main's entries. + cache-version: v2-${{ needs.platforms.outputs.deps-profile }} timeout-minutes: *timeout tools: *tools craft-fonts-ref: *craft-fonts diff --git a/scripts/test-workspace-tests.py b/scripts/test-workspace-tests.py index 77cdccd2e..0bc036e0d 100644 --- a/scripts/test-workspace-tests.py +++ b/scripts/test-workspace-tests.py @@ -313,9 +313,13 @@ class WorkspaceTests(unittest.TestCase): # Only the Linux leg splits into a build job and shards, and only for the audit. self.assertEqual(source.count("test-shards:"), 1) self.assertIn("test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}", source) - # Every Workspace leg's cache entry is named after the profile overrides it was built with. + # The Linux leg's entry, which keeps workspace crates, is named after every profile override; + # the macOS and Windows legs' dependency-only entries after the settings that reach a + # dependency, so next restores main's (test_profile_overrides_name_only_workspace_members). self.assertIn("cache-version: &cache-version v2-${{ needs.platforms.outputs.profile }}\n", source) - self.assertIn(" cache-version: *cache-version\n", source) + self.assertIn(" cache-version: v2-${{ needs.platforms.outputs.deps-profile }}\n", source) + self.assertIn(" deps-profile: ${{ steps.audit.outputs.deps-profile }}\n", source) + self.assertNotIn(" cache-version: *cache-version\n", source) # Only the Linux leg keeps workspace crates; the cache budget has no room for the others. self.assertEqual(source.count("cache-workspace-crates: true"), 1) self.assertIn(" msrv:", source) From 0075c7e7fd6b5a6012c34372ca0d7522984e66d4 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:10:42 +0000 Subject: [PATCH 2/2] CI: a failed deps-profile hash stops the step instead of naming every entry v2- Co-Authored-By: Claude Opus 5.5 --- .github/workflows/workspace.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index e1891613b..11b1d9def 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -88,7 +88,8 @@ jobs: run: | echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT" echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" - echo "deps-profile=$(python3 -I - <<'PY' + # An assignment, so a failure stops the step (`bash -e`) instead of naming every entry `v2-`. + deps=$(python3 -I - <<'PY' import hashlib, json, tomllib kept = [] for path in (".config/cargo-dev.toml", ".config/cargo-ci.toml"): @@ -97,7 +98,8 @@ jobs: kept.append([dev, dev.pop("package", {}).get("*", {})]) print(hashlib.sha256(json.dumps(kept, sort_keys=True).encode()).hexdigest()[:12]) PY - )" >> "$GITHUB_OUTPUT" + ) + echo "deps-profile=$deps" >> "$GITHUB_OUTPUT" # The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each # main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo