Define consistent and unique cache keys (#6182)

Take OS name, build tool, Swift version and dependencies into account.
This commit is contained in:
Danny Mösch
2025-08-08 20:00:59 +00:00
committed by GitHub
parent 1d46d6cca2
commit 8a1e56ea24
3 changed files with 16 additions and 7 deletions
+5 -2
View File
@@ -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
+5 -2
View File
@@ -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: |
+6 -3
View File
@@ -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