Skip to content

Commit 6b9c7fd

Browse files
brianmichelcompnerd
authored andcommitted
Setup sccache for SDK job
We do a small bit of C/C++ building in the SDK job which could benefit from also using sccache. This sets the cache up with the associated steps for fallback to disk cache and workspace hash computation.
1 parent d7f8a5f commit 6b9c7fd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,30 @@ jobs:
22782278
ref: ${{ inputs.swift_testing_revision }}
22792279
path: ${{ github.workspace }}/SourceCache/swift-testing
22802280
show-progress: false
2281+
- uses: actions/[email protected]
2282+
with:
2283+
path: ${{ github.workspace }}/SourceCache/swift-build
2284+
show-progress: false
2285+
2286+
- name: Compute workspace hash
2287+
id: workspace_hash
2288+
run: |
2289+
$stringAsStream = [System.IO.MemoryStream]::new()
2290+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
2291+
$writer.write("${{ github.workspace }}")
2292+
$writer.Flush()
2293+
$stringAsStream.Position = 0
2294+
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
2295+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
2296+
2297+
- name: Setup sccache
2298+
uses: ./SourceCache/swift-build/.github/actions/setup-sccache
2299+
with:
2300+
s3-bucket: ${{ vars.SCCACHE_S3_BUCKET }}
2301+
aws-region: ${{ vars.SCCACHE_AWS_REGION }}
2302+
aws-arn: ${{ vars.SCCACHE_AWS_ARN }}
2303+
disk-max-size: 500M
2304+
disk-cache-key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-sdk
22812305

22822306
- name: Setup environment
22832307
if: matrix.os != 'Android' || inputs.build_android
@@ -2412,9 +2436,11 @@ jobs:
24122436
-D BUILD_SHARED_LIBS=YES `
24132437
-D CMAKE_BUILD_TYPE=Release `
24142438
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
2439+
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
24152440
-D CMAKE_C_COMPILER_TARGET=${{ matrix.triple }} `
24162441
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
24172442
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
2443+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
24182444
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} `
24192445
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
24202446
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk/usr `
@@ -2554,9 +2580,11 @@ jobs:
25542580
-D CMAKE_BUILD_TYPE=Release `
25552581
-D CMAKE_BUILD_WITH_INSTALL_RPATH=YES `
25562582
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
2583+
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
25572584
-D CMAKE_C_COMPILER_TARGET=${{ matrix.triple }} `
25582585
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
25592586
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
2587+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
25602588
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} `
25612589
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
25622590
-D CMAKE_INSTALL_BINDIR=$XCTestBinDir `
@@ -2621,6 +2649,7 @@ jobs:
26212649
-D CMAKE_BUILD_TYPE=Release `
26222650
-D CMAKE_BUILD_WITH_INSTALL_RPATH=YES `
26232651
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
2652+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
26242653
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} `
26252654
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
26262655
-D CMAKE_INSTALL_BINDIR=$TestingBinDir `

0 commit comments

Comments
 (0)