From b4aa584b4505a95768ba1d16f4bce92223407f3f Mon Sep 17 00:00:00 2001 From: Maksym <3645723+makarychev@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:03:05 +0300 Subject: [PATCH] Add CI to build contract (#3) --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ Anchor.toml | 2 +- ci/build-and-test.sh | 13 +++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100755 ci/build-and-test.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..122a42d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +--- + name: Solana_Build + + on: [push] + + jobs: + Test: + runs-on: [ubuntu-22.04] + env: + RUST_VERSION: 1.77.0 + SOLANA_VERSION: 1.18.8 + ANCHOR_VERSION: 0.29.0 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + override: true + components: rustfmt, clippy + + - name: Install Solana + uses: metadaoproject/setup-solana@v1.0 + with: + solana-cli-version: ${{ env.SOLANA_VERSION }} + + - name: Generate Key + run: solana-keygen new --no-passphrase + + - name: Install Anchor + run: cargo install --git https://github.com/coral-xyz/anchor --tag v${{ env.ANCHOR_VERSION }} anchor-cli --locked + + - name: Build + run: anchor build + + - name: Install JS Dependencies + run: yarn install + + - name: JS Tests + run: anchor test \ No newline at end of file diff --git a/Anchor.toml b/Anchor.toml index 34f58d2..29e97ed 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -12,7 +12,7 @@ url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "/home/maksym/.config/solana/id.json" +wallet = "~/.config/solana/id.json" [scripts] test = "yarn run mocha -t 1000000 tests/*" diff --git a/ci/build-and-test.sh b/ci/build-and-test.sh new file mode 100755 index 0000000..6a1ca2e --- /dev/null +++ b/ci/build-and-test.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +cd "$(dirname "$0")/.." + +set -x +solana config set --url localhost + +solana-keygen new + +anchor test + +exit 0 \ No newline at end of file