Skip to content

Commit 509d1dc

Browse files
authored
add(CI): Setup zebra build env (#10375)
* Refactor to use into_values and flatten * Replace println warning with tracing warn * Add GitHub Action to setup Zebra build environment * Install protoc in setup-zebra-build and remove arduino/setup-protoc
1 parent 79505cd commit 509d1dc

File tree

10 files changed

+43
-50
lines changed

10 files changed

+43
-50
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup Zebra Build Environment'
2+
description: 'Install protoc as system library'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Install protoc on Ubuntu
7+
if: runner.os == 'Linux'
8+
shell: bash
9+
run: |
10+
sudo apt-get -qq update
11+
sudo apt-get -qq install -y --no-install-recommends protobuf-compiler
12+
13+
- name: Install protoc on macOS
14+
if: runner.os == 'macOS'
15+
shell: bash
16+
run: |
17+
brew install protobuf
18+
19+
- name: Install protoc on Windows
20+
if: runner.os == 'Windows'
21+
shell: bash
22+
run: |
23+
choco install protoc -y

.github/workflows/book.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ jobs:
4444
mdbook-version: ~0.5
4545
use-linkcheck: true
4646
use-mermaid: true
47-
- name: Install last version of Protoc
48-
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
49-
with:
50-
repo-token: ${{ secrets.GITHUB_TOKEN }}
5147
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
5248
with:
5349
toolchain: nightly
5450
cache-on-failure: true
51+
- uses: ./.github/actions/setup-zebra-build
5552

5653
- name: Build Zebra book
5754
run: |

.github/workflows/coverage.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ jobs:
4141
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
4242
with:
4343
persist-credentials: false
44-
- name: Install last version of Protoc
45-
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
46-
with:
47-
repo-token: ${{ secrets.GITHUB_TOKEN }}
4844
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
4945
with:
5046
toolchain: stable
@@ -53,6 +49,7 @@ jobs:
5349
- uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
5450
with:
5551
tool: cargo-llvm-cov,nextest
52+
- uses: ./.github/actions/setup-zebra-build
5653
- name: Run coverage tests
5754
run: |
5855
cargo llvm-cov --no-report nextest

.github/workflows/lint.yml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ jobs:
6565
components: clippy
6666
toolchain: ${{ matrix.rust-version }}
6767
cache-on-failure: true
68-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
69-
with:
70-
repo-token: ${{ secrets.GITHUB_TOKEN }}
68+
- uses: ./.github/actions/setup-zebra-build
7169
- name: Run clippy
7270
run: cargo clippy ${{ matrix.args }} --features "${{ matrix.features }}"
7371

@@ -83,12 +81,10 @@ jobs:
8381
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
8482
with:
8583
cache-on-failure: true
86-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
87-
with:
88-
repo-token: ${{ secrets.GITHUB_TOKEN }}
8984
- uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
9085
with:
9186
tool: cargo-hack
87+
- uses: ./.github/actions/setup-zebra-build
9288
- run: cargo hack check --workspace
9389

9490
msrv:
@@ -106,13 +102,11 @@ jobs:
106102
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
107103
with:
108104
persist-credentials: false
109-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
110-
with:
111-
repo-token: ${{ secrets.GITHUB_TOKEN }}
112105
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
113106
with:
114107
toolchain: 1.89 # MSRV
115108
cache-on-failure: true
109+
- uses: ./.github/actions/setup-zebra-build
116110
- run: cargo build --bin "${{ matrix.binary }}" --workspace
117111

118112
docs:
@@ -125,14 +119,11 @@ jobs:
125119
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
126120
with:
127121
persist-credentials: false
128-
- name: Install last version of Protoc
129-
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
130-
with:
131-
repo-token: ${{ secrets.GITHUB_TOKEN }}
132122
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
133123
with:
134124
toolchain: nightly
135125
cache-on-failure: true
126+
- uses: ./.github/actions/setup-zebra-build
136127
- run: cargo doc --no-deps --workspace --all-features --document-private-items --target-dir "$(pwd)"/target/internal
137128
env:
138129
# Keep in sync with ./book.yml:jobs.build
@@ -168,17 +159,14 @@ jobs:
168159
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
169160
with:
170161
persist-credentials: false
171-
- name: Install last version of Protoc
172-
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
173-
with:
174-
repo-token: ${{ secrets.GITHUB_TOKEN }}
175162
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
176163
with:
177164
toolchain: nightly
178165
cache-on-failure: true
179166
- uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
180167
with:
181168
tool: cargo-udeps
169+
- uses: ./.github/actions/setup-zebra-build
182170
- run: cargo udeps --workspace --all-targets --all-features --locked
183171

184172
no-test-deps:
@@ -208,10 +196,6 @@ jobs:
208196
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
209197
with:
210198
persist-credentials: false
211-
- name: Install last version of Protoc
212-
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
213-
with:
214-
repo-token: ${{ secrets.GITHUB_TOKEN }}
215199
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c #v1.15.2
216200
with:
217201
toolchain: nightly
@@ -220,6 +204,7 @@ jobs:
220204
uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
221205
with:
222206
tool: cargo-hack
207+
- uses: ./.github/actions/setup-zebra-build
223208
- run: cargo hack check --all
224209
env:
225210
RUSTFLAGS: -D warnings
@@ -238,9 +223,7 @@ jobs:
238223
with:
239224
toolchain: stable
240225
cache-on-failure: true
241-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
242-
with:
243-
repo-token: ${{ secrets.GITHUB_TOKEN }}
226+
- uses: ./.github/actions/setup-zebra-build
244227
- run: cargo check --locked --all-features --all-targets
245228

246229
deny:

.github/workflows/test-crates.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
toolchain: stable
6161
components: clippy
6262
cache-on-failure: true
63+
- uses: ./.github/actions/setup-zebra-build
6364

6465
# This step dynamically creates a JSON containing the values of each crate
6566
# available in this repo in the root directory. We use `cargo tree` to accomplish this task.
@@ -113,9 +114,7 @@ jobs:
113114
cache-key: crate-build-${{ matrix.crate }}
114115
cache-on-failure: true
115116

116-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
117-
with:
118-
repo-token: ${{ secrets.GITHUB_TOKEN }}
117+
- uses: ./.github/actions/setup-zebra-build
119118

120119
# We could use `features: ['', '--all-features', '--no-default-features']` as a matrix argument,
121120
# but it's faster to run these commands sequentially, so they can re-use the local cargo cache.
@@ -176,9 +175,7 @@ jobs:
176175
cache-key: crate-build-msrv-${{ matrix.crate }}
177176
cache-on-failure: true
178177

179-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
180-
with:
181-
repo-token: ${{ secrets.GITHUB_TOKEN }}
178+
- uses: ./.github/actions/setup-zebra-build
182179

183180
- name: Build ${{ matrix.crate }} crate with MSRV, all features and all targets
184181
# zebrad can have a higher MSRV than the other crates since it is a binary, so we skip the MSRV build for it.

.github/workflows/tests-unit.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ jobs:
7171
- uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
7272
with:
7373
tool: cargo-nextest
74-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
75-
with:
76-
repo-token: ${{ secrets.GITHUB_TOKEN }}
77-
74+
- uses: ./.github/actions/setup-zebra-build
75+
7876
# Windows-specific setup
7977
- name: Install LLVM on Windows
8078
if: matrix.os == 'windows-latest'
@@ -117,9 +115,7 @@ jobs:
117115
- uses: taiki-e/install-action@305bebabd4457bed9b82541755f034994382465b #v2.68.10
118116
with:
119117
tool: cargo-nextest
120-
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b #v3.0.0
121-
with:
122-
repo-token: ${{ secrets.GITHUB_TOKEN }}
118+
- uses: ./.github/actions/setup-zebra-build
123119
- name: Check no git dependencies
124120
run: cargo nextest run --profile check-no-git-dependencies --locked --run-ignored=only
125121

zebra-consensus/src/primitives/groth16/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ async fn verify_sprout_groth16() {
7171

7272
let transactions = zebra_test::vectors::MAINNET_BLOCKS
7373
.clone()
74-
.iter()
75-
.flat_map(|(_, bytes)| {
74+
.into_values()
75+
.flat_map(|bytes| {
7676
let block = bytes
7777
.zcash_deserialize_into::<Block>()
7878
.expect("a valid block");

zebra-state/src/service/queued_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl QueuedBlocks {
140140
let mut by_height = self.by_height.split_off(&split_height);
141141
mem::swap(&mut self.by_height, &mut by_height);
142142

143-
for hash in by_height.into_iter().flat_map(|(_, hashes)| hashes) {
143+
for hash in by_height.into_values().flatten() {
144144
let (expired_block, expired_sender) =
145145
self.blocks.remove(&hash).expect("block is present");
146146
let parent_hash = &expired_block.block.header.previous_block_hash;

zebra-state/src/service/read/tests/vectors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ async fn any_chain_block_finds_side_chain_blocks() -> Result<()> {
478478
// If hashes are the same, we can't test side chains properly
479479
// This would mean our fake block generation isn't working as expected
480480
if best_hash == side_hash {
481-
println!("WARNING: Unable to create different block hashes, skipping side chain test");
481+
tracing::warn!("unable to create different block hashes, skipping side chain test");
482482
return Ok(());
483483
}
484484

zebrad/src/components/mempool/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777
while combined_changes <= MAX_CHANGES_BEFORE_SEND && txs.len() < max_tx_inv_in_message {
7878
match receiver.try_recv() {
7979
Ok(mempool_change) if mempool_change.is_added() => {
80-
txs.extend(mempool_change.into_tx_ids().into_iter())
80+
txs.extend(mempool_change.into_tx_ids())
8181
}
8282
Ok(_) => {
8383
// ignore other changes, we only want to gossip added transactions

0 commit comments

Comments
 (0)