From f5a1e9f3d37ad3d86c83802a7aae3a0bb75d4a12 Mon Sep 17 00:00:00 2001 From: jlaveracll Date: Thu, 9 Jan 2025 16:35:11 -0300 Subject: [PATCH] Add CI Action to build Solana contracts --- .../actions/setup-solana/build-contracts.yml | 52 +++++++++++++++++++ .github/workflows/ci-core.yml | 4 ++ 2 files changed, 56 insertions(+) create mode 100644 .github/actions/setup-solana/build-contracts.yml diff --git a/.github/actions/setup-solana/build-contracts.yml b/.github/actions/setup-solana/build-contracts.yml new file mode 100644 index 00000000000..b802935fc5b --- /dev/null +++ b/.github/actions/setup-solana/build-contracts.yml @@ -0,0 +1,52 @@ +name: Solana build contracts +description: Build Solana contracts + +defaults: + run: + working-directory: ./chains/solana + +runs: + using: composite + steps: + - name: Checkout chainlink-ccip + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + repository: chainlink/chainlink-ccip + path: chainlink-ccip + # token: ${{ steps.token.outputs.access-token }} + - name: Get Anchor Version + id: get_anchor_version + run: | + cd chainlink-ccip + anchor=$(make anchor_version) + echo "anchor=${anchor}" >>$GITHUB_OUTPUT + - name: cache docker build image + id: cache-image + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + lookup-only: true + path: chains/solana/contracts/docker-build.tar + key: ${{ runner.os }}-solana-build-${{ get_anchor_version.outputs.anchor_version }}-${{ hashFiles('**/Cargo.lock') }} + - name: Cache cargo target dir + id: cache-target + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + lookup-only: true + path: chains/solana/contracts/target + key: ${{ runner.os }}-solana-contract-artifacts-${{ hashFiles('**/Cargo.lock') }} + - name: build & save image + if: steps.cache-image.outputs.cache-hit != 'true' + run: | + cd contracts + docker buildx build . -t ccip-solana:build --build-arg ANCHOR_CLI=${{ get_anchor_version.outputs.anchor_version }} + docker save -o docker-build.tar ccip-solana + - name: build & save contract compilation artifacts + if: steps.cache-target.outputs.cache-hit != 'true' + run: | + docker run -v "$(pwd)/":/solana ccip-solana:build bash -c "\ + set -eoux pipefail &&\ + RUSTUP_HOME=\"/root/.rustup\" &&\ + FORCE_COLOR=1 &&\ + cd /solana/contracts &&\ + anchor build &&\ + chmod -R 755 ./target" \ No newline at end of file diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 5eafa0a6721..4773af68d78 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -227,6 +227,10 @@ jobs: if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }} uses: ./.github/actions/setup-solana + - name: Build Solana artifacts + if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }} + uses: ./.github/actions/setup-solana/build-contracts.yml + - name: Setup wasmd if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }} uses: ./.github/actions/setup-wasmd