Skip to content

Commit

Permalink
Kvg dep cache (#39)
Browse files Browse the repository at this point in the history
* Cache Rust dependencies
  • Loading branch information
kvg authored Oct 19, 2024
1 parent e9969da commit d07d43e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true

- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -90,11 +101,20 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.repository }}-${{ hashFiles('docker/**') }}
restore-keys: |
${{ runner.os }}-buildx-${{ github.repository }}-
${{ runner.os }}-buildx-
- name: Configure Docker to use gcloud credentials
run: gcloud auth configure-docker us.gcr.io -q

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./docker
push: true
Expand All @@ -108,4 +128,9 @@ jobs:
type=local,dest=/tmp/.buildx-cache-new,mode=max
type=gha,mode=max,scope=${{ github.workflow }}
build-contexts: |
binary=./target/release
binary=./target/release
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
16 changes: 12 additions & 4 deletions .github/workflows/ci_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -52,8 +54,9 @@ jobs:
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-buildx-${{ github.repository }}-${{ hashFiles('docker/**') }}
restore-keys: |
${{ runner.os }}-buildx-${{ github.repository }}-
${{ runner.os }}-buildx-
- name: Configure Docker to use gcloud credentials
Expand All @@ -69,9 +72,14 @@ jobs:
branch=v${{ github.ref_name }}
cache-from: |
type=local,src=/tmp/.buildx-cache
type=gha,scope=${{ github.workflow }}
type=gha,scope=${{ github.repository }}
cache-to: |
type=local,dest=/tmp/.buildx-cache-new,mode=max
type=gha,mode=max,scope=${{ github.workflow }}
type=gha,mode=max,scope=${{ github.repository }}
build-contexts: |
binary=./target/release
binary=./target/release
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 comments on commit d07d43e

Please sign in to comment.