Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ inputs:
cargo-cache-local-key:
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
required: false
clippy:
description: Install Clippy if `true`. Defaults to `false`.
required: false
rustfmt:
description: Install Rustfmt if `true`. Defaults to `false`.
toolchain:
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
required: false
solana:
description: Install Solana if `true`. Defaults to `false`.
Expand All @@ -38,29 +35,46 @@ runs:

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

- name: Install Rustfmt
if: ${{ inputs.rustfmt == 'true' }}
- name: Install Rust 'build' Toolchain
if: ${{ contains(inputs.toolchain, 'build') }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_BUILD }}

- name: Install Rust 'format' Toolchain
if: ${{ contains(inputs.toolchain, 'format') }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
components: rustfmt

- name: Install Clippy
if: ${{ inputs.clippy == 'true' }}
- name: Install Rust 'lint' Toolchain
if: ${{ contains(inputs.toolchain, 'lint') }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_LINT }}
components: clippy

- name: Install Rust 'test' Toolchain
if: ${{ contains(inputs.toolchain, 'test') }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_TEST }}

- name: Install Solana
if: ${{ inputs.solana == 'true' }}
uses: solana-program/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: true

- name: Install 'cargo-hack'
if: ${{ contains(inputs.toolchain, 'lint') }}
shell: bash
run: cargo install cargo-hack

- name: Cache Cargo Dependencies
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
uses: actions/cache@v4
Expand Down
195 changes: 99 additions & 96 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
format_and_lint_programs:
name: Format & Lint Programs
format_and_lint_client_rust:
name: Format & Lint Client Rust
runs-on: ubuntu-latest
steps:
- name: Git Checkout
Expand All @@ -17,33 +16,82 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup
with:
clippy: true
rustfmt: true
toolchain: format, lint

- name: Format Programs
run: pnpm programs:format
- name: Format
run: pnpm rust:format

- name: Lint Programs
run: pnpm programs:lint
- name: Lint / Clippy
run: pnpm rust:lint:clippy

format_and_lint_client_js:
name: Format & Lint Client JS
- name: Lint / Docs
run: pnpm rust:lint:docs

- name: Lint / Features
run: pnpm rust:lint:features

test_client_rust:
name: Test Client Rust
runs-on: ubuntu-latest
needs: format_and_lint_client_rust
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-rust-client
toolchain: test
solana: true

- name: Format Client JS
run: pnpm clients:js:format
- name: Test Client Rust
run: pnpm rust:test

- name: Lint Client JS
run: pnpm clients:js:lint
format_and_lint_interface:
name: Format & Lint Interface
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

format_and_lint_client_rust:
name: Format & Lint Client Rust
- name: Setup Environment
uses: ./.github/actions/setup
with:
toolchain: format, lint

- name: Format
run: pnpm interface:format

- name: Lint / Clippy
run: pnpm interface:lint:clippy

- name: Lint / Docs
run: pnpm interface:lint:docs

- name: Lint / Features
run: pnpm interface:lint:features

test_interface:
name: Test Interface
runs-on: ubuntu-latest
needs: format_and_lint_interface
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
toolchain: test
cargo-cache-key: cargo-interface
solana: true

- name: Test Interface
run: pnpm interface:test

format_and_lint_program:
name: Format & Lint Program
runs-on: ubuntu-latest
steps:
- name: Git Checkout
Expand All @@ -52,33 +100,38 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup
with:
clippy: true
rustfmt: true
toolchain: format, lint

- name: Format
run: pnpm program:format

- name: Lint / Clippy
run: pnpm program:lint:clippy

- name: Format Client Rust
run: pnpm clients:rust:format
- name: Lint / Docs
run: pnpm program:lint:docs

- name: Lint Client Rust
run: pnpm clients:rust:lint
- name: Lint / Features
run: pnpm program:lint:features

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

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
cargo-cache-key: cargo-program
solana: true

- name: Build Programs
run: pnpm programs:build
- name: Build Program
run: pnpm program:build

- name: Upload Program Builds
- name: Upload Program Build
uses: actions/upload-artifact@v4
with:
name: program-builds
Expand All @@ -89,75 +142,48 @@ jobs:
uses: actions/cache/save@v4
with:
path: ./**/*.so
key: ${{ runner.os }}-builds-${{ github.sha }}
key: ${{ runner.os }}-build-${{ github.sha }}

#test_programs:
# name: Test Programs
#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:
# cargo-cache-key: cargo-program-tests
# cargo-cache-fallback-key: cargo-programs
# solana: true
# toolchain: format
#
# - name: Test Programs
# run: pnpm programs:test

# Currently using a manual IDL.
#
#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
# cargo-cache-local-key: cargo-local
#
# - name: Generate IDLs
# run: pnpm generate:idls
# - name: Generate Clients
# run: pnpm generate:clients
#
# - name: Check Working Directory
# run: |
# git status --porcelain
# test -z "$(git status --porcelain)"

generate_clients:
name: Check Client Generation
format_and_lint_client_js:
name: Format & Lint Client JS
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:
rustfmt: true

- name: Generate Clients
run: pnpm generate:clients
- name: Format Client JS
run: pnpm js:format

- name: Check Working Directory
run: |
git status --porcelain
test -z "$(git status --porcelain)"
- name: Lint Client JS
run: pnpm js:lint

test_client_js:
name: Test Client JS
runs-on: ubuntu-latest
needs: build_programs
needs: [format_and_lint_client_js, build_program]
steps:
- name: Git Checkout
uses: actions/checkout@v4
Expand All @@ -167,34 +193,11 @@ jobs:
with:
solana: true

- name: Restore Program Builds
- name: Restore Program Build
uses: actions/cache/restore@v4
with:
path: ./**/*.so
key: ${{ runner.os }}-builds-${{ github.sha }}
key: ${{ runner.os }}-build-${{ github.sha }}

- name: Test Client JS
run: pnpm clients:js:test

#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-rust-client
# solana: true
#
# - name: Restore Program Builds
# uses: actions/cache/restore@v4
# with:
# path: ./**/*.so
# key: ${{ runner.os }}-builds-${{ github.sha }}
#
# - name: Test Client Rust
# run: pnpm clients:rust:test
run: pnpm js:test
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ solana = "2.1.0"
[workspace.metadata.toolchains]
format = "nightly-2024-08-08"
lint = "nightly-2024-08-08"
test = "nightly-2024-08-08"
1 change: 1 addition & 0 deletions clients/rust/src/generated/types/authorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
};

#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Authorized {
#[cfg_attr(
feature = "serde",
Expand Down
1 change: 1 addition & 0 deletions clients/rust/src/generated/types/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
};

#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Delegation {
#[cfg_attr(
feature = "serde",
Expand Down
1 change: 1 addition & 0 deletions clients/rust/src/generated/types/lockup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
};

#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Lockup {
pub unix_timestamp: i64,
pub epoch: u64,
Expand Down
1 change: 1 addition & 0 deletions clients/rust/src/generated/types/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
};

#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Meta {
pub rent_exempt_reserve: u64,
pub authorized: Authorized,
Expand Down
Loading
Loading