Skip to content

Commit 9e967ca

Browse files
authored
Merge pull request #1307 from o1-labs/dw/improve-ci-slightly
CI: consolidate workflows and improve caching strategy
2 parents f512345 + d6b1a8a commit 9e967ca

File tree

10 files changed

+93
-26
lines changed

10 files changed

+93
-26
lines changed

.github/actions/setup-build-deps/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
description: 'Include SQLite3 in the installation'
66
required: false
77
default: 'false'
8+
install-nextest:
9+
description: 'Install cargo-nextest for faster test execution'
10+
required: false
11+
default: 'false'
812
runs:
913
using: 'composite'
1014
steps:
@@ -23,4 +27,10 @@ runs:
2327
if: runner.os == 'macOS'
2428
shell: bash
2529
run: |
26-
brew install protobuf
30+
brew install protobuf
31+
32+
- name: Install cargo-nextest
33+
if: inputs.install-nextest == 'true'
34+
uses: taiki-e/install-action@v2
35+
with:
36+
tool: nextest

.github/actions/setup-rust/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ runs:
3030
if: inputs.enable-cache == 'true'
3131
uses: Swatinem/rust-cache@v2
3232
with:
33-
prefix-key: ${{ inputs.cache-prefix }}
33+
prefix-key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}
34+
shared-key: shared-${{ inputs.toolchain }}
35+
save-if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' }}

.github/workflows/ci.yaml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,38 @@ on:
55
pull_request:
66
paths-ignore: [ "frontend" ]
77
workflow_dispatch:
8+
inputs:
9+
refresh_cache:
10+
description: 'Refresh cargo cache'
11+
required: false
12+
type: boolean
13+
default: false
814

915
env:
1016
CARGO_TERM_COLOR: always
1117
RUST_BACKTRACE: full
1218
OPENMINA_PANIC_ON_BUG: true
19+
CARGO_INCREMENTAL: 1
20+
RUSTFLAGS: "-C overflow-checks=off -C debug-assertions=off"
1321

1422
concurrency:
1523
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1624
cancel-in-progress: true
1725

1826
jobs:
27+
refresh-cache:
28+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.refresh_cache == 'true' }}
29+
runs-on: ubuntu-24.04
30+
steps:
31+
- uses: actions/checkout@v5
32+
- name: Setup Rust
33+
uses: ./.github/actions/setup-rust
34+
with:
35+
toolchain: 1.84
36+
enable-cache: false
37+
- name: Clean cargo cache
38+
run: cargo clean
39+
1940
ledger-tests:
2041
timeout-minutes: 20
2142
runs-on: ubuntu-24.04
@@ -194,13 +215,7 @@ jobs:
194215
cache-prefix: build-tests-${{ matrix.os }}-v0
195216

196217
- name: Build tests
197-
run: |
198-
mkdir -p target/release/tests
199-
200-
cargo build --release --tests --package=openmina-node-testing --package=cli
201-
cargo build --release --tests --package=openmina-node-testing --package=cli --message-format=json > cargo-build-test.json
202-
jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
203-
while read NAME FILE; do cp -a $FILE target/release/tests/$NAME; done < tests.tsv
218+
run: make build-tests
204219

205220
- name: Upload tests
206221
if: matrix.os == 'ubuntu-22.04'

.github/workflows/fmt.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ on:
88
jobs:
99
format:
1010
name: Format using nightly
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- uses: actions/checkout@v5
14-
- uses: dtolnay/rust-toolchain@stable
14+
- name: Setup Rust
15+
uses: ./.github/actions/setup-rust
1516
with:
1617
toolchain: nightly
1718
components: rustfmt
19+
cache-prefix: format-nightly-v0
1820
- uses: taiki-e/install-action@v2
1921
with:
2022
tool: taplo

.github/workflows/frontend.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212

1313
jobs:
1414
frontend-test:
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
steps:
1717
- name: Git checkout
1818
uses: actions/checkout@v5

.github/workflows/lint.yml renamed to .github/workflows/lint.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest]
15+
os: [ubuntu-24.04]
1616
toolchain: [1.84]
1717
steps:
1818
- uses: actions/checkout@v5
1919
- name: Setup build dependencies
20-
run: |
21-
sudo apt update || true
22-
sudo apt install -y protobuf-compiler sqlite3 || true
20+
uses: ./.github/actions/setup-build-deps
21+
with:
22+
include-sqlite: true
2323
- name: Setup SQLite database for SQLx
2424
run: |
2525
sqlite3 /tmp/heartbeats.db < tools/heartbeats-processor/schema.sql
26-
- uses: dtolnay/rust-toolchain@stable
26+
- name: Setup Rust
27+
uses: ./.github/actions/setup-rust
2728
with:
2829
toolchain: ${{ matrix.toolchain }}
2930
components: clippy, rustfmt
31+
cache-prefix: lint-${{ matrix.toolchain }}-v0
3032
- name: Run make check
3133
run: make check
3234
env:
@@ -42,18 +44,18 @@ jobs:
4244
runs-on: ${{ matrix.os }}
4345
strategy:
4446
matrix:
45-
os: [ubuntu-latest]
47+
os: [ubuntu-24.04]
4648
toolchain: [nightly]
4749
steps:
4850
- uses: actions/checkout@v5
4951
- name: Setup build dependencies
50-
run: |
51-
sudo apt update || true
52-
sudo apt install -y protobuf-compiler || true
53-
- uses: dtolnay/rust-toolchain@stable
52+
uses: ./.github/actions/setup-build-deps
53+
- name: Setup Rust
54+
uses: ./.github/actions/setup-rust
5455
with:
5556
toolchain: ${{ matrix.toolchain }}
5657
components: clippy, rustfmt
58+
cache-prefix: lint-tx-fuzzing-${{ matrix.toolchain }}-v0
5759
- name: Run transaction Fuzzing check
5860
run: make check-tx-fuzzing
5961

@@ -63,7 +65,7 @@ jobs:
6365
runs-on: ${{ matrix.os }}
6466
strategy:
6567
matrix:
66-
os: [ubuntu-latest]
68+
os: [ubuntu-24.04]
6769
steps:
6870
- uses: actions/checkout@v5
6971
- name: Install shellcheck
@@ -79,7 +81,7 @@ jobs:
7981
runs-on: ${{ matrix.os }}
8082
strategy:
8183
matrix:
82-
os: [ubuntu-latest]
84+
os: [ubuntu-24.04]
8385
steps:
8486
- uses: actions/checkout@v5
8587
- name: Install hadolint

.github/workflows/markdown-format.yml renamed to .github/workflows/markdown-format.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
markdown-format:
1010
name: Check Markdown Formatting
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- name: Checkout code
1414
uses: actions/checkout@v5

Makefile

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ build-release: ## Build the project in release mode
4545
build-testing: ## Build the testing binary with scenario generators
4646
cargo build --release --features scenario-generators --bin openmina-node-testing
4747

48+
.PHONY: build-tests
49+
build-tests: ## Build tests for scenario testing
50+
@mkdir -p target/release/tests
51+
@cargo build --release --tests \
52+
--package=openmina-node-testing \
53+
--package=cli
54+
@cargo build --release --tests \
55+
--package=openmina-node-testing \
56+
--package=cli \
57+
--message-format=json > cargo-build-test.json
58+
@jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' \
59+
cargo-build-test.json > tests.tsv
60+
@while read NAME FILE; do \
61+
cp -a $$FILE target/release/tests/$$NAME; \
62+
done < tests.tsv
63+
4864
.PHONY: build-tests-webrtc
4965
build-tests-webrtc: ## Build tests for WebRTC
5066
@mkdir -p target/release/tests
@@ -224,7 +240,7 @@ test-ledger: build-ledger ## Run ledger tests in release mode, requires nightly
224240

225241
.PHONY: test-p2p
226242
test-p2p: ## Run P2P tests
227-
cargo test -p p2p --tests
243+
cargo test -p p2p --tests --release
228244

229245
.PHONY: test-release
230246
test-release: ## Run tests in release mode
@@ -234,6 +250,26 @@ test-release: ## Run tests in release mode
234250
test-vrf: ## Run VRF tests, requires nightly Rust
235251
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
236252

253+
.PHONY: nextest
254+
nextest: ## Run tests with cargo-nextest for faster execution
255+
@cargo nextest run
256+
257+
.PHONY: nextest-release
258+
nextest-release: ## Run tests in release mode with cargo-nextest
259+
@cargo nextest run --release
260+
261+
.PHONY: nextest-p2p
262+
nextest-p2p: ## Run P2P tests with cargo-nextest
263+
@cargo nextest run -p p2p --tests
264+
265+
.PHONY: nextest-ledger
266+
nextest-ledger: build-ledger ## Run ledger tests with cargo-nextest, requires nightly Rust
267+
@cd ledger && cargo +nightly nextest run --release
268+
269+
.PHONY: nextest-vrf
270+
nextest-vrf: ## Run VRF tests with cargo-nextest, requires nightly Rust
271+
@cd vrf && cargo +nightly nextest run --release
272+
237273
# Docker build targets
238274

239275
.PHONY: docker-build-all

0 commit comments

Comments
 (0)