Skip to content

Commit

Permalink
Setup Kinobi (2/2) (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec authored Jul 31, 2024
1 parent 9ff58c5 commit ba24ffb
Show file tree
Hide file tree
Showing 47 changed files with 5,395 additions and 66 deletions.
38 changes: 29 additions & 9 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ name: Setup environment

inputs:
cargo-cache-key:
description: The key to cache cargo dependencies.
description: The key to cache cargo dependencies. Skips if not provided.
required: false
protoc:
description: Whether or not to install protoc (workaround).
clippy:
description: Install Clippy (true/false). Skips if not provided.
required: false
node:
description: The Node.js version to install.
description: The Node.js version to install. Required.
required: true
protoc:
description: Whether or not to install protoc (workaround). Skips if not provided.
required: false
rustfmt:
description: Install Rustfmt (true/false). Skips if not provided.
required: false
solana:
description: The Solana version to install. Skips if not provided.
required: false
Expand All @@ -26,20 +32,34 @@ runs:
node-version: ${{ inputs.node }}
cache: "pnpm"

- name: Install dependencies
- name: Install Dependencies
run: pnpm install --frozen-lockfile
shell: bash

- name: Set env vars
- name: Set Environment Variables
shell: bash
run: pnpm zx ./scripts/ci/set-env.mjs

- name: (Temporary Workaround) Install protoc
- name: (Temporary Workaround) Install Protobuf Compiler
if: ${{ inputs.protoc == 'true' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install Rustfmt
if: ${{ inputs.rustfmt == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTFMT_NIGHTLY_VERSION }}
components: rustfmt

- name: Install Clippy
if: ${{ inputs.clippy == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CLIPPY_NIGHTLY_VERSION }}
components: clippy

- name: Install Solana
if: ${{ inputs.solana }}
Expand All @@ -48,7 +68,7 @@ runs:
version: ${{ inputs.solana }}
cache: true

- name: Cache cargo dependencies
- name: Cache Cargo Dependencies
if: ${{ inputs.cargo-cache-key }}
uses: actions/cache@v4
with:
Expand All @@ -61,7 +81,7 @@ runs:
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}

- name: Cache cargo dev dependencies
- name: Cache Cargo Dev-Dependencies
if: ${{ inputs.cargo-cache-key }}
uses: actions/cache@v4
with:
Expand Down
168 changes: 156 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,195 @@ env:
SOLANA_VERSION: 1.18.12

jobs:
format_and_lint_programs:
name: Format & Lint Programs
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
clippy: true
node: ${{ env.NODE_VERSION }}
rustfmt: true
protoc: true

- name: Format Programs
run: pnpm programs:format

- name: Lint Programs
run: pnpm programs:lint

format_and_lint_client_rust:
name: Format & Lint Client Rust
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
clippy: true
node: ${{ env.NODE_VERSION }}
rustfmt: true
protoc: true

- name: Format Client Rust
run: pnpm clients:rust:format

- name: Lint Client Rust
run: pnpm clients:rust:lint

format_and_lint_client_js:
name: Format & Lint Client JS
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
node: ${{ env.NODE_VERSION }}

- name: Format Client JS
run: pnpm clients:js:format

- name: Lint Client JS
run: pnpm clients:js:lint

build_programs:
name: Build programs
runs-on: ubuntu-latest
needs: format_and_lint_programs
steps:
- name: Git checkout
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup environment
- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
protoc: true
node: ${{ env.NODE_VERSION }}
solana: ${{ env.SOLANA_VERSION }}

- name: Build programs
run: pnpm programs:build --features bpf-entrypoint
- name: Build Programs
run: pnpm programs:build

- name: Upload program builds
- name: Upload Program Builds
uses: actions/upload-artifact@v4
with:
name: program-builds
path: ./target/deploy/*.so
if-no-files-found: error

- name: Save all builds for clients
- name: Cache Program Builds
uses: actions/cache/save@v4
with:
path: ./**/*.so
key: ${{ runner.os }}-builds-${{ github.sha }}

test_programs:
name: Test programs
name: Test Progams
runs-on: ubuntu-latest
needs: format_and_lint_programs
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
protoc: true
node: ${{ env.NODE_VERSION }}
solana: ${{ env.SOLANA_VERSION }}

- name: Test Programs
run: pnpm programs:test

generate_idls:
name: Check IDL Generation
runs-on: ubuntu-latest
needs: format_and_lint_programs
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
node: ${{ env.NODE_VERSION }}

- name: Generate IDLs
run: pnpm generate:idls

- name: Check Working Directory
run: |
git status --porcelain
test -z "$(git status --porcelain)"
generate_clients:
name: Check Client Generation
runs-on: ubuntu-latest
needs: format_and_lint_programs
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
node: ${{ env.NODE_VERSION }}
rustfmt: true

- name: Generate Clients
run: pnpm generate:clients

- name: Check Working Directory
run: |
git status --porcelain
test -z "$(git status --porcelain)"
test_client_rust:
name: Test Client Rust
runs-on: ubuntu-latest
needs: build_programs
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
protoc: true
node: ${{ env.NODE_VERSION }}
solana: ${{ env.SOLANA_VERSION }}

- name: Test Client Rust
run: pnpm clients:rust:test

test_client_js:
name: Test Client JS
runs-on: ubuntu-latest
needs: build_programs
steps:
- name: Git checkout
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup environment
- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
protoc: true
node: ${{ env.NODE_VERSION }}
solana: ${{ env.SOLANA_VERSION }}

- name: Test programs
run: pnpm programs:test --features bpf-entrypoint
- name: Test Client JS
run: pnpm clients:js:test
Loading

0 comments on commit ba24ffb

Please sign in to comment.