Skip to content

Commit 59387d2

Browse files
authored
Ci (#2)
* CI: Add setup for the whole repo #### Problem This repo only contains the implementation of the program, with no way of testing that any of it works. #### Summary of changes Get this repo in shape, based on the memo repo. Does the following: * add CI for testing during PRs * add dependabot * add scripts * add Cargo workspace * add license * add toolchain file / format file * update maintainers to Anza * (Temporary) always run CI * Revert "(Temporary) always run CI" This reverts commit 8f21cb3. * Fixup name to "record"
1 parent b5f032e commit 59387d2

27 files changed

+8192
-5
lines changed

.github/actions/setup/action.yml

+103
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: 20
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: solana-program/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/dependabot.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: cargo
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
time: "08:00"
13+
timezone: UTC
14+
open-pull-requests-limit: 6
15+
- package-ecosystem: npm
16+
directory: "/"
17+
schedule:
18+
interval: daily
19+
time: "09:00"
20+
timezone: UTC
21+
open-pull-requests-limit: 6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'solana-program/record'
12+
steps:
13+
- name: Enable auto-merge
14+
run: gh pr merge --auto --squash "$PR_URL"
15+
env:
16+
PR_URL: ${{ github.event.pull_request.html_url }}
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
audit_rust:
30+
name: Audit Rust
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+
with:
39+
cargo-cache-key: cargo-audit
40+
41+
- name: Install cargo-audit
42+
uses: taiki-e/install-action@v2
43+
with:
44+
tool: cargo-audit
45+
46+
- name: Run cargo-audit
47+
run: pnpm rust:audit
48+
49+
semver_rust:
50+
name: Check semver Rust
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Git Checkout
54+
uses: actions/checkout@v4
55+
56+
- name: Setup Environment
57+
uses: ./.github/actions/setup
58+
with:
59+
cargo-cache-key: cargo-semver
60+
61+
- name: Install cargo-audit
62+
uses: taiki-e/install-action@v2
63+
with:
64+
tool: cargo-semver-checks
65+
66+
- name: Run semver checks
67+
run: pnpm rust:semver
68+
69+
spellcheck_rust:
70+
name: Spellcheck Rust
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Git Checkout
74+
uses: actions/checkout@v4
75+
76+
- name: Setup Environment
77+
uses: ./.github/actions/setup
78+
with:
79+
cargo-cache-key: cargo-spellcheck
80+
81+
- name: Install cargo-spellcheck
82+
uses: taiki-e/install-action@v2
83+
with:
84+
tool: cargo-spellcheck
85+
86+
- name: Run cargo-spellcheck
87+
run: pnpm rust:spellcheck
88+
89+
build_programs:
90+
name: Build programs
91+
runs-on: ubuntu-latest
92+
needs: format_and_lint_programs
93+
steps:
94+
- name: Git Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Setup Environment
98+
uses: ./.github/actions/setup
99+
with:
100+
cargo-cache-key: cargo-programs
101+
solana: true
102+
103+
- name: Build Programs
104+
run: pnpm programs:build
105+
106+
- name: Upload Program Builds
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: program-builds
110+
path: ./target/deploy/*.so
111+
if-no-files-found: error
112+
113+
- name: Save Program Builds For Client Jobs
114+
uses: actions/cache/save@v4
115+
with:
116+
path: ./**/*.so
117+
key: ${{ runner.os }}-builds-${{ github.sha }}
118+
119+
test_programs:
120+
name: Test Programs
121+
runs-on: ubuntu-latest
122+
needs: format_and_lint_programs
123+
steps:
124+
- name: Git Checkout
125+
uses: actions/checkout@v4
126+
127+
- name: Setup Environment
128+
uses: ./.github/actions/setup
129+
with:
130+
cargo-cache-key: cargo-program-tests
131+
cargo-cache-fallback-key: cargo-programs
132+
solana: true
133+
134+
- name: Test Programs
135+
run: pnpm programs:test

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.anchor
2+
.cargo
3+
.DS_Store
4+
**/.DS_Store
5+
**/target
6+
**/*.rs.bk
7+
node_modules
8+
test-ledger
9+
dist

0 commit comments

Comments
 (0)