Skip to content

Instantly share code, notes, and snippets.

@BouweCeunen
Created January 19, 2022 08:40
Show Gist options
  • Save BouweCeunen/e74eb3863105950f6034b9aee15ba666 to your computer and use it in GitHub Desktop.
Save BouweCeunen/e74eb3863105950f6034b9aee15ba666 to your computer and use it in GitHub Desktop.
name: CI
on:
push:
branches:
- localnet
- devnet
- mainnet
pull_request:
env:
SOLANA_VERSION: "1.8.10"
ANCHOR_VERSION: "0.20.1"
RUST_TOOLCHAIN: nightly-2021-12-23
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Install Rust
- name: Cache Cargo registry + index
uses: actions/cache@v2
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-v0000-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
# Run build
- name: Cache build
uses: Swatinem/rust-cache@v1
- name: Build program
run: cargo build
- name: Run clippy
run: cargo clippy -- -D warnings -A clippy::too_many_arguments
ci:
runs-on: ubuntu-latest
needs: [validate]
environment:
name: localnet
steps:
- uses: actions/checkout@v2
# Install Rust
- name: Cache Cargo registry + index
uses: actions/cache@v2
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-v0000-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
# Install Solana
- name: Cache Solana binaries
id: solana-cache
uses: actions/cache@v2
with:
path: |
~/.cache/solana
~/.local/share/solana/install
key: ${{ runner.os }}-${{ env.SOLANA_VERSION }}
- name: Install Solana
if: steps.solana-cache.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.8.10/install)"
- name: Setup Solana Path
run: |
mkdir ~/.config/solana/
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
solana config get
# Copy secrets
- name: Copy secrets
run: |
echo ${{ secrets.ID }} > ~/.config/solana/id.json
echo ${{ secrets.GATEKEEPER_NETWORK }} > ~/.config/solana/local-random-gatekeeper-network.json
echo ${{ secrets.MANAGER_KEY }} > ~/.config/solana/local-random-manager-key.json
# Install Yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Yarn Cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-
# Install Anchor
- name: Install Anchor
run: yarn global add @project-serum/anchor-cli@${{ env.ANCHOR_VERSION }}
# Install Node
- name: Setup Node
uses: actions/setup-node@v2
# Run tests
- name: Cache build
uses: Swatinem/rust-cache@v1
- name: Installing test dependencies
run: cd tests/ && yarn install
- name: Run e2e tests
run: sh ./tests/test.sh
cd-devnet:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/devnet'
needs: [ci]
environment:
name: devnet
steps:
- uses: actions/checkout@v2
# Install Rust
- name: Cache Cargo registry + index
uses: actions/cache@v2
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-${{ runner.os }}-v0000-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
# Install Solana
- name: Cache Solana binaries
id: solana-cache
uses: actions/cache@v2
with:
path: |
~/.cache/solana
~/.local/share/solana/install
key: ${{ runner.os }}-${{ env.SOLANA_VERSION }}
- name: Install Solana
if: steps.solana-cache.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.8.10/install)"
- name: Setup Solana 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"
solana --version
solana config get
# Copy secrets
- name: Copy secrets
run: |
echo ${{ secrets.ID }} > ~/.config/solana/id.json
# Install Yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Yarn Cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-
# Install Anchor
- name: Install Anchor
run: yarn global add @project-serum/anchor-cli@${{ env.ANCHOR_VERSION }}
# Deploy
- name: Cache build
uses: Swatinem/rust-cache@v1
- name: Deploy program
run: sh ./deploy/deploy.sh devnet
@ayazzz
Copy link

ayazzz commented Jun 25, 2022

Hi Bouwe,

Thank you for this awesome example. It was very helpful for me to set the pipeline for my project.

However I am very new to Solana and all blockchain technology and so I have a question about 2 secrets.
I did some research and couldn't find anything I could make connections.

GATEKEEPER_NETWORK and MANAGER_KEY

if you could show me the correct direction about those two, I will be more than happy. Unless they are something specific to the project.

@BouweCeunen
Copy link
Author

Hi! These environment variables are specific to the project, so you shouldn't necessarily need them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment