Skip to content

Commit

Permalink
cache build image
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed Oct 1, 2024
1 parent 5049f05 commit 33468dc
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,32 @@ jobs:
build_image_test:
name: build image test
runs-on: ubuntu-latest
needs: [get_projectserum_version]
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Cache cargo registry
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
- name: cache cargo target dir
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target dir
path: contracts/target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}'
- name: cache docker build image
id: cache-image
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: contracts/target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
# - name: build cargo cache into docker container
# run: |
# cd ..
# docker buildx build ./contracts --platform=linux/amd64 -t solana-build:local
path: contracts/docker-build.tar
key: ${{ runner.os }}-docker-build-${{ needs.get_projectserum_version.outputs.projectserum_version }}-${{ hashFiles('**/Cargo.lock') }}'
- name: build & save image
if: steps.cache-image.outputs.cache-hit != 'true'
run: |
docker buildx build . --platform=linux/amd64 -t chainlink-solana:build
docker save chainlink-solana > docker-build.tar
- name: load cached image
if: steps.cache-image.outputs.cache-hit == 'true'
run: |
docker load docker-build.tar
- name: build from cached artifacts
run: |
cd ..
docker run -v ~/.cargo/registry:/root/.cargo/registry -v ~/.cargo/git:/root/.cargo/git -v "$(pwd)/":/workdir backpackapp/build:v0.29.0 bash -c "cd /workdir/contracts && anchor build && chmod -R 755 ./target && chmod -R 755 /root/.cargo/registry && chmod -R 755 /root/.cargo/git"
docker run -v "$(pwd)/../":/workdir chainlink-solana:build bash -c "cd /workdir/contracts && anchor build && chmod -R 755 ./target"
rust_run_anchor_tests:
name: Rust Run Anchor Tests
Expand Down

0 comments on commit 33468dc

Please sign in to comment.