Skip to content

Commit 960949f

Browse files
Overhaul CI with Makefile (#51)
* scripts: replace simple jobs with cargo-make * scripts: replace js test job with cargo-make * scripts: bashify publish scripts * scripts: drop everything unused * move all aliases to `Makefile.toml` * ci: make pnpm install optional * Use a Makefile * Spell pnpm correctly, parallelize more * Remove dev.env file * Revert "Remove dev.env file" This reverts commit 6340769. * Use / rename vars file * shebang * cli version name * cargo release dry run * restart-test-validator.sh --------- Co-authored-by: Jon C <[email protected]>
1 parent 36c68bc commit 960949f

22 files changed

+214
-1507
lines changed

.github/actions/setup/action.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,73 @@ inputs:
1010
cargo-cache-local-key:
1111
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
1212
required: false
13-
toolchain:
14-
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
13+
pnpm:
14+
description: Install pnpm if `true`. Defaults to `false`.
1515
required: false
1616
solana:
1717
description: Install Solana if `true`. Defaults to `false`.
1818
required: false
19+
toolchain:
20+
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
21+
required: false
1922

2023
runs:
2124
using: 'composite'
2225
steps:
26+
- name: Set Environment Variables
27+
shell: bash
28+
run: |
29+
source ./vars.env
30+
echo "RUST_TOOLCHAIN_NIGHTLY=$RUST_TOOLCHAIN_NIGHTLY" >> "$GITHUB_ENV"
31+
echo "SOLANA_CLI_VERSION=$SOLANA_CLI_VERSION" >> "$GITHUB_ENV"
32+
2333
- name: Setup pnpm
34+
if: ${{ inputs.pnpm == 'true' }}
2435
uses: pnpm/action-setup@v3
2536

2637
- name: Setup Node.js
38+
if: ${{ inputs.pnpm == 'true' }}
2739
uses: actions/setup-node@v4
2840
with:
2941
node-version: 20
3042
cache: 'pnpm'
3143

3244
- name: Install Dependencies
45+
if: ${{ inputs.pnpm == 'true' }}
3346
run: pnpm install --frozen-lockfile
3447
shell: bash
3548

36-
- name: Set Environment Variables
37-
shell: bash
38-
run: pnpm tsx ./scripts/ci/set-env.mts
39-
4049
- name: Install Rust 'build' Toolchain
4150
if: ${{ contains(inputs.toolchain, 'build') }}
4251
uses: dtolnay/rust-toolchain@master
4352
with:
44-
toolchain: ${{ env.TOOLCHAIN_BUILD }}
53+
toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
4554

4655
- name: Install Rust 'format' Toolchain
4756
if: ${{ contains(inputs.toolchain, 'format') }}
4857
uses: dtolnay/rust-toolchain@master
4958
with:
50-
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
59+
toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
5160
components: rustfmt
5261

5362
- name: Install Rust 'lint' Toolchain
5463
if: ${{ contains(inputs.toolchain, 'lint') }}
5564
uses: dtolnay/rust-toolchain@master
5665
with:
57-
toolchain: ${{ env.TOOLCHAIN_LINT }}
66+
toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
5867
components: clippy
5968

6069
- name: Install Rust 'test' Toolchain
6170
if: ${{ contains(inputs.toolchain, 'test') }}
6271
uses: dtolnay/rust-toolchain@master
6372
with:
64-
toolchain: ${{ env.TOOLCHAIN_TEST }}
73+
toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
6574

6675
- name: Install Solana
6776
if: ${{ inputs.solana == 'true' }}
6877
uses: solana-program/actions/install-solana@v1
6978
with:
70-
version: ${{ env.SOLANA_VERSION }}
79+
version: ${{ env.SOLANA_CLI_VERSION }}
7180
cache: true
7281

7382
- name: Install 'cargo-hack'

.github/workflows/main.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ jobs:
1515

1616
- name: Setup Environment
1717
uses: ./.github/actions/setup
18+
with:
19+
pnpm: true
1820

1921
- name: Format Client JS
20-
run: pnpm js:format
22+
run: make format-js
2123

2224
- name: Lint Client JS
23-
run: pnpm js:lint
25+
run: make lint-js
2426

2527
format_and_lint_client_rust:
2628
name: Format & Lint Client Rust
@@ -35,16 +37,16 @@ jobs:
3537
toolchain: format, lint
3638

3739
- name: Format
38-
run: pnpm rust:format
40+
run: make format-clients-rust
3941

4042
- name: Lint / Clippy
41-
run: pnpm rust:lint:clippy
43+
run: make clippy-clients-rust
4244

4345
- name: Lint / Docs
44-
run: pnpm rust:lint:docs
46+
run: make lint-docs-clients-rust
4547

4648
- name: Lint / Features
47-
run: pnpm rust:lint:features
49+
run: make lint-features-clients-rust
4850

4951
format_and_lint_interface:
5052
name: Format & Lint Interface
@@ -59,21 +61,20 @@ jobs:
5961
toolchain: format, lint
6062

6163
- name: Format
62-
run: pnpm interface:format
64+
run: make format-interface
6365

6466
- name: Lint / Clippy
65-
run: pnpm interface:lint:clippy
67+
run: make clippy-interface
6668

6769
- name: Lint / Docs
68-
run: pnpm interface:lint:docs
70+
run: make lint-docs-interface
6971

7072
- name: Lint / Features
71-
run: pnpm interface:lint:features
73+
run: make lint-features-interface
7274

7375
wasm_interface:
7476
name: Build Interface in WASM
7577
runs-on: ubuntu-latest
76-
needs: format_and_lint_interface
7778
steps:
7879
- name: Git Checkout
7980
uses: actions/checkout@v4
@@ -90,12 +91,11 @@ jobs:
9091
tool: wasm-pack
9192

9293
- name: Build Interface with wasm-pack
93-
run: pnpm interface:wasm
94+
run: make build-wasm-interface
9495

9596
test_interface:
9697
name: Test Interface
9798
runs-on: ubuntu-latest
98-
needs: format_and_lint_interface
9999
steps:
100100
- name: Git Checkout
101101
uses: actions/checkout@v4
@@ -108,7 +108,7 @@ jobs:
108108
solana: true
109109

110110
- name: Test Interface
111-
run: pnpm interface:test
111+
run: make test-interface
112112

113113
generate_clients:
114114
name: Check Client Generation
@@ -120,6 +120,7 @@ jobs:
120120
- name: Setup Environment
121121
uses: ./.github/actions/setup
122122
with:
123+
pnpm: true
123124
toolchain: format
124125

125126
- name: Generate Clients
@@ -133,23 +134,22 @@ jobs:
133134
test_client_js:
134135
name: Test Client JS
135136
runs-on: ubuntu-latest
136-
needs: [format_and_lint_client_js]
137137
steps:
138138
- name: Git Checkout
139139
uses: actions/checkout@v4
140140

141141
- name: Setup Environment
142142
uses: ./.github/actions/setup
143143
with:
144+
pnpm: true
144145
solana: true
145146

146147
- name: Test Client JS
147-
run: pnpm js:test
148+
run: make test-js
148149

149150
test_client_rust:
150151
name: Test Client Rust
151152
runs-on: ubuntu-latest
152-
needs: [format_and_lint_client_rust]
153153
steps:
154154
- name: Git Checkout
155155
uses: actions/checkout@v4
@@ -162,4 +162,4 @@ jobs:
162162
solana: true
163163

164164
- name: Test Client Rust
165-
run: pnpm rust:test
165+
run: make test-clients-rust

.github/workflows/publish-js-client.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ jobs:
4141
solana: true
4242

4343
- name: Format
44-
run: pnpm js:format
44+
run: make format-js
4545

4646
- name: Lint
47-
run: pnpm js:lint
47+
run: make lint-js
4848

4949
- name: Test
50-
run: pnpm js:test
50+
run: make test-js
5151

5252
publish_js:
5353
name: Publish JS client
@@ -83,7 +83,7 @@ jobs:
8383
8484
- name: Publish JS Client
8585
id: publish
86-
run: pnpm js:publish ${{ inputs.level }} ${{ inputs.tag }}
86+
run: ./scripts/publish-js.sh clients/js ${{ inputs.level }} ${{ inputs.tag }}
8787

8888
- name: Push Commit and Tag
8989
run: git push origin --follow-tags

.github/workflows/publish-rust-client.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
solana: true
5050

5151
- name: Format
52-
run: pnpm rust:format
52+
run: make format-clients-rust
5353

5454
- name: Lint
55-
run: pnpm rust:lint
55+
run: make clippy-clients-rust
5656

5757
- name: Test
58-
run: pnpm rust:test
58+
run: make test-clients-rust
5959

6060
publish_rust:
6161
name: Publish Rust Client
@@ -109,7 +109,7 @@ jobs:
109109
OPTIONS=""
110110
fi
111111
112-
pnpm rust:publish $LEVEL $OPTIONS
112+
./scripts/publish-rust.sh clients/rust $LEVEL $OPTIONS
113113
114114
- name: Push Commit and Tag
115115
if: github.event.inputs.dry_run != 'true'

Cargo.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ solana-program = { version = "2.2.1", default-features = false }
2727
solana-program-entrypoint = "2.2.1"
2828
solana-program-error = "2.2.1"
2929
solana-pubkey = { version = "2.2.1", default-features = false }
30-
31-
[workspace.metadata.cli]
32-
solana = "2.2.0"
33-
34-
[workspace.metadata.toolchains]
35-
format = "nightly-2024-11-22"
36-
lint = "nightly-2024-11-22"
37-
test = "nightly-2024-11-22"

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include vars.env
2+
3+
nightly = +$(subst ",,${RUST_TOOLCHAIN_NIGHTLY})
4+
5+
clippy-%:
6+
cargo $(nightly) clippy --manifest-path $(subst -,/,$*)/Cargo.toml
7+
8+
format-%:
9+
cargo $(nightly) fmt --check --manifest-path $(subst -,/,$*)/Cargo.toml
10+
11+
format-%-fix:
12+
cargo $(nightly) fmt --manifest-path $(subst -,/,$*)/Cargo.toml
13+
14+
features-%:
15+
cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(subst -,/,$*)/Cargo.toml
16+
17+
publish-%:
18+
./scripts/publish-rust.sh $(subst -,/,$*)
19+
20+
build-wasm-interface:
21+
wasm-pack build --target nodejs --dev ./interface --features bincode
22+
23+
lint-docs-%:
24+
RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo $(nightly) doc --all-features --no-deps --manifest-path $(subst -,/,$*)/Cargo.toml
25+
26+
lint-features-%:
27+
cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(subst -,/,$*)/Cargo.toml
28+
29+
test-%:
30+
cargo $(nightly) test --manifest-path $(subst -,/,$*)/Cargo.toml
31+
32+
format-js:
33+
cd ./clients/js && pnpm install && pnpm format
34+
35+
lint-js:
36+
cd ./clients/js && pnpm install && pnpm lint
37+
38+
test-js:
39+
./scripts/restart-test-validator.sh
40+
cd ./clients/js && pnpm install && pnpm build && pnpm test
41+
./scripts/stop-test-validator.sh

package.json

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,13 @@
11
{
22
"private": true,
33
"scripts": {
4-
"solana:check": "tsx ./scripts/helpers/check-solana-version.mts",
5-
"solana:link": "tsx ./scripts/helpers/link-solana-version.mts",
64
"generate": "pnpm generate:clients",
7-
"generate:clients": "codama run --all",
8-
"validator:start": "tsx ./scripts/helpers/start-validator.mts",
9-
"validator:restart": "pnpm validator:start --restart",
10-
"validator:stop": "tsx ./scripts/helpers/stop-validator.mts",
11-
"js:format": "tsx ./scripts/js.mts format clients/js",
12-
"js:lint": "tsx ./scripts/js.mts lint clients/js",
13-
"js:publish": "tsx ./scripts/js.mts publish clients/js",
14-
"js:test": "tsx ./scripts/js.mts test clients/js",
15-
"rust:format": "tsx ./scripts/rust.mts format clients/rust",
16-
"rust:lint": "tsx ./scripts/rust.mts lint clients/rust",
17-
"rust:lint:clippy": "tsx ./scripts/rust.mts lint-clippy clients/rust",
18-
"rust:lint:docs": "tsx ./scripts/rust.mts lint-docs clients/rust",
19-
"rust:lint:features": "tsx ./scripts/rust.mts lint-features clients/rust",
20-
"rust:publish": "tsx ./scripts/rust.mts publish clients/rust",
21-
"rust:test": "tsx ./scripts/rust.mts test clients/rust",
22-
"interface:format": "tsx ./scripts/rust.mts format interface",
23-
"interface:lint": "tsx ./scripts/rust.mts lint interface",
24-
"interface:lint:clippy": "tsx ./scripts/rust.mts lint-clippy interface",
25-
"interface:lint:docs": "tsx ./scripts/rust.mts lint-docs interface",
26-
"interface:lint:features": "tsx ./scripts/rust.mts lint-features interface",
27-
"interface:publish": "tsx ./scripts/rust.mts publish interface",
28-
"interface:test": "tsx ./scripts/rust.mts test interface",
29-
"interface:wasm": "tsx ./scripts/rust.mts wasm interface",
30-
"template:upgrade": "tsx ./scripts/helpers/upgrade-template.ts"
5+
"generate:clients": "codama run --all"
316
},
327
"devDependencies": {
338
"@codama/renderers-js": "^1.2.7",
349
"@codama/renderers-rust": "^1.0.16",
35-
"@iarna/toml": "^2.2.5",
36-
"codama": "^1.2.8",
37-
"tsx": "^4.19.2",
38-
"typescript": "^5.5.2",
39-
"zx": "^7.2.3"
10+
"codama": "^1.2.8"
4011
},
4112
"engines": {
4213
"node": ">=v20.0.0"

0 commit comments

Comments
 (0)