Skip to content

Commit a7ca79e

Browse files
authored
Update repo from latest create-solana-program (#5)
1 parent afc2280 commit a7ca79e

33 files changed

+1194
-258
lines changed

.github/actions/setup/action.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Setup environment
2+
3+
inputs:
4+
cargo-cache-key:
5+
description: The key to cache cargo dependencies. Skips cargo caching if not provided.
6+
required: false
7+
cargo-cache-fallback-key:
8+
description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key.
9+
required: false
10+
cargo-cache-local-key:
11+
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
12+
required: false
13+
clippy:
14+
description: Install Clippy if `true`. Defaults to `false`.
15+
required: false
16+
rustfmt:
17+
description: Install Rustfmt if `true`. Defaults to `false`.
18+
required: false
19+
solana:
20+
description: Install Solana if `true`. Defaults to `false`.
21+
required: false
22+
23+
runs:
24+
using: 'composite'
25+
steps:
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v3
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 18
33+
cache: 'pnpm'
34+
35+
- name: Install Dependencies
36+
run: pnpm install --frozen-lockfile
37+
shell: bash
38+
39+
- name: Set Environment Variables
40+
shell: bash
41+
run: pnpm zx ./scripts/ci/set-env.mjs
42+
43+
- name: Install Rustfmt
44+
if: ${{ inputs.rustfmt == 'true' }}
45+
uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
48+
components: rustfmt
49+
50+
- name: Install Clippy
51+
if: ${{ inputs.clippy == 'true' }}
52+
uses: dtolnay/rust-toolchain@master
53+
with:
54+
toolchain: ${{ env.TOOLCHAIN_LINT }}
55+
components: clippy
56+
57+
- name: Install Solana
58+
if: ${{ inputs.solana == 'true' }}
59+
uses: metaplex-foundation/actions/install-solana@v1
60+
with:
61+
version: ${{ env.SOLANA_VERSION }}
62+
cache: true
63+
64+
- name: Cache Cargo Dependencies
65+
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cargo/bin/
70+
~/.cargo/registry/index/
71+
~/.cargo/registry/cache/
72+
~/.cargo/git/db/
73+
target/
74+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
76+
77+
- name: Cache Cargo Dependencies With Fallback
78+
if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
79+
uses: actions/cache@v4
80+
with:
81+
path: |
82+
~/.cargo/bin/
83+
~/.cargo/registry/index/
84+
~/.cargo/registry/cache/
85+
~/.cargo/git/db/
86+
target/
87+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
88+
restore-keys: |
89+
${{ runner.os }}-${{ inputs.cargo-cache-key }}
90+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
91+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
92+
93+
- name: Cache Local Cargo Dependencies
94+
if: ${{ inputs.cargo-cache-local-key }}
95+
uses: actions/cache@v4
96+
with:
97+
path: |
98+
.cargo/bin/
99+
.cargo/registry/index/
100+
.cargo/registry/cache/
101+
.cargo/git/db/
102+
key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
103+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}

.github/workflows/main.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
format_and_lint_client_js:
11+
name: Format & Lint Client JS
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Git Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Environment
18+
uses: ./.github/actions/setup
19+
20+
- name: Format Client JS
21+
run: pnpm clients:js:format
22+
23+
- name: Lint Client JS
24+
run: pnpm clients:js:lint
25+
26+
format_and_lint_client_rust:
27+
if: false # Disabled until we have a Rust client
28+
name: Format & Lint Client Rust
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Git Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Environment
35+
uses: ./.github/actions/setup
36+
with:
37+
clippy: true
38+
rustfmt: true
39+
40+
- name: Format Client Rust
41+
run: pnpm clients:rust:format
42+
43+
- name: Lint Client Rust
44+
run: pnpm clients:rust:lint
45+
46+
generate_clients:
47+
name: Check Client Generation
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Git Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Setup Environment
54+
uses: ./.github/actions/setup
55+
with:
56+
rustfmt: true
57+
58+
- name: Generate Clients
59+
run: pnpm generate:clients
60+
61+
- name: Check Working Directory
62+
run: |
63+
git status --porcelain
64+
test -z "$(git status --porcelain)"
65+
66+
test_client_js:
67+
name: Test Client JS
68+
runs-on: ubuntu-latest
69+
needs: format_and_lint_client_js
70+
steps:
71+
- name: Git Checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Setup Environment
75+
uses: ./.github/actions/setup
76+
with:
77+
solana: true
78+
79+
- name: Test Client JS
80+
run: pnpm clients:js:test
81+
82+
test_client_rust:
83+
if: false # Disabled until we have a Rust client
84+
name: Test Client Rust
85+
runs-on: ubuntu-latest
86+
needs: format_and_lint_client_rust
87+
steps:
88+
- name: Git Checkout
89+
uses: actions/checkout@v4
90+
91+
- name: Setup Environment
92+
uses: ./.github/actions/setup
93+
with:
94+
cargo-cache-key: cargo-rust-client
95+
solana: true
96+
97+
- name: Test Client Rust
98+
run: pnpm clients:rust:test
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Publish JS Client
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
level:
7+
description: Version level
8+
required: true
9+
default: patch
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- prerelease
16+
- prepatch
17+
- preminor
18+
- premajor
19+
tag:
20+
description: NPM Tag (and preid for pre-releases)
21+
required: true
22+
type: string
23+
default: latest
24+
create_release:
25+
description: Create a GitHub release
26+
required: true
27+
type: boolean
28+
default: true
29+
30+
jobs:
31+
test_js:
32+
name: Test JS client
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Git Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Environment
39+
uses: ./.github/actions/setup
40+
with:
41+
solana: true
42+
43+
- name: Format JS Client
44+
run: pnpm clients:js:format
45+
46+
- name: Lint JS Client
47+
run: pnpm clients:js:lint
48+
49+
- name: Test JS Client
50+
run: pnpm clients:js:test
51+
52+
publish_js:
53+
name: Publish JS client
54+
runs-on: ubuntu-latest
55+
needs: test_js
56+
permissions:
57+
contents: write
58+
steps:
59+
- name: Git Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Environment
63+
uses: ./.github/actions/setup
64+
65+
- name: Ensure NPM_TOKEN variable is set
66+
env:
67+
token: ${{ secrets.NPM_TOKEN }}
68+
if: ${{ env.token == '' }}
69+
run: |
70+
echo "The NPM_TOKEN secret variable is not set"
71+
echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
72+
exit 1
73+
74+
- name: NPM Authentication
75+
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
76+
env:
77+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
79+
- name: Set Git Author
80+
run: |
81+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
82+
git config --global user.name "github-actions[bot]"
83+
84+
- name: Publish JS Client
85+
id: publish
86+
run: pnpm clients:js:publish ${{ inputs.level }} ${{ inputs.tag }}
87+
88+
- name: Push Commit and Tag
89+
run: git push origin --follow-tags
90+
91+
- name: Create GitHub release
92+
if: github.event.inputs.create_release == 'true'
93+
uses: ncipollo/release-action@v1
94+
with:
95+
tag: js@v${{ steps.publish.outputs.new_version }}

0 commit comments

Comments
 (0)