@@ -4,6 +4,8 @@ on: [push, pull_request]
44env :
55 RUSTDOCFLAGS : -Dwarnings
66 RUSTFLAGS : -Dwarnings
7+ RUST_LLVM_VERSION : 18.0-2024-02-13
8+ RUST_COMPILER_RT_ROOT : ./compiler-rt
79
810jobs :
911 test :
@@ -105,11 +107,28 @@ jobs:
105107 shell : bash
106108 - run : rustup target add ${{ matrix.target }}
107109 - run : rustup component add llvm-tools-preview
110+ - uses : Swatinem/rust-cache@v2
111+ with :
112+ key : ${{ matrix.target }}
113+ - name : Cache Docker layers
114+ uses : actions/cache@v2
115+ if : matrix.os == 'ubuntu-latest'
116+ with :
117+ path : /tmp/.buildx-cache
118+ key : ${{ matrix.target }}-buildx-${{ github.sha }}
119+ restore-keys : ${{ matrix.target }}-buildx-
120+
121+ - name : Cache compiler-rt
122+ id : cache-compiler-rt
123+ uses : actions/cache@v4
124+ with :
125+ path : compiler-rt
126+ key : ${{ runner.os }}-compiler-rt-${{ env.RUST_LLVM_VERSION }}
108127 - name : Download compiler-rt reference sources
128+ if : steps.cache-compiler-rt.outputs.cache-hit != 'true'
109129 run : |
110- curl -L -o code.tar.gz https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz
111- tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-18.0-2024-02-13/compiler-rt
112- echo RUST_COMPILER_RT_ROOT=./compiler-rt >> $GITHUB_ENV
130+ curl -L -o code.tar.gz "https://github.com/rust-lang/llvm-project/archive/rustc/${RUST_LLVM_VERSION}.tar.gz"
131+ tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-${RUST_LLVM_VERSION}/compiler-rt
113132 shell : bash
114133
115134 # Non-linux tests just use our raw script
@@ -120,10 +139,23 @@ jobs:
120139 NO_STD : ${{ matrix.no_std }}
121140 TEST_VERBATIM : ${{ matrix.test_verbatim }}
122141
142+ # Configure buildx to use Docker layer caching
143+ - uses : docker/setup-buildx-action@v3
144+ if : matrix.os == 'ubuntu-latest'
145+
123146 # Otherwise we use our docker containers to run builds
124147 - run : cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
125148 if : matrix.os == 'ubuntu-latest'
126149
150+ # Workaround to keep Docker cache smaller
151+ # https://github.com/docker/build-push-action/issues/252
152+ # https://github.com/moby/buildkit/issues/1896
153+ - name : Move Docker cache
154+ if : matrix.os == 'ubuntu-latest'
155+ run : |
156+ rm -rf /tmp/.buildx-cache
157+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
158+
127159 rustfmt :
128160 name : Rustfmt
129161 runs-on : ubuntu-latest
@@ -147,6 +179,7 @@ jobs:
147179 - name : Install nightly `clippy`
148180 run : |
149181 rustup set profile minimal && rustup default "nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/clippy)" && rustup component add clippy
182+ - uses : Swatinem/rust-cache@v2
150183 - run : cargo clippy -- -D clippy::all
151184
152185 success :
0 commit comments