-
Notifications
You must be signed in to change notification settings - Fork 11
101 lines (94 loc) · 3.79 KB
/
Copy pathrust-ci.yaml
File metadata and controls
101 lines (94 loc) · 3.79 KB
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
name: Rust CI
on:
pull_request:
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
- 'packages/**'
- '.github/workflows/rust-ci.yaml'
push:
branches:
- main
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
jobs:
lint:
name: Format & Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
cache-on-failure: true
- name: Rust fmt
run: cargo fmt --all -- --check
- name: Rust clippy
run: cargo clippy --workspace --all-targets -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
cache-on-failure: true
- name: Install cargo-nextest
uses: taiki-e/install-action@37ba67210166984a515120020147f0b4ae3b8667 # nextest
# Regenerate Cairo reference data when Cairo/SDK files changed or on push to main (rebase)
- name: Check for Cairo/SDK changes
id: cairo-check
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3
with:
filters: |
changed:
- 'packages/**'
- 'sdk/**'
- 'Scarb.toml'
- 'Scarb.lock'
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true'
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: sdk/package-lock.json
- name: Install Scarb
if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true'
uses: software-mansion/setup-scarb@2a96b748888e3329ee44ac9ac073d930e692b3cd # v1
with:
scarb-version: "2.18.0"
- uses: software-mansion/setup-universal-sierra-compiler@30c139bca57cc0561cfae6f5353825bbc42c9f37 # v1
if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true'
with:
universal-sierra-compiler-version: "v2.8.0"
- name: Install starknet-foundry via asdf
if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true'
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 # v3
with:
asdf_branch: v0.14.1
tool_versions: |
starknet-foundry 0.63.0
- name: Generate Cairo reference data
if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true'
run: |
# Remove Scarb's dev build dir so we don't load stale incremental cache
# (rust-cache restores target/ which can contain Scarb's target/dev/ from a previous run)
rm -rf target/dev
cd sdk
npm run scarb:build
npm run generate:cairo-refs
cp tests/fixtures/cairo-reference-data.json ../crates/discovery-core/tests/fixtures/cairo-reference-data.json
- name: Install starknet-devnet
run: |
curl -L https://github.com/0xSpaceShard/starknet-devnet/releases/download/v0.8.0-rc.3/starknet-devnet-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C /usr/local/bin
chmod +x /usr/local/bin/starknet-devnet
- name: Rust test
run: cargo nextest run --workspace --all-targets