Skip to content

Commit

Permalink
Merge pull request #35 from invariant-labs/ci-test-protocol
Browse files Browse the repository at this point in the history
Add testing protocol to CI
  • Loading branch information
none00y authored Aug 21, 2024
2 parents e804457 + 9fbb14b commit ced235e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 118 deletions.
211 changes: 93 additions & 118 deletions .github/workflows/test-protocol.yml
Original file line number Diff line number Diff line change
@@ -1,121 +1,96 @@
# name: test protocol
name: build & e2e tests

# permissions:
# contents: read
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
solana_version: '1.18.12'
anchor_version: '0.29.0'
protocol_path: 'protocol'

# on:
# push:
# branches:
# - master
# pull_request:
# branches:
# - master
# env:
# solana_version: 1.18.18
# anchor_version: 0.29.0
jobs:
install:
runs-on: ubuntu-latest

# jobs:
# install:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: ./protocol
# strategy:
# matrix:
# case:
# [
# 'npm run test:init',
# 'npm run test:token',
# 'npm run test:invoke',
# 'npm run test:init-lp-pool',
# 'npm run test:math'
# ]
# steps:
# - uses: actions/checkout@v4
# - name: test
# run: |
# echo "${{ matrix.case }}"
# - uses: actions/cache@v3
# 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 }}-v0000-${{ hashFiles('**/Cargo.lock') }}
# - uses: actions/cache@v3
# name: Cache Solana Tool Suite
# id: cache-solana
# with:
# path: |
# ~/.cache/solana/
# ~/.local/share/solana/
# key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
# - uses: actions/cache@v3
# name: Cache target folder
# id: cache-programs
# with:
# path: |
# ./target
# key: solana-${{ runner.os }}-v0000-${{ hashFiles('**/programs/**/*.rs') }}-${{ hashFiles('**/programs/**/*.toml') }}
# - uses: actions/cache@v3
# name: Cache Node Modules
# id: cache-node-modules
# with:
# path: |
# ~/.npm/
# ./node_modules
# key: npm-${{ runner.os }}-v0000-${{ hashFiles('**/package-lock.json') }}
# - uses: actions/setup-node@v4
# with:
# node-version: '20'
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: nightly-2024-02-04
# override: true
# - name: install global mocha
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# npm install -g mocha
# npm install -g ts-mocha
# npm install -g typescript
# npm install -g @project-serum/anchor
# ts-mocha -h
# - name: install essential
# run: |
# sudo apt-get update
# sudo apt-get install -y pkg-config build-essential libudev-dev
# - name: install solana
# if: steps.cache-solana.outputs.cache-hit != 'true'
# run: |
# sh -c "$(curl -sSfL https://release.solana.com/v${{ env.solana_version }}/install)"
# echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# solana --version
# - name: setup solana
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# solana --version
# solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
# - name: install Anchor
# if: steps.cache-anchor.outputs.cache-hit != 'true'
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# cargo install --git https://github.com/project-serum/anchor --tag v${{ env.anchor_version }} anchor-cli --locked
# - name: build programs
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# anchor build
# - name: install
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# npm install
# - name: build invariant sdk & staker sdk
# run: |
# npm run build:all
# - name: test
# run: |
# export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
# ${{ matrix.case }}
steps:
- uses: actions/checkout@v3
- 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 }}-v0000-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
name: Cache Solana Tool Suite
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}
- uses: actions/cache@v2
name: Cache target folder
id: cache-programs
with:
path: |
./target
key: solana-${{ runner.os }}-v0000-${{ hashFiles('**/programs/**/*.rs') }}-${{ hashFiles('**/programs/**/*.toml') }}
- uses: actions/cache@v2
name: Cache Node Modules
id: cache-node-modules
with:
path: |
~/.npm/
./node_modules
key: npm-${{ runner.os }}-v0000-${{ hashFiles('**/package-lock.json') }}
- uses: actions/setup-node@v2
with:
node-version: '18'
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-02-04
override: true
- name: install global mocha
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm install -g mocha
npm install -g ts-mocha
npm install -g typescript
npm install -g @project-serum/anchor
ts-mocha -h
- name: install essential
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
- name: install solana
if: steps.cache-solana.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.solana_version }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
- name: setup solana
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
- name: install Anchor
if: steps.cache-anchor.outputs.cache-hit != 'true'
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
cargo install --git https://github.com/project-serum/anchor --tag v${{ env.anchor_version }} anchor-cli --locked
- name: build programs
working-directory: ${{ env.protocol_path }}
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm i
chmod +x tests.sh
./tests.sh
1 change: 1 addition & 0 deletions protocol/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ puppet='[51,155,154,107,110,131,244,50,197,81,99,152,71,175,210,224,80,66,26,119
invarinat='[100,94,104,217,253,66,112,71,155,206,9,70,30,6,93,185,82,49,169,250,96,24,120,234,25,145,148,106,134,60,55,123,176,93,3,185,31,73,255,255,107,72,82,123,112,9,31,16,214,15,171,107,164,37,143,208,35,195,133,157,224,137,246,197]'

# Write the keypair JSON to file
mkdir -p target/deploy
echo "$protocol" > target/deploy/protocol-keypair.json
echo "$puppet" > target/deploy/puppet-keypair.json
echo "$invarinat" > target/deploy/invariant-keypair.json
Expand Down

0 comments on commit ced235e

Please sign in to comment.