-
Notifications
You must be signed in to change notification settings - Fork 37
126 lines (113 loc) · 4.02 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
name: Solana CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- dev
jobs:
solana-sbf:
name: Solana Cargo SBF
runs-on: ubuntu-20.04
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) }' solana/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) }' solana/Cargo.toml)"
echo "::set-output name=version::${SOLANA_VERSION}"
- name: Cache rust toolchain
uses: actions/cache@v3
env:
cache-name: solana-toolchain
with:
path: |
~/.cargo/bin
~/.rustup
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
with:
toolchain: ${{ steps.toolchain.outputs.version }}
components: "clippy,rustfmt"
- name: Cache rust packages / build cache
uses: actions/cache@v3
env:
cache-name: solana-rust-packages
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git/db
solana/target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run `cargo fmt`
run: cargo fmt --check --all --manifest-path solana/Cargo.toml
- name: Run `cargo check`
run: cargo check --workspace --tests --manifest-path solana/Cargo.toml
- name: Run `cargo clippy`
run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml
- 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
env:
RUST_BACKTRACE: "1"
run: |
cd solana
export BPF_OUT_DIR="$(pwd)/target/deploy"
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
mkdir -p "${BPF_OUT_DIR}"
BPF_PACKAGES=(
programs/example-native-token-transfers/Cargo.toml
programs/wormhole-governance/Cargo.toml
)
for p in "${BPF_PACKAGES[@]}"; do
cargo build-sbf --manifest-path "${p}"
done
for p in "${BPF_PACKAGES[@]}"; do
cargo test-sbf --manifest-path "${p}"
done
anchor-test:
name: Anchor Test
runs-on: ubuntu-latest
# Anchor Docker image: https://www.anchor-lang.com/docs/verifiable-builds#images
container: backpackapp/build:v0.29.0
steps:
- uses: actions/checkout@v4
- name: Set default Rust toolchain
run: rustup default stable
working-directory: ./solana
- name: anchor test --arch sbf
run: make anchor-test
working-directory: ./solana