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
31 changes: 20 additions & 11 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,73 @@ inputs:
cargo-cache-local-key:
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
required: false
toolchain:
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
pnpm:
description: Install pnpm if `true`. Defaults to `false`.
required: false
solana:
description: Install Solana if `true`. Defaults to `false`.
required: false
toolchain:
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
required: false

runs:
using: 'composite'
steps:
- name: Set Environment Variables
shell: bash
run: |
source ./vars.env
echo "RUST_TOOLCHAIN_NIGHTLY=$RUST_TOOLCHAIN_NIGHTLY" >> "$GITHUB_ENV"
echo "SOLANA_CLI_VERSION=$SOLANA_CLI_VERSION" >> "$GITHUB_ENV"

- name: Setup pnpm
if: ${{ inputs.pnpm == 'true' }}
uses: pnpm/action-setup@v3

- name: Setup Node.js
if: ${{ inputs.pnpm == 'true' }}
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install Dependencies
if: ${{ inputs.pnpm == 'true' }}
run: pnpm install --frozen-lockfile
shell: bash

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

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

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

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

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

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

- name: Install 'cargo-hack'
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/setup
with:
pnpm: true

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

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

format_and_lint_client_rust:
name: Format & Lint Client Rust
Expand All @@ -35,16 +37,16 @@ jobs:
toolchain: format, lint

- name: Format
run: pnpm rust:format
run: make format-clients-rust

- name: Lint / Clippy
run: pnpm rust:lint:clippy
run: make clippy-clients-rust

- name: Lint / Docs
run: pnpm rust:lint:docs
run: make lint-docs-clients-rust

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

format_and_lint_interface:
name: Format & Lint Interface
Expand All @@ -59,21 +61,20 @@ jobs:
toolchain: format, lint

- name: Format
run: pnpm interface:format
run: make format-interface

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

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

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

wasm_interface:
name: Build Interface in WASM
runs-on: ubuntu-latest
needs: format_and_lint_interface
steps:
- name: Git Checkout
uses: actions/checkout@v4
Expand All @@ -90,12 +91,11 @@ jobs:
tool: wasm-pack

- name: Build Interface with wasm-pack
run: pnpm interface:wasm
run: make build-wasm-interface

test_interface:
name: Test Interface
runs-on: ubuntu-latest
needs: format_and_lint_interface
steps:
- name: Git Checkout
uses: actions/checkout@v4
Expand All @@ -108,7 +108,7 @@ jobs:
solana: true

- name: Test Interface
run: pnpm interface:test
run: make test-interface

generate_clients:
name: Check Client Generation
Expand All @@ -120,6 +120,7 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup
with:
pnpm: true
toolchain: format

- name: Generate Clients
Expand All @@ -133,23 +134,22 @@ jobs:
test_client_js:
name: Test Client JS
runs-on: ubuntu-latest
needs: [format_and_lint_client_js]
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
pnpm: true
solana: true

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

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
Expand All @@ -162,4 +162,4 @@ jobs:
solana: true

- name: Test Client Rust
run: pnpm rust:test
run: make test-clients-rust
8 changes: 4 additions & 4 deletions .github/workflows/publish-js-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ jobs:
solana: true

- name: Format
run: pnpm js:format
run: make format-js

- name: Lint
run: pnpm js:lint
run: make lint-js

- name: Test
run: pnpm js:test
run: make test-js

publish_js:
name: Publish JS client
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:

- name: Publish JS Client
id: publish
run: pnpm js:publish ${{ inputs.level }} ${{ inputs.tag }}
run: ./scripts/publish-js.sh clients/js ${{ inputs.level }} ${{ inputs.tag }}

- name: Push Commit and Tag
run: git push origin --follow-tags
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-rust-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
solana: true

- name: Format
run: pnpm rust:format
run: make format-clients-rust

- name: Lint
run: pnpm rust:lint
run: make clippy-clients-rust

- name: Test
run: pnpm rust:test
run: make test-clients-rust

publish_rust:
name: Publish Rust Client
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
OPTIONS=""
fi

pnpm rust:publish $LEVEL $OPTIONS
./scripts/publish-rust.sh clients/rust $LEVEL $OPTIONS

- name: Push Commit and Tag
if: github.event.inputs.dry_run != 'true'
Expand Down
8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,3 @@ solana-program = { version = "2.2.1", default-features = false }
solana-program-entrypoint = "2.2.1"
solana-program-error = "2.2.1"
solana-pubkey = { version = "2.2.1", default-features = false }

[workspace.metadata.cli]
solana = "2.2.0"

[workspace.metadata.toolchains]
format = "nightly-2024-11-22"
lint = "nightly-2024-11-22"
test = "nightly-2024-11-22"
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include vars.env

nightly = +$(subst ",,${RUST_TOOLCHAIN_NIGHTLY})

clippy-%:
cargo $(nightly) clippy --manifest-path $(subst -,/,$*)/Cargo.toml

format-%:
cargo $(nightly) fmt --check --manifest-path $(subst -,/,$*)/Cargo.toml

format-%-fix:
cargo $(nightly) fmt --manifest-path $(subst -,/,$*)/Cargo.toml

features-%:
cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(subst -,/,$*)/Cargo.toml

publish-%:
./scripts/publish-rust.sh $(subst -,/,$*)

build-wasm-interface:
wasm-pack build --target nodejs --dev ./interface --features bincode

lint-docs-%:
RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo $(nightly) doc --all-features --no-deps --manifest-path $(subst -,/,$*)/Cargo.toml

lint-features-%:
cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(subst -,/,$*)/Cargo.toml

test-%:
cargo $(nightly) test --manifest-path $(subst -,/,$*)/Cargo.toml

format-js:
cd ./clients/js && pnpm install && pnpm format

lint-js:
cd ./clients/js && pnpm install && pnpm lint

test-js:
./scripts/restart-test-validator.sh
cd ./clients/js && pnpm install && pnpm build && pnpm test
./scripts/stop-test-validator.sh
33 changes: 2 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
{
"private": true,
"scripts": {
"solana:check": "tsx ./scripts/helpers/check-solana-version.mts",
"solana:link": "tsx ./scripts/helpers/link-solana-version.mts",
Comment on lines -4 to -5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have missed it but I don't think these command have replacements. They seem to be just removed from the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, I felt like they weren't really necessary. If I'm wrong, we can add them back!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine not having it back. It was just a useful thing to ensure your local Solana version matches the project requirements but tbh this is probably best as a user-based utility instead.

"generate": "pnpm generate:clients",
"generate:clients": "codama run --all",
"validator:start": "tsx ./scripts/helpers/start-validator.mts",
"validator:restart": "pnpm validator:start --restart",
"validator:stop": "tsx ./scripts/helpers/stop-validator.mts",
"js:format": "tsx ./scripts/js.mts format clients/js",
"js:lint": "tsx ./scripts/js.mts lint clients/js",
"js:publish": "tsx ./scripts/js.mts publish clients/js",
"js:test": "tsx ./scripts/js.mts test clients/js",
"rust:format": "tsx ./scripts/rust.mts format clients/rust",
"rust:lint": "tsx ./scripts/rust.mts lint clients/rust",
"rust:lint:clippy": "tsx ./scripts/rust.mts lint-clippy clients/rust",
"rust:lint:docs": "tsx ./scripts/rust.mts lint-docs clients/rust",
"rust:lint:features": "tsx ./scripts/rust.mts lint-features clients/rust",
"rust:publish": "tsx ./scripts/rust.mts publish clients/rust",
"rust:test": "tsx ./scripts/rust.mts test clients/rust",
"interface:format": "tsx ./scripts/rust.mts format interface",
"interface:lint": "tsx ./scripts/rust.mts lint interface",
"interface:lint:clippy": "tsx ./scripts/rust.mts lint-clippy interface",
"interface:lint:docs": "tsx ./scripts/rust.mts lint-docs interface",
"interface:lint:features": "tsx ./scripts/rust.mts lint-features interface",
"interface:publish": "tsx ./scripts/rust.mts publish interface",
"interface:test": "tsx ./scripts/rust.mts test interface",
"interface:wasm": "tsx ./scripts/rust.mts wasm interface",
"template:upgrade": "tsx ./scripts/helpers/upgrade-template.ts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this command which doesn't seem to be replaced.

"generate:clients": "codama run --all"
},
"devDependencies": {
"@codama/renderers-js": "^1.2.7",
"@codama/renderers-rust": "^1.0.16",
"@iarna/toml": "^2.2.5",
"codama": "^1.2.8",
"tsx": "^4.19.2",
"typescript": "^5.5.2",
"zx": "^7.2.3"
"codama": "^1.2.8"
},
"engines": {
"node": ">=v20.0.0"
Expand Down
Loading