Skip to content

Commit 012d30a

Browse files
committed
Fix sudo on CI.
1 parent 23b6147 commit 012d30a

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ jobs:
140140
- name: Install Foundry
141141
uses: foundry-rs/foundry-toolchain@v1
142142
- name: Run network simulation
143-
run: |
144-
just forward-ipv4 true
145-
just create-net
146-
just netsim
143+
run: just forward-ipv4 true create-net netsim
147144

148145
contracts:
149146
runs-on: ubuntu-latest

justfile

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
set export
2-
31
export RUSTDOCFLAGS := '-D warnings'
42

5-
LOG_LEVELS := "RUST_LOG=timeboost=debug,sailfish=debug,cliquenet=debug,tests=debug"
6-
7-
run_as_root := if env("CI", "false") == "true" { "sudo" } else { "run0" }
3+
log_levels := "RUST_LOG=timeboost=debug,sailfish=debug,cliquenet=debug,tests=debug"
4+
run_as_root := if env("CI", "") == "true" { "sudo" } else { "run0" }
85

96
####################
107
###BUILD COMMANDS###
@@ -156,10 +153,10 @@ test-contracts: build-contracts
156153
forge test
157154

158155
test_ci *ARGS: build-port-alloc
159-
env {{LOG_LEVELS}} NO_COLOR=1 target/release/run \
156+
env {{log_levels}} NO_COLOR=1 target/release/run \
160157
--spawn target/release/port-alloc \
161158
cargo nextest run -- --workspace {{ARGS}}
162-
env {{LOG_LEVELS}} NO_COLOR=1 cargo test --doc {{ARGS}}
159+
env {{log_levels}} NO_COLOR=1 cargo test --doc {{ARGS}}
163160

164161
test-individually: build-port-alloc
165162
@for pkg in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name'); do \
@@ -185,30 +182,43 @@ test-all: build_release build-test-utils
185182
--spawn "5:target/release/run-committee -c test-configs/local/ -t target/release/timeboost" \
186183
target/release/block-checker -- -c test-configs/local -b 1000
187184

185+
[linux]
188186
forward-ipv4 val: build-test-utils
189187
{{run_as_root}} target/release/net-setup system --forward-ipv4 {{val}}
190188

189+
[linux]
191190
create-net: build-test-utils
192191
{{run_as_root}} target/release/net-setup create -c test-configs/linux/net.toml
193192

193+
[linux]
194194
delete-net: build-test-utils
195195
{{run_as_root}} target/release/net-setup delete -c test-configs/linux/net.toml
196196

197+
[linux]
197198
netsim: build_release build-test-utils
198-
env RUST_LOG=timeboost_builder::submit=debug,block_checker=info,warn \
199-
{{run_as_root}} --setenv=PATH --setenv=HOME --setenv=RUST_LOG target/release/run \
200-
--verbose \
201-
--timeout 120 \
202-
--clear-env \
203-
--env PATH \
204-
--env HOME \
205-
--env RUST_LOG \
206-
--uid `id -u` \
207-
--gid `id -g` \
208-
--spawn "1:anvil --host 10.0.1.0 --port 8545" \
209-
--run "2:sleep 3" \
210-
--run "3:scripts/deploy-test-contract test-configs/linux/committee.toml http://10.0.1.0:8545" \
211-
--spawn "4:target/release/block-maker --bind 10.0.1.0:55000 -c test-configs/linux/committee.toml" \
212-
--spawn "4:target/release/yapper -c test-configs/linux/committee.toml" \
213-
--spawn-as-root "5:target/release/run-committee -u `id -u` -g `id -g` -c test-configs/linux/ -t target/release/timeboost" \
214-
target/release/block-checker -- -c test-configs/linux -b 200
199+
#!/usr/bin/env bash
200+
set -eo pipefail
201+
function run_as_root {
202+
if [ "$CI" == "true" ]; then
203+
sudo "$@"
204+
else
205+
run0 --setenv=PATH --setenv=HOME --setenv=RUST_LOG "$@"
206+
fi
207+
}
208+
export RUST_LOG=timeboost_builder::submit=debug,block_checker=info,warn
209+
run_as_root target/release/run \
210+
--verbose \
211+
--timeout 120 \
212+
--clear-env \
213+
--env PATH \
214+
--env HOME \
215+
--env RUST_LOG \
216+
--uid $(id -u) \
217+
--gid $(id -g) \
218+
--spawn "1:anvil --host 10.0.1.0 --port 8545" \
219+
--run "2:sleep 3" \
220+
--run "3:scripts/deploy-test-contract test-configs/linux/committee.toml http://10.0.1.0:8545" \
221+
--spawn "4:target/release/block-maker --bind 10.0.1.0:55000 -c test-configs/linux/committee.toml" \
222+
--spawn "4:target/release/yapper -c test-configs/linux/committee.toml" \
223+
--spawn-as-root "5:target/release/run-committee -u $(id -u) -g $(id -g) -c test-configs/linux/ -t target/release/timeboost" \
224+
target/release/block-checker -- -c test-configs/linux -b 200

0 commit comments

Comments
 (0)