forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
134 lines (118 loc) · 4.45 KB
/
justfile
File metadata and controls
134 lines (118 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
REPO_ROOT := `realpath ..` # path to the root of the optimism monorepo
# Default recipe - runs acceptance tests
default:
@just acceptance-test
# Run acceptance tests, optionally filtered by a gate (reads packages from gates/<gate>.txt)
acceptance-test gate="":
#!/usr/bin/env bash
set -euo pipefail
GATE="{{gate}}"
if [[ -n "$GATE" ]]; then
echo -e "DEVNET: in-memory, GATE: $GATE\n"
else
echo -e "DEVNET: in-memory, MODE: all tests\n"
fi
# Build dependencies for in-process mode if not in CI.
# In CI jobs already take care of this, so we skip it.
if [[ -z "${CIRCLECI:-}" ]]; then
echo "Building contracts (local build)..."
cd {{REPO_ROOT}}
echo " - Updating submodules..."
git submodule update --init --recursive --single-branch -j 8
echo " - Installing mise..."
mise install
cd packages/contracts-bedrock
echo " - Installing contracts..."
just install
echo " - Forge build..."
just build-no-tests
cd {{REPO_ROOT}}
echo "Checking cannon dependencies..."
if [ ! -e {{REPO_ROOT}}/cannon/bin/cannon ] || [ ! -e {{REPO_ROOT}}/op-program/bin/prestate-mt64.bin.gz ]; then
echo "Building cannon dependencies..."
cd {{REPO_ROOT}}
make cannon-prestates
fi
echo "Building Rust binaries (kona-node, op-rbuilder, rollup-boost)..."
cd {{REPO_ROOT}}
just build-rust-release
fi
LOG_LEVEL="$(echo "${LOG_LEVEL:-info}" | grep -E '^(debug|info|warn|error)$' || echo 'info')"
echo "LOG_LEVEL: $LOG_LEVEL"
CPU_COUNT=""
if command -v nproc >/dev/null 2>&1; then
CPU_COUNT="$(nproc)"
elif command -v getconf >/dev/null 2>&1; then
CPU_COUNT="$(getconf _NPROCESSORS_ONLN)"
elif command -v sysctl >/dev/null 2>&1; then
CPU_COUNT="$(sysctl -n hw.ncpu)"
fi
if [[ -z "$CPU_COUNT" || "$CPU_COUNT" -lt 1 ]]; then
CPU_COUNT=1
fi
DEFAULT_JOBS="$CPU_COUNT"
DEFAULT_TEST_PARALLEL="$(( CPU_COUNT / 2 ))"
if [[ "$DEFAULT_TEST_PARALLEL" -lt 1 ]]; then
DEFAULT_TEST_PARALLEL=1
fi
JOBS="${ACCEPTANCE_TEST_JOBS:-$DEFAULT_JOBS}"
TEST_PARALLEL="${ACCEPTANCE_TEST_PARALLEL:-$DEFAULT_TEST_PARALLEL}"
TEST_TIMEOUT="${ACCEPTANCE_TEST_TIMEOUT:-2h}"
echo "CPU COUNT: $CPU_COUNT"
echo "PACKAGE JOBS: $JOBS"
echo "TEST PARALLELISM: $TEST_PARALLEL"
echo "PACKAGE TIMEOUT: $TEST_TIMEOUT"
cd {{REPO_ROOT}}
if ! command -v gotestsum >/dev/null; then
echo "error: gotestsum is required for acceptance-test runs." >&2
exit 1
fi
LOG_ROOT="{{REPO_ROOT}}/op-acceptance-tests/logs"
RESULTS_DIR="{{REPO_ROOT}}/op-acceptance-tests/results"
mkdir -p "$LOG_ROOT" "$RESULTS_DIR"
LOG_DIR="$LOG_ROOT/testrun-$(date -u +%Y%m%d-%H%M%S)"
mkdir -p "$LOG_DIR/failed"
rm -f "$RESULTS_DIR/results.xml"
FLAKY_REPORT="$LOG_DIR/flaky-tests.txt"
if command -v rg >/dev/null 2>&1; then
rg -n "MarkFlaky\\(" ./op-acceptance-tests/tests > "$FLAKY_REPORT" || true
else
grep -RIn "MarkFlaky(" ./op-acceptance-tests/tests > "$FLAKY_REPORT" || true
fi
# Determine which packages to test
if [[ -n "$GATE" ]]; then
GATE_FILE="{{REPO_ROOT}}/op-acceptance-tests/gates/${GATE}.txt"
if [[ ! -f "$GATE_FILE" ]]; then
echo "error: gate file not found: $GATE_FILE" >&2
exit 1
fi
# Read non-empty, non-comment lines from the gate file
TEST_PACKAGES=()
while IFS= read -r line; do
line="${line%%#*}" # strip comments
line="${line// /}" # strip whitespace
[[ -z "$line" ]] && continue
TEST_PACKAGES+=("$line")
done < "$GATE_FILE"
echo "Gate '$GATE': ${#TEST_PACKAGES[@]} packages"
else
TEST_PACKAGES=("./op-acceptance-tests/tests/...")
fi
set +e
LOG_LEVEL="${LOG_LEVEL}" {{REPO_ROOT}}/ops/scripts/gotestsum-split.sh \
--format testname \
--junitfile "$RESULTS_DIR/results.xml" \
--jsonfile "$LOG_DIR/raw_go_events.log" \
-- \
-count=1 \
-p "${JOBS}" \
-parallel "${TEST_PARALLEL}" \
-timeout "${TEST_TIMEOUT}" \
"${TEST_PACKAGES[@]}" \
2>&1 | tee "$LOG_DIR/all.log"
TEST_STATUS=${PIPESTATUS[0]}
set -e
cp "$LOG_DIR/all.log" "$LOG_DIR/summary.log"
exit "$TEST_STATUS"
clean:
rm -rf tests/interop/loadtest/artifacts