Skip to content

Commit 636aa23

Browse files
committed
CI: add targets in Makefile and replace it in ci.yaml
1 parent 170bff0 commit 636aa23

File tree

2 files changed

+54
-36
lines changed

2 files changed

+54
-36
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ jobs:
3232
rustup override set nightly
3333
- name: Download circuits files
3434
run: |
35-
git clone --depth 1 https://github.com/openmina/circuit-blobs.git
36-
ln -s -b $PWD/circuit-blobs/* ledger/
35+
make download-circuits
3736
- name: Build ledger tests
3837
run: |
39-
cd ledger
40-
cargo build --release --tests
38+
make build-ledger
4139
- name: Run ledger tests
4240
run: |
43-
cd ledger
44-
cargo test --release -- -Z unstable-options --report-time
41+
make test-ledger
4542
4643
ledger-32x9-tests:
4744
runs-on: ubuntu-22.04
@@ -59,8 +56,7 @@ jobs:
5956
rustup override set nightly
6057
- name: Download circuits files
6158
run: |
62-
git clone --depth 1 https://github.com/openmina/circuit-blobs.git
63-
ln -s -b $PWD/circuit-blobs/* ledger/
59+
make download-circuits
6460
- name: Enable 32x9 fields implementation
6561
run: |
6662
cargo install sd
@@ -70,12 +66,10 @@ jobs:
7066
cat ./Cargo.toml
7167
- name: Build ledger tests
7268
run: |
73-
cd ledger
74-
cargo build --release --tests
69+
make build-ledger
7570
- name: Run ledger tests
7671
run: |
77-
cd ledger
78-
cargo test --release -- -Z unstable-options --report-time
72+
make test-ledger
7973
8074
vrf-tests:
8175
runs-on: ubuntu-22.04
@@ -93,12 +87,10 @@ jobs:
9387
rustup override set nightly
9488
- name: Build vrf tests
9589
run: |
96-
cd vrf
97-
cargo build --release --tests
90+
make build-vrf
9891
- name: Run vrf tests
9992
run: |
100-
cd vrf
101-
cargo test --release -- -Z unstable-options --report-time
93+
make test-vrf
10294
10395
p2p-tests:
10496
runs-on: ubuntu-22.04
@@ -123,8 +115,7 @@ jobs:
123115

124116
- name: Test p2p crate
125117
run: |
126-
cargo test -p p2p --tests
127-
118+
make test-p2p
128119
129120
build:
130121
runs-on: ubuntu-22.04
@@ -149,7 +140,7 @@ jobs:
149140

150141
- name: Release build
151142
run: |
152-
cargo build --release --bin openmina
143+
make build-release
153144
154145
- name: Upload binaries
155146
uses: actions/upload-artifact@v4
@@ -182,10 +173,8 @@ jobs:
182173

183174
- name: Release build
184175
run: |
185-
cd node/web
186176
rustup component add rust-src rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
187-
cargo +nightly build --release --target wasm32-unknown-unknown
188-
wasm-bindgen --keep-debug --web --out-dir pkg ../../target/wasm32-unknown-unknown/release/openmina_node_web.wasm
177+
make build-wasm
189178
190179
build-tests:
191180
runs-on: ubuntu-22.04
@@ -246,12 +235,7 @@ jobs:
246235

247236
- name: Build tests
248237
run: |
249-
mkdir -p target/release/tests
250-
251-
cargo build --release --features=scenario-generators,p2p-webrtc --package=openmina-node-testing --tests
252-
cargo build --release --features=scenario-generators,p2p-webrtc --package=openmina-node-testing --tests --message-format=json > cargo-build-test.json
253-
jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
254-
while read NAME FILE; do cp -a $FILE target/release/tests/webrtc_$NAME; done < tests.tsv
238+
make build-tests-webrtc
255239
256240
- name: Upload tests
257241
uses: actions/upload-artifact@v4

Makefile

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,42 @@ help: ## Ask for help!
88
build: ## Build the project in debug mode
99
cargo build
1010

11+
.PHONY: build-ledger
12+
build-ledger: download-circuits ## Build the ledger binary and library, requires nightly Rust
13+
@cd ledger && cargo +nightly build --release --tests
14+
1115
.PHONY: build-release
1216
build-release: ## Build the project in release mode
1317
cargo build --release --bin openmina
1418

15-
.PHONY: build-tests
16-
build-tests: ## Build test binaries
17-
cargo build --release --tests --package=openmina-node-testing --package=cli
19+
.PHONY: build-tests-webrtc
20+
build-tests-webrtc: ## Build tests for WebRTC
21+
@mkdir -p target/release/tests
22+
@cargo build --release --tests \
23+
--package=openmina-node-testing \
24+
--package=cli
25+
@cargo build --release \
26+
--features=scenario-generators,p2p-webrtc \
27+
--package=openmina-node-testing \
28+
--tests \
29+
--message-format=json \
30+
> cargo-build-test.json
31+
@jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
32+
@while read NAME FILE; do \
33+
cp -a $$FILE target/release/tests/webrtc_$$NAME; \
34+
done < tests.tsv
35+
36+
.PHONY: build-vrf
37+
build-vrf: ## Build the VRF package
38+
@cd vrf && cargo +nightly build --release --tests
1839

1940
.PHONY: build-wasm
2041
build-wasm: ## Build WebAssembly node
21-
cd node/web && cargo +nightly build --release --target wasm32-unknown-unknown
42+
@cd node/web && cargo +nightly build \
43+
--release --target wasm32-unknown-unknown
44+
@wasm-bindgen --keep-debug --web \
45+
--out-dir pkg \
46+
target/wasm32-unknown-unknown/release/openmina_node_web.wasm
2247

2348
.PHONY: check
2449
check: ## Check code for compilation errors
@@ -42,6 +67,15 @@ check-md: ## Check if markdown files are properly formatted
4267
clean: ## Clean build artifacts
4368
cargo clean
4469

70+
.PHONY: download-circuits
71+
download-circuits: ## Download the circuits used by Mina from GitHub
72+
@if [ ! -d "circuit-blobs" ]; then \
73+
git clone --depth 1 https://github.com/openmina/circuit-blobs.git; \
74+
ln -s -b "$$PWD"/circuit-blobs/* ledger/; \
75+
else \
76+
echo "circuit-blobs already exists, skipping download."; \
77+
fi
78+
4579
.PHONY: format
4680
format: ## Format code using rustfmt
4781
cargo +nightly fmt
@@ -61,8 +95,8 @@ test: ## Run tests
6195
cargo test
6296

6397
.PHONY: test-ledger
64-
test-ledger: ## Run ledger tests
65-
cd ledger && cargo test --release
98+
test-ledger: build-ledger ## Run ledger tests in release mode, requires nightly Rust
99+
@cd ledger && cargo +nightly test --release -- -Z unstable-options --report-time
66100

67101
.PHONY: test-p2p
68102
test-p2p: ## Run P2P tests
@@ -73,5 +107,5 @@ test-release: ## Run tests in release mode
73107
cargo test --release
74108

75109
.PHONY: test-vrf
76-
test-vrf: ## Run VRF tests
77-
cd vrf && cargo test --release
110+
test-vrf: ## Run VRF tests, requires nightly Rust
111+
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time

0 commit comments

Comments
 (0)