Skip to content

Commit eff3b5a

Browse files
authored
Upgrade Repository Template (#10)
1 parent e5150b7 commit eff3b5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+8438
-343
lines changed

.github/actions/setup/action.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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 Protobuf Compiler (Temporary Workaround for Solana 2.0)
44+
if: ${{ inputs.solana == 'true' || inputs.rustfmt == 'true' || inputs.clippy == 'true' }}
45+
shell: bash
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y protobuf-compiler
49+
50+
- name: Install Rustfmt
51+
if: ${{ inputs.rustfmt == 'true' }}
52+
uses: dtolnay/rust-toolchain@master
53+
with:
54+
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
55+
components: rustfmt
56+
57+
- name: Install Clippy
58+
if: ${{ inputs.clippy == 'true' }}
59+
uses: dtolnay/rust-toolchain@master
60+
with:
61+
toolchain: ${{ env.TOOLCHAIN_LINT }}
62+
components: clippy
63+
64+
- name: Install Solana
65+
if: ${{ inputs.solana == 'true' }}
66+
uses: metaplex-foundation/actions/install-solana@v1
67+
with:
68+
version: ${{ env.SOLANA_VERSION }}
69+
cache: true
70+
71+
- name: Cache Cargo Dependencies
72+
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
73+
uses: actions/cache@v4
74+
with:
75+
path: |
76+
~/.cargo/bin/
77+
~/.cargo/registry/index/
78+
~/.cargo/registry/cache/
79+
~/.cargo/git/db/
80+
target/
81+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
82+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
83+
84+
- name: Cache Cargo Dependencies With Fallback
85+
if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
86+
uses: actions/cache@v4
87+
with:
88+
path: |
89+
~/.cargo/bin/
90+
~/.cargo/registry/index/
91+
~/.cargo/registry/cache/
92+
~/.cargo/git/db/
93+
target/
94+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
95+
restore-keys: |
96+
${{ runner.os }}-${{ inputs.cargo-cache-key }}
97+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
98+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
99+
100+
- name: Cache Local Cargo Dependencies
101+
if: ${{ inputs.cargo-cache-local-key }}
102+
uses: actions/cache@v4
103+
with:
104+
path: |
105+
.cargo/bin/
106+
.cargo/registry/index/
107+
.cargo/registry/cache/
108+
.cargo/git/db/
109+
key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
110+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}

.github/workflows/main.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
format_and_lint_programs:
11+
name: Format & Lint Programs
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+
with:
20+
clippy: true
21+
rustfmt: true
22+
23+
- name: Format Programs
24+
run: pnpm programs:format
25+
26+
- name: Lint Programs
27+
run: pnpm programs:lint
28+
29+
format_and_lint_client_js:
30+
name: Format & Lint Client JS
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Git Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Environment
37+
uses: ./.github/actions/setup
38+
39+
- name: Format Client JS
40+
run: pnpm clients:js:format
41+
42+
- name: Lint Client JS
43+
run: pnpm clients:js:lint
44+
45+
format_and_lint_client_rust:
46+
name: Format & Lint Client Rust
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Git Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Environment
53+
uses: ./.github/actions/setup
54+
with:
55+
clippy: true
56+
rustfmt: true
57+
58+
- name: Format Client Rust
59+
run: pnpm clients:rust:format
60+
61+
- name: Lint Client Rust
62+
run: pnpm clients:rust:lint
63+
64+
build_programs:
65+
name: Build programs
66+
runs-on: ubuntu-latest
67+
needs: format_and_lint_programs
68+
steps:
69+
- name: Git Checkout
70+
uses: actions/checkout@v4
71+
72+
- name: Setup Environment
73+
uses: ./.github/actions/setup
74+
with:
75+
cargo-cache-key: cargo-programs
76+
solana: true
77+
78+
- name: Build Programs
79+
run: pnpm programs:build
80+
81+
- name: Upload Program Builds
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: program-builds
85+
path: ./target/deploy/*.so
86+
if-no-files-found: error
87+
88+
- name: Save Program Builds For Client Jobs
89+
uses: actions/cache/save@v4
90+
with:
91+
path: ./**/*.so
92+
key: ${{ runner.os }}-builds-${{ github.sha }}
93+
94+
test_programs:
95+
name: Test Programs
96+
runs-on: ubuntu-latest
97+
needs: format_and_lint_programs
98+
steps:
99+
- name: Git Checkout
100+
uses: actions/checkout@v4
101+
102+
- name: Setup Environment
103+
uses: ./.github/actions/setup
104+
with:
105+
cargo-cache-key: cargo-program-tests
106+
cargo-cache-fallback-key: cargo-programs
107+
solana: true
108+
109+
- name: Test Programs
110+
run: pnpm programs:test
111+
112+
## SKIP: IDL is hand-cranked here for now.
113+
##
114+
# generate_idls:
115+
# name: Check IDL Generation
116+
# runs-on: ubuntu-latest
117+
# needs: format_and_lint_programs
118+
# steps:
119+
# - name: Git Checkout
120+
# uses: actions/checkout@v4
121+
122+
# - name: Setup Environment
123+
# uses: ./.github/actions/setup
124+
# with:
125+
# cargo-cache-key: cargo-programs
126+
# cargo-cache-local-key: cargo-local
127+
128+
# - name: Generate IDLs
129+
# run: pnpm generate:idls
130+
131+
# - name: Check Working Directory
132+
# run: |
133+
# git status --porcelain
134+
# test -z "$(git status --porcelain)"
135+
136+
generate_clients:
137+
name: Check Client Generation
138+
runs-on: ubuntu-latest
139+
needs: format_and_lint_programs
140+
steps:
141+
- name: Git Checkout
142+
uses: actions/checkout@v4
143+
144+
- name: Setup Environment
145+
uses: ./.github/actions/setup
146+
with:
147+
rustfmt: true
148+
149+
- name: Generate Clients
150+
run: pnpm generate:clients
151+
152+
- name: Check Working Directory
153+
run: |
154+
git status --porcelain
155+
test -z "$(git status --porcelain)"
156+
157+
test_client_js:
158+
name: Test Client JS
159+
runs-on: ubuntu-latest
160+
needs: build_programs
161+
steps:
162+
- name: Git Checkout
163+
uses: actions/checkout@v4
164+
165+
- name: Setup Environment
166+
uses: ./.github/actions/setup
167+
with:
168+
solana: true
169+
170+
- name: Restore Program Builds
171+
uses: actions/cache/restore@v4
172+
with:
173+
path: ./**/*.so
174+
key: ${{ runner.os }}-builds-${{ github.sha }}
175+
176+
- name: Test Client JS
177+
run: pnpm clients:js:test
178+
179+
test_client_rust:
180+
name: Test Client Rust
181+
runs-on: ubuntu-latest
182+
needs: build_programs
183+
steps:
184+
- name: Git Checkout
185+
uses: actions/checkout@v4
186+
187+
- name: Setup Environment
188+
uses: ./.github/actions/setup
189+
with:
190+
cargo-cache-key: cargo-rust-client
191+
solana: true
192+
193+
- name: Restore Program Builds
194+
uses: actions/cache/restore@v4
195+
with:
196+
path: ./**/*.so
197+
key: ${{ runner.os }}-builds-${{ github.sha }}
198+
199+
- name: Test Client Rust
200+
run: pnpm clients:rust:test

0 commit comments

Comments
 (0)