Skip to content

Commit 2b70ef6

Browse files
committed
repository setup
0 parents  commit 2b70ef6

Some content is hidden

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

67 files changed

+13274
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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@v4
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+
shell: bash
67+
run: |
68+
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_VERSION }}/install)"
69+
rm -f "$HOME/.local/share/solana/install/active_release"
70+
ln -s "$HOME/.local/share/solana/install/releases/${{ env.SOLANA_VERSION }}/solana-release" "$HOME/.local/share/solana/install/active_release"
71+
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
72+
73+
- name: Cache Cargo Dependencies
74+
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
75+
uses: actions/cache@v4
76+
with:
77+
path: |
78+
~/.cargo/bin/
79+
~/.cargo/registry/index/
80+
~/.cargo/registry/cache/
81+
~/.cargo/git/db/
82+
target/
83+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
84+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
85+
86+
- name: Cache Cargo Dependencies With Fallback
87+
if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
88+
uses: actions/cache@v4
89+
with:
90+
path: |
91+
~/.cargo/bin/
92+
~/.cargo/registry/index/
93+
~/.cargo/registry/cache/
94+
~/.cargo/git/db/
95+
target/
96+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
97+
restore-keys: |
98+
${{ runner.os }}-${{ inputs.cargo-cache-key }}
99+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
100+
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
101+
102+
- name: Cache Local Cargo Dependencies
103+
if: ${{ inputs.cargo-cache-local-key }}
104+
uses: actions/cache@v4
105+
with:
106+
path: |
107+
.cargo/bin/
108+
.cargo/registry/index/
109+
.cargo/registry/cache/
110+
.cargo/git/db/
111+
key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
112+
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}

.github/workflows/main.yml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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+
generate_idls:
113+
name: Check IDL Generation
114+
runs-on: ubuntu-latest
115+
needs: format_and_lint_programs
116+
steps:
117+
- name: Git Checkout
118+
uses: actions/checkout@v4
119+
120+
- name: Setup Environment
121+
uses: ./.github/actions/setup
122+
with:
123+
cargo-cache-key: cargo-programs
124+
cargo-cache-local-key: cargo-local
125+
126+
- name: Generate IDLs
127+
run: pnpm generate:idls
128+
129+
- name: Check Working Directory
130+
run: |
131+
git status --porcelain
132+
test -z "$(git status --porcelain)"
133+
134+
generate_clients:
135+
name: Check Client Generation
136+
runs-on: ubuntu-latest
137+
needs: format_and_lint_programs
138+
steps:
139+
- name: Git Checkout
140+
uses: actions/checkout@v4
141+
142+
- name: Setup Environment
143+
uses: ./.github/actions/setup
144+
with:
145+
rustfmt: true
146+
147+
- name: Generate Clients
148+
run: pnpm generate:clients
149+
150+
- name: Check Working Directory
151+
run: |
152+
git status --porcelain
153+
test -z "$(git status --porcelain)"
154+
155+
test_client_js:
156+
name: Test Client JS
157+
runs-on: ubuntu-latest
158+
needs: build_programs
159+
steps:
160+
- name: Git Checkout
161+
uses: actions/checkout@v4
162+
163+
- name: Setup Environment
164+
uses: ./.github/actions/setup
165+
with:
166+
solana: true
167+
168+
- name: Restore Program Builds
169+
uses: actions/cache/restore@v4
170+
with:
171+
path: ./**/*.so
172+
key: ${{ runner.os }}-builds-${{ github.sha }}
173+
174+
- name: Test Client JS
175+
run: pnpm clients:js:test
176+
177+
test_client_rust:
178+
name: Test Client Rust
179+
runs-on: ubuntu-latest
180+
needs: build_programs
181+
steps:
182+
- name: Git Checkout
183+
uses: actions/checkout@v4
184+
185+
- name: Setup Environment
186+
uses: ./.github/actions/setup
187+
with:
188+
cargo-cache-key: cargo-rust-client
189+
solana: true
190+
191+
- name: Restore Program Builds
192+
uses: actions/cache/restore@v4
193+
with:
194+
path: ./**/*.so
195+
key: ${{ runner.os }}-builds-${{ github.sha }}
196+
197+
- name: Test Client Rust
198+
run: pnpm clients:rust:test

0 commit comments

Comments
 (0)