Skip to content

Commit

Permalink
Enable cache for Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed May 24, 2024
1 parent 1f7f7ee commit e5cb826
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Download compiler-rt reference sources
run: |
curl -L -o code.tar.gz https://github.com/rust-lang/llvm-project/archive/rustc/18.0-2024-02-13.tar.gz
Expand All @@ -123,6 +124,10 @@ jobs:
NO_STD: ${{ matrix.no_std }}
TEST_VERBATIM: ${{ matrix.test_verbatim }}

# Configure buildx to use Docker layer caching
- uses: docker/setup-buildx-action@v3
if: matrix.os == 'ubuntu-latest'

# Otherwise we use our docker containers to run builds
- run: cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
if: matrix.os == 'ubuntu-latest'
Expand Down
13 changes: 12 additions & 1 deletion ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ run() {
export RUST_COMPILER_RT_ROOT=./compiler-rt
fi

docker build \
if [ "$GITHUB_ACTIONS" = "true" ]; then
# Enable Docker image caching on GHA

buildx="buildx"
build_args=(
"${build_args[@]:-}"
"--cache-to" "type=gha,scope=$target"
"--cache-from" "type=gha,scope=$target"
)
fi

docker "${buildx:-}" build \
-t "builtins-$target" \
${build_args[@]:-} \
"ci/docker/$target"
Expand Down

0 comments on commit e5cb826

Please sign in to comment.