Skip to content

Commit

Permalink
Add gh-actions
Browse files Browse the repository at this point in the history
Switch amman to solana-local-validator

Testing setup

Switch back to amman

Anchor build

Add more logs

Add more logs

Switch back to anchor

Rename keypair

Anchor provider fix

Add logs back

Fix keypair name

Test reporter

Debug test reporter

Revert name change

Bump solana version
  • Loading branch information
jpbogle committed May 27, 2022
1 parent 36b964e commit b2605d9
Show file tree
Hide file tree
Showing 16 changed files with 2,658 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/actions/install-anchor/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Setup Anchor cli

inputs:
anchor_git:
description: Link to Anchor cli GH repository
required: true
anchor_version:
description: Version of Anchor cli
required: true

runs:
using: "composite"
steps:
- uses: actions/cache@v2
name: Cache Cargo registry + index
id: cache-anchor
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }}
- name: Install anchor
if: steps.cache-anchor.outputs.cache-hit != 'true'
run: cargo install --git ${{inputs.anchor_git}} --tag v${{inputs.anchor_version}} anchor-cli --locked --force
shell: bash
- uses: actions/upload-artifact@v2
with:
name: anchor-binary
path: ~/.cargo/bin/anchor
30 changes: 30 additions & 0 deletions .github/actions/install-linux-build-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Install Linux Build Deps
runs:
using: "composite"
steps:
- name: apt-get add llvm-snapshot key and update
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
sudo apt-get update
shell: bash

- name: apt-get install clang
run: |
sudo apt-get install -y clang-7 --allow-unauthenticated
clang-7 --version
shell: bash

- name: apt-get install ssl libs
run: |
sudo apt-get install -y openssl --allow-unauthenticated
sudo apt-get install -y libssl-dev --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated
shell: bash

- name: apt-get install dev tools
run: |
sudo apt-get install -y libudev-dev
sudo apt-get install -y binutils-dev
sudo apt-get install -y libunwind-dev
shell: bash
44 changes: 44 additions & 0 deletions .github/actions/install-solana/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Install Solana

inputs:
solana_version:
description: Version of Solana to install
required: true

runs:
using: "composite"
steps:
- name: Cache Solana Install
id: cache-solana-install
uses: actions/cache@v2
with:
path: "$HOME/.local/share/solana/install/releases/${{ inputs.solana_version }}"
key: ${{ runner.os }}-Solana-v${{ inputs.solana_version }}

- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ inputs.solana_version }}/install)"
shell: bash

- name: Set Active Solana Version
run: |
rm -f "$HOME/.local/share/solana/install/active_release"
ln -s "$HOME/.local/share/solana/install/releases/${{ inputs.solana_version }}/solana-release" "$HOME/.local/share/solana/install/active_release"
shell: bash

- name: Add Solana bin to Path
run: |
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
shell: bash

- name: Verify Solana install
run: |
solana --version
shell: bash

- name: Install toolchain
run: |
echo Installing bpf toolchain...
(cd /home/runner/.local/share/solana/install/active_release/bin/sdk/bpf/scripts; ./install.sh)
shell: bash
24 changes: 24 additions & 0 deletions .github/actions/install-soteria/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Install soteria

inputs:
soteria-version:
description: Version of Solana to install
required: true

runs:
using: "composite"
steps:
- name: Cache Soteria Install
id: cache-soteria-install
uses: actions/cache@v2
with:
path: "PATH=$PWD/soteria-linux-develop/bin/soteria"
key: ${{ runner.os }}-soteria-v${{ inputs.soteria-version }}
- name: Install soteria
if: steps.cache-soteria.outputs.cache-hit != 'true'
run: |
echo Installing Soteria...
sh -c "$(curl -k https://supercompiler.xyz/install)"
export PATH=$PWD/soteria-linux-develop/bin/:$PATH
echo "$PWD/soteria-linux-develop/bin" >> $GITHUB_PATH
shell: bash
137 changes: 137 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Test

on:
workflow_dispatch: {}
push:
branches: [main]
pull_request:
branches: [main]

permissions:
checks: write
contents: read
issues: read
pull-requests: write

env:
CARGO_TERM_COLOR: always
SOLANA_VERSION: 1.9.24
RUST_TOOLCHAIN: nightly
SOTERIA_VERSION: 0.0.0
ANCHOR_GIT: https://github.com/project-serum/anchor
ANCHOR_VERSION: 0.24.2

jobs:
rust-clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
override: true
components: rustfmt, clippy
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
args: --all-features

rust-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
override: true
components: rustfmt, clippy
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Run fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path ./Cargo.toml -- --check

soteria-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: ./.github/actions/install-solana
with:
solana_version: ${{ env.SOLANA_VERSION }}
- uses: ./.github/actions/install-soteria
with:
soteria_version: ${{ env.SOTERIA_VERSION }}
- name: Soteria scan programs
working-directory: ./programs
run: >-
for PROGRAM in ./*; do
if [ -d "$PROGRAM" ]; then
cd "$PROGRAM"
echo "Soteria scan for $PROGRAM"
soteria -analyzeAll .
cd ..
fi
done
shell: bash

integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-linux-build-deps
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: ./.github/actions/install-solana
with:
solana_version: ${{ env.SOLANA_VERSION }}
- uses: ./.github/actions/install-anchor
with:
anchor_git: ${{ env.ANCHOR_GIT }}
anchor_version: ${{ env.ANCHOR_VERSION }}

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./rust/target
key: ${{ env.cache_id }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTC_HASH }}

- name: Install Yarn dependencies
run: yarn install

- name: Generate client sdk
run: yarn run api:gen

- run: mkdir -p target/deploy
- run: cp -r tests/test-keypairs/* target/deploy
- run: find . -type f -name "*" -exec sed -i'' -e "s/hyDQ4Nz1eYyegS6JfenyKwKzYxRsCWCriYSAjtzP4Vg/$(solana-keygen pubkey tests/test-keypairs/hydra-keypair.json)/g" {} +

- run: yarn build
- run: anchor build

- run: solana-test-validator --url https://api.devnet.solana.com --clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --reset &
- run: sleep 6
- run: solana airdrop 1000 $(solana-keygen pubkey tests/test-key.json) --url http://localhost:8899
- run: anchor deploy --provider.cluster localnet
- run: yarn test:report

- uses: dorny/test-reporter@v1
if: always()
with:
name: integration-tests
path: ./tests/out.json
reporter: mocha-json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ test-ledger
!.yarn/sdks
!.yarn/versions
.idea/*
tests/out.json
Loading

0 comments on commit b2605d9

Please sign in to comment.