From 8a1e56ea2412566fda4e94fa24db8d56bd9204af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Fri, 8 Aug 2025 22:00:59 +0200 Subject: [PATCH] Define consistent and unique cache keys (#6182) Take OS name, build tool, Swift version and dependencies into account. --- .github/workflows/copilot-setup-steps.yml | 7 +++++-- .github/workflows/docs.yml | 7 +++++-- .github/workflows/test.yml | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 279f0d195..d72f2483f 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -16,10 +16,13 @@ jobs: contents: read steps: - uses: actions/checkout@v4 + - name: Get Swift version + id: swift_version + run: echo "version=$(swift --version | grep '[5-9]\.[0-9]\+\.[0-9]' -o | head -1)" >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: - key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }} - restore-keys: ${{ runner.os }}-swift-spm- + key: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}-${{ hashFiles('Package.resolved', 'Package.swift') }} + restore-keys: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}- path: .build - name: Build everything run: swift build --build-tests diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cb12d47d0..3a807641c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,10 +22,13 @@ jobs: target: "//:swiftlint @com_github_jpsim_sourcekitten//:sourcekitten" env: CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }} + - name: Get Swift version + id: swift_version + run: echo "version=$(swift --version | grep '[5-9]\.[0-9]\+\.[0-9]' -o | head -1)" >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: - key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }} - restore-keys: ${{ runner.os }}-swift-spm- + key: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}-${{ hashFiles('Package.resolved', 'Package.swift') }} + restore-keys: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}- path: .build - name: Generate documentation run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb26266e8..68b79f79b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,10 +18,13 @@ jobs: container: swift:6.1-noble steps: - uses: actions/checkout@v4 + - name: Get Swift version + id: swift_version + run: echo "version=$(swift --version | grep '[5-9]\.[0-9]\+\.[0-9]' -o | head -1)" >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: - key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }} - restore-keys: ${{ runner.os }}-swift-spm- + key: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}-${{ hashFiles('Package.resolved', 'Package.swift') }} + restore-keys: ${{ runner.os }}-spm-${{ steps.swift_version.outputs.version }}- path: .build - name: Run tests uses: ./.github/actions/run-make @@ -44,7 +47,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - key: ${{ runner.os }}-xcode-spm-${{ matrix.xcode }}-${{ hashFiles('Package.resolved') }} + key: ${{ runner.os }}-xcode-spm-${{ matrix.xcode }}-${{ hashFiles('Package.resolved', 'Package.swift') }} restore-keys: ${{ runner.os }}-xcode-spm-${{ matrix.xcode }}- path: .build - name: Run tests