From 6d1dbd47ac59fdfa5cdece8b639a781e754e1a56 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:05:47 +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 | 21 +++++++++++++++++++-- scripts/test-workspace-tests.py | 8 ++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index c426254585..b8d2afa3df 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -42,6 +42,7 @@ jobs: tests: ${{ steps.select.outputs.tests }} filter: ${{ steps.select.outputs.filter }} profile: ${{ steps.profile.outputs.profile }} + deps-profile: ${{ steps.profile.outputs.deps-profile }} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 @@ -70,8 +71,23 @@ jobs: persist-credentials: false sparse-checkout: .config/cargo-*.toml sparse-checkout-cone-mode: false + # 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. - id: profile - run: echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" + run: | + 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 @@ -153,7 +169,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 3aced9c5ca..6485e2a98a 100644 --- a/scripts/test-workspace-tests.py +++ b/scripts/test-workspace-tests.py @@ -305,9 +305,13 @@ class WorkspaceTests(unittest.TestCase): self.assertIn(" lint-command: *lint\n", source) self.assertIn(" command: *command\n", source) self.assertNotIn("windows-command", 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.profile.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 68ab35c9bb121525d0713d97676daaf28a1cb9c6 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:10:40 +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 b8d2afa3df..99e5c571d5 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -78,7 +78,8 @@ jobs: - id: profile run: | 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"): @@ -87,7 +88,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