Skip to content

Commit a1530b8

Browse files
committed
Add build scripts
1 parent d19c466 commit a1530b8

File tree

18 files changed

+404
-242
lines changed

18 files changed

+404
-242
lines changed

.github/.env

Lines changed: 0 additions & 3 deletions
This file was deleted.

.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+
toolchain:
8+
description: Rust toolchain to install. Comma-separated string of [`build`, `format`, `lint`, `test`].
9+
required: false
10+
components:
11+
description: Cargo components to install. Comma-separated string of [`audit`, `hack`, `release`, `semver-checks`].
12+
required: false
13+
solana:
14+
description: Install Solana if `true`. Defaults to `false`.
15+
required: false
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Set Environment Variables
21+
shell: bash
22+
run: |
23+
source make
24+
echo "RUST_TOOLCHAIN_BUILD=${RUST_TOOLCHAIN_BUILD}" >> $GITHUB_ENV
25+
echo "RUST_TOOLCHAIN_FORMAT=${RUST_TOOLCHAIN_FORMAT}" >> $GITHUB_ENV
26+
echo "RUST_TOOLCHAIN_LINT=${RUST_TOOLCHAIN_LINT}" >> $GITHUB_ENV
27+
echo "RUST_TOOLCHAIN_TEST=${RUST_TOOLCHAIN_TEST}" >> $GITHUB_ENV
28+
echo "SOLANA_CLI_VERSION=${SOLANA_CLI_VERSION}" >> $GITHUB_ENV
29+
30+
- name: Install Rust 'build' Toolchain
31+
if: ${{ contains(inputs.toolchain, 'build') }}
32+
uses: dtolnay/rust-toolchain@master
33+
with:
34+
toolchain: ${{ env.RUST_TOOLCHAIN_BUILD }}
35+
36+
- name: Install Rust 'format' Toolchain
37+
if: ${{ contains(inputs.toolchain, 'format') }}
38+
uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: ${{ env.RUST_TOOLCHAIN_FORMAT }}
41+
components: rustfmt
42+
43+
- name: Install Rust 'lint' Toolchain
44+
if: ${{ contains(inputs.toolchain, 'lint') }}
45+
uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: ${{ env.RUST_TOOLCHAIN_LINT }}
48+
components: clippy
49+
50+
- name: Install Rust 'test' Toolchain
51+
if: ${{ contains(inputs.toolchain, 'test') }}
52+
uses: dtolnay/rust-toolchain@master
53+
with:
54+
toolchain: ${{ env.RUST_TOOLCHAIN_TEST }}
55+
56+
- name: Install Solana
57+
if: ${{ inputs.solana == 'true' }}
58+
uses: solana-program/actions/install-solana@v1
59+
with:
60+
version: ${{ env.SOLANA_VERSION }}
61+
cache: true
62+
63+
- name: Install 'cargo-audit'
64+
if: ${{ contains(inputs.components, 'audit') }}
65+
uses: taiki-e/cache-cargo-install-action@v2
66+
with:
67+
tool: cargo-audit
68+
69+
- name: Install 'cargo-hack'
70+
if: ${{ contains(inputs.components, 'hack') }}
71+
uses: taiki-e/cache-cargo-install-action@v2
72+
with:
73+
tool: cargo-hack
74+
75+
- name: Install 'cargo-release'
76+
if: ${{ contains(inputs.components, 'release') }}
77+
uses: taiki-e/cache-cargo-install-action@v2
78+
with:
79+
80+
81+
- name: Install 'cargo-semver-checks'
82+
if: ${{ contains(inputs.components, 'semver-checks') }}
83+
uses: taiki-e/cache-cargo-install-action@v2
84+
with:
85+
86+
87+
- name: Install 'cargo-miri'
88+
if: ${{ contains(inputs.toolchain, 'lint') }}
89+
uses: dtolnay/rust-toolchain@master
90+
with:
91+
toolchain: ${{ env.TOOLCHAIN_LINT }}
92+
components: miri
93+
94+
- name: Install 'cargo-spellcheck'
95+
if: ${{ contains(inputs.components, 'spellcheck') }}
96+
uses: taiki-e/install-action@v2
97+
with:
98+
tool: cargo-spellcheck
99+
100+
- name: Cache Cargo Dependencies
101+
if: ${{ inputs.cargo-cache-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+
target/
110+
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}

.github/file-filters.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,89 @@ on:
44
push:
55
branches: [main]
66
pull_request:
7-
branches: [main]
87

98
env:
109
CACHE: true
1110

1211
jobs:
13-
changes:
14-
name: Detect changes
15-
runs-on: buildjet-8vcpu-ubuntu-2204
16-
outputs:
17-
crate: ${{ steps.changes.outputs.crate }}
12+
spellcheck:
13+
name: Spellcheck
14+
runs-on: ubuntu-latest
1815
steps:
19-
- name: Git checkout
16+
- name: Git Checkout
2017
uses: actions/checkout@v4
2118

22-
- name: Load environment variables
23-
run: cat .github/.env >> $GITHUB_ENV
19+
- name: Setup Environment
20+
uses: ./.github/actions/setup
21+
with:
22+
cargo-cache-key: cargo-spellcheck
23+
components: spellcheck
24+
25+
- name: cargo-spellcheck
26+
run: ./make spellcheck
27+
28+
lint:
29+
name: Lint
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Git Checkout
33+
uses: actions/checkout@v4
2434

25-
- name: Detect changes
26-
uses: dorny/paths-filter@v3
27-
id: changes
35+
- name: Setup Environment
36+
uses: ./.github/actions/setup
2837
with:
29-
filters: .github/file-filters.yml
38+
cargo-cache-key: cargo-lint
39+
toolchain: format, lint
40+
components: hack, miri
41+
42+
- name: cargo-clippy
43+
run: ./make clippy
44+
45+
- name: cargo-fmt
46+
run: ./make format
47+
48+
- name: cargo-doc
49+
run: ./make doc
50+
51+
- name: cargo-hack
52+
run: ./make hack
53+
54+
- name: cargo-miri
55+
run: ./make miri
3056

3157
build:
32-
name: Crate
33-
if: ${{ needs.changes.outputs.crate == 'true' }}
34-
needs: changes
35-
uses: ./.github/workflows/build.yml
36-
secrets: inherit
58+
name: Build
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Git Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Environment
65+
uses: ./.github/actions/setup
66+
with:
67+
cargo-cache-key: cargo-build
68+
toolchain: build
69+
solana: true
70+
71+
- name: cargo-build
72+
run: ./make build
73+
74+
- name: cargo-build-sbf
75+
run: ./make build-sbf
3776

3877
test:
39-
name: Crate
40-
if: ${{ needs.changes.outputs.crate == 'true' }}
41-
needs: changes
42-
uses: ./.github/workflows/test.yml
43-
secrets: inherit
78+
name: Test
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Git Checkout
82+
uses: actions/checkout@v4
83+
84+
- name: Setup Environment
85+
uses: ./.github/actions/setup
86+
with:
87+
cargo-cache-key: cargo-test
88+
toolchain: test
89+
solana: true
90+
91+
- name: cargo-test
92+
run: ./make test

0 commit comments

Comments
 (0)