-
Notifications
You must be signed in to change notification settings - Fork 38
142 lines (127 loc) · 4.16 KB
/
solana.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Solana CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- dev
defaults:
run:
working-directory: ./solana
jobs:
solana-sbf:
name: Solana Cargo SBF
runs-on: tilt-kube-public
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v3
- name: Get rust toolchain version
id: toolchain
run: |
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' rust-toolchain)"
echo "::set-output name=version::${RUST_VERSION}"
- name: Get solana version
id: solana
run: |
SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' Cargo.toml)"
echo "::set-output name=version::${SOLANA_VERSION}"
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
with:
toolchain: ${{ steps.toolchain.outputs.version }}
components: "clippy,rustfmt"
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "solana"
- name: Run `cargo fmt`
run: cargo fmt --check --all --manifest-path Cargo.toml
- name: Run `cargo check`
run: cargo check --workspace --tests --manifest-path Cargo.toml
- name: Run `cargo clippy`
run: cargo clippy --workspace --tests --manifest-path Cargo.toml -- -Dclippy::cast_possible_truncation
- name: Cache solana tools
id: cache-solana
uses: actions/cache@v3
env:
cache-name: solana-tools
with:
path: |
~/.local/share/solana/install/
~/.cache/solana/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }}
- if: ${{ steps.cache-solana.outputs.cache-hit != 'true' }}
name: Install solana tools
env:
SOLANA_VERSION: ${{ steps.solana.outputs.version }}
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_VERSION}/install)"
~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh
- name: cargo build-sbf && cargo test-sbf && cargo test
env:
RUST_BACKTRACE: "1"
run: |
export BPF_OUT_DIR="$(pwd)/target/deploy"
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
mkdir -p "${BPF_OUT_DIR}"
cargo build-sbf --features "mainnet"
cargo test-sbf --features "mainnet"
cargo test
check-version:
name: Check version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./scripts/sync-versions --check
shell: bash
anchor-test:
name: Anchor Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: metadaoproject/setup-anchor@v2
with:
node-version: "20.11.0"
solana-cli-version: "1.18.10"
anchor-version: "0.29.0"
- name: Cache node_modules
uses: actions/cache@v3
with:
path: ./solana/node_modules/
key: node-modules-${{ runner.os }}-build-${{ inputs.node-version }}
- name: Install node_modules
run: make node_modules
shell: bash
- name: Create keypair
run: solana-keygen new --no-bip39-passphrase
shell: bash
- name: Make Anchor.toml compatible with runner
run: sed -i 's:/user/:/runner/:' Anchor.toml
shell: bash
- name: Install Cargo toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustc
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "solana"
- name: Setup SDK
run: make sdk
shell: bash
- name: Check idl
run: |
git diff --exit-code ts/idl
- name: Set default Rust toolchain
run: rustup default stable
shell: bash
- name: Run anchor lint
run: make anchor-lint
shell: bash
- name: Run tests
run: anchor test --skip-build
shell: bash