From d07d43ed7a4c637043162c7ab774b4f466d3a607 Mon Sep 17 00:00:00 2001 From: Kiran V Garimella Date: Sat, 19 Oct 2024 08:49:34 -0400 Subject: [PATCH] Kvg dep cache (#39) * Cache Rust dependencies --- .github/workflows/cd.yml | 29 +++++++++++++++++++++++++++-- .github/workflows/ci_push.yml | 16 ++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 847cdc66..68a9bb73 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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: @@ -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 @@ -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 \ No newline at end of file + binary=./target/release + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file diff --git a/.github/workflows/ci_push.yml b/.github/workflows/ci_push.yml index 9c83a1f5..deb1c72d 100644 --- a/.github/workflows/ci_push.yml +++ b/.github/workflows/ci_push.yml @@ -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 @@ -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 @@ -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 \ No newline at end of file + binary=./target/release + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file