Skip to content

Commit 5a3ef38

Browse files
committed
make prefork network as a configurable argument
1 parent f0c04ba commit 5a3ef38

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

buildkite/src/Jobs/Test/HardForkTest.dhall

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ in Pipeline.build
5454
, privileged = True
5555
, useBash = False
5656
}
57-
"./scripts/hardfork/build-and-test.sh"
57+
"./scripts/hardfork/build-and-test.sh --fork-from origin/master"
5858
]
59-
, label = "hard fork test"
60-
, key = "hard-fork-test"
59+
, label = "hard fork test - legacy mode"
60+
, key = "hard-fork-test-legacy"
6161
, target = Size.Integration
6262
, soft_fail = Some (B/SoftFail.Boolean False)
6363
, docker = None Docker.Type

scripts/hardfork/build-and-test.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
# This scripts builds master and current branch with nix
3+
# This scripts builds a designated PREFORK branch and current branch with nix
44
# 0. Prepare environment if needed
5-
# 1. Build master as a prefork build;
5+
# 1. Build PREFORK as a prefork build;
66
# 2. Upload to nix cache, the reason for not uploading cache for following 2
77
# steps is that they change for each PR.
88
# 3. Build current branch as a postfork build;
@@ -12,6 +12,45 @@
1212
# Step 0. Prepare environment if needed
1313
set -eux -o pipefail
1414

15+
PREFORK=""
16+
17+
usage() {
18+
echo "Usage: $0 --fork-from <PREFORK>"
19+
exit 1
20+
}
21+
22+
# ---- argument parsing --------------------------------------------------------
23+
while [[ $# -gt 0 ]]; do
24+
case "$1" in
25+
--fork-from)
26+
# ensure value exists
27+
if [[ $# -lt 2 ]]; then
28+
echo "Error: --fork-from requires an argument."
29+
usage
30+
fi
31+
PREFORK="$2"
32+
shift 2
33+
;;
34+
--help|-h)
35+
usage
36+
;;
37+
--*)
38+
echo "Unknown option: $1"
39+
usage
40+
;;
41+
*)
42+
# positional arg — store if needed later
43+
echo "Unexpected argument: $1"
44+
usage
45+
;;
46+
esac
47+
done
48+
49+
if [[ -z "$PREFORK" ]]; then
50+
echo "Error: --fork-from must be provided."
51+
usage
52+
fi
53+
1554
NIX_OPTS=( --accept-flake-config --experimental-features 'nix-command flakes' )
1655

1756
if [[ -n "${NIX_CACHE_NAR_SECRET:-}" ]]; then
@@ -70,8 +109,8 @@ if [ -n "${BUILDKITE:-}" ]; then
70109
git fetch origin
71110
fi
72111

73-
# 1. Build master as a prefork build;
74-
git checkout origin/master
112+
# 1. Build PREFORK as a prefork build;
113+
git checkout $PREFORK
75114
git submodule update --init --recursive --depth 1
76115
nix "${NIX_OPTS[@]}" build "$PWD?submodules=1#devnet" --out-link "prefork-devnet"
77116

0 commit comments

Comments
 (0)