1
0
Fork 0

Improve build caching

docker
Bo Jeanes 2022-09-12 08:26:55 +10:00
parent 7355ffa75c
commit c4fb085931
2 changed files with 34 additions and 45 deletions

View File

@ -1,2 +1,4 @@
.git
Dockerfile Dockerfile
**/README.md README.md
/target/

View File

@ -28,28 +28,17 @@ jobs:
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
sudo apt-get clean && sudo apt-get update sudo apt-get clean && sudo apt-get update
sudo apt-get install -y pkg-config libudev-dev sudo apt-get install -y pkg-config libudev-dev
- name: Cache cargo registry - name: Cargo cache
uses: actions/cache@v1 uses: actions/cache@v2
with: with:
path: ~/.cargo/registry path: |
key: ${{ runner.os }}-cargo-registry-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} ~/.cargo/git
~/.cargo/registry
./target
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-cargo-registry- ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-
- name: Cache cargo index ${{ runner.os }}-cargo
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-
${{ runner.os }}-cargo-build-target-
- name: Run tests - name: Run tests
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@ -73,30 +62,17 @@ jobs:
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
sudo apt-get clean && sudo apt-get update sudo apt-get clean && sudo apt-get update
sudo apt-get install -y pkg-config libudev-dev sudo apt-get install -y pkg-config libudev-dev
- name: Cache cargo registry - name: Cargo cache
uses: actions/cache@v1 uses: actions/cache@v2
with: with:
path: ~/.cargo/registry path: |
key: ${{ runner.os }}-cargo-registry-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} ~/.cargo/git
~/.cargo/registry
./target
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-cargo-registry-${{ steps.rust-toolchain.outputs.rustc_hash }}- ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-
${{ runner.os }}-cargo-registry- ${{ runner.os }}-cargo
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-${{ steps.rust-toolchain.outputs.rustc_hash }}-
${{ runner.os }}-cargo-index-
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-
${{ runner.os }}-cargo-build-target-
- name: Check rustfmt - name: Check rustfmt
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@ -150,9 +126,16 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: | path: |
~/.cargo/git
~/.cargo/registry ~/.cargo/registry
./target ./target
key: build-cargo-registry-${{matrix.TARGET}} key: ${{ runner.os }}-cargo-${{matrix.TARGET}}-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{matrix.TARGET}}-${{ steps.rust-toolchain.outputs.rustc_hash }}
${{ runner.os }}-cargo-${{matrix.TARGET}}-
${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc_hash }}-
${{ runner.os }}-cargo
- name: Setup cross linux toolchain - name: Setup cross linux toolchain
if: contains(matrix.TARGET, '-linux-') && !startsWith(matrix.TARGET, 'x86_64-') if: contains(matrix.TARGET, '-linux-') && !startsWith(matrix.TARGET, 'x86_64-')
run: | run: |
@ -387,6 +370,8 @@ jobs:
file: Dockerfile.alpine file: Dockerfile.alpine
tags: ${{ steps.meta-alpine.outputs.tags }} tags: ${{ steps.meta-alpine.outputs.tags }}
labels: ${{ steps.meta-alpine.outputs.labels }} labels: ${{ steps.meta-alpine.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push - name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
@ -397,4 +382,6 @@ jobs:
linux/amd64 linux/amd64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max