-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaction.yaml
More file actions
339 lines (285 loc) · 12.9 KB
/
Copy pathaction.yaml
File metadata and controls
339 lines (285 loc) · 12.9 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: 'Benchmarkoor'
description: 'Run Ethereum execution client benchmarks using benchmarkoor'
author: 'ethpandaops'
branding:
icon: 'activity'
color: 'gray-dark'
inputs:
github-token:
description: 'GitHub token for API access'
required: true
mode:
description: 'Which phase(s) to run: "all" (build if a build-config is set, then run — the default), "build" (build only, no run), or "run" (run only, skip build even if a build-config is set).'
required: false
default: 'all'
image:
description: 'Docker image to extract the benchmarkoor binary from (e.g., ghcr.io/ethpandaops/benchmarkoor:master). If not provided, will build the image locally from git-ref/git-repo and extract from it.'
required: false
default: ''
git-ref:
description: 'Git branch or commit hash to build from. Only used when image is not provided. Defaults to master.'
required: false
default: ''
git-repo:
description: 'Git repository URL to clone for building the image. Only used when image is not provided. Defaults to ethpandaops/benchmarkoor.'
required: false
default: 'https://github.com/ethpandaops/benchmarkoor.git'
upload-artifacts:
description: 'Whether to upload run results as GitHub artifacts'
required: false
default: 'false'
run-config-urls:
description: 'Comma-separated URLs for config files to download and pass via --config (merged in order)'
required: false
default: ''
run-config:
description: 'Raw YAML config content to pass via --config (appended after URL config)'
required: false
default: ''
run-args:
description: 'Extra flags passed to benchmarkoor run command'
required: false
default: ''
build-config-urls:
description: 'Comma-separated URLs for config files to download and pass to `benchmarkoor build` via --config (merged in order). Setting this or build-config enables the build phase (state-actor snapshots + eest payloads), which runs before the benchmark run.'
required: false
default: ''
build-config:
description: 'Raw YAML config content to pass to `benchmarkoor build` via --config (appended after URL config). Setting this or build-config-urls enables the build phase.'
required: false
default: ''
build-args:
description: 'Extra flags passed to the benchmarkoor build command (e.g. --force, --limit-state-actor-target=)'
required: false
default: ''
tmp-dir:
description: 'Temporary directory path used for benchmarkoor data (overlayfs) and cache'
required: false
default: '/tmp'
runs:
using: 'composite'
steps:
- name: Validate mode
shell: bash
run: |
case "${{ inputs.mode }}" in
all|build|run) ;;
*) echo "Invalid mode '${{ inputs.mode }}' (expected: all, build, or run)" >&2; exit 1 ;;
esac
- name: Verify and install dependencies
uses: ethpandaops/benchmarkoor/.github/actions/dependencies@0ff45ea539387c901ac4a7845e2c6e6aeb9d8f25
- name: Build Docker image locally
if: inputs.image == ''
shell: bash
run: |
GIT_REF="${{ inputs.git-ref }}"
if [ -z "$GIT_REF" ]; then
GIT_REF="master"
fi
GIT_REPO="${{ inputs.git-repo }}"
echo "Cloning ${GIT_REPO} at ref $GIT_REF"
git clone "${GIT_REPO}" benchmarkoor-build
cd benchmarkoor-build
git checkout "$GIT_REF"
echo "Building Docker image..."
docker build -t benchmarkoor:local .
cd ..
rm -rf benchmarkoor-build
- name: Extract benchmarkoor binary
id: extract-binary
shell: bash
run: |
if [ -n "${{ inputs.image }}" ]; then
IMAGE="${{ inputs.image }}"
echo "Pulling Docker image to extract binary: ${IMAGE}"
docker pull "${IMAGE}" || {
echo "Failed to pull Docker image: ${IMAGE}"
exit 1
}
else
IMAGE="benchmarkoor:local"
echo "Using locally built image: ${IMAGE}"
fi
BIN="${{ runner.temp }}/benchmarkoor"
# docker create + docker cp gives us the binary owned by the
# runner user without needing a writable bind-mount or matching
# uid inside the container.
cid=$(docker create "${IMAGE}")
trap "docker rm -f \"$cid\" >/dev/null 2>&1 || true" EXIT
docker cp "$cid:/usr/local/bin/benchmarkoor" "$BIN"
chmod +x "$BIN"
echo "Extracted binary to $BIN"
"$BIN" --version || true
echo "binary=${BIN}" >> "$GITHUB_OUTPUT"
- name: Build Benchmarkoor artifacts
id: build-benchmarkoor
if: (inputs.mode == 'all' || inputs.mode == 'build') && (inputs.build-config != '' || inputs.build-config-urls != '')
shell: bash
env:
INPUT_BUILD_CONFIG: ${{ inputs.build-config }}
INPUT_BUILD_CONFIG_URLS: ${{ inputs.build-config-urls }}
run: |
BIN="${{ steps.extract-binary.outputs.binary }}"
# Download URL configs if provided (comma-separated)
if [ -n "$INPUT_BUILD_CONFIG_URLS" ]; then
IFS=',' read -ra CONFIG_URLS <<< "$INPUT_BUILD_CONFIG_URLS"
for i in "${!CONFIG_URLS[@]}"; do
URL=$(echo "${CONFIG_URLS[$i]}" | xargs) # trim whitespace
echo "Downloading build config from ${URL}"
curl -fsSL "${URL}" -o "${{ runner.temp }}/benchmarkoor-build-config-url-${i}.yaml"
done
fi
# Write inline config if provided
if [ -n "$INPUT_BUILD_CONFIG" ]; then
echo "$INPUT_BUILD_CONFIG" > "${{ runner.temp }}/benchmarkoor-build-config-inline.yaml"
fi
# Build argv as an array so quoted values survive intact. Config files
# apply in order: URL configs, then inline config (last wins). This step
# runs from the workspace, so any relative paths in the config (e.g. a
# custom fill_dockerfile) resolve against the checkout.
ARGS=("build")
for cfg in "${{ runner.temp }}"/benchmarkoor-build-config-url-*.yaml; do
[ -f "$cfg" ] && ARGS+=("--config=$cfg")
done
if [ -f "${{ runner.temp }}/benchmarkoor-build-config-inline.yaml" ]; then
ARGS+=("--config=${{ runner.temp }}/benchmarkoor-build-config-inline.yaml")
fi
# Append extra build args if provided (whitespace-split, same as run).
if [ -n "${{ inputs.build-args }}" ]; then
# shellcheck disable=SC2206 # intentional word-split for argv
EXTRA_ARGS=(${{ inputs.build-args }})
ARGS+=("${EXTRA_ARGS[@]}")
fi
# `sudo -E` for the same reasons as the run step: keeps the built
# snapshots/fixtures root-owned (so the rootful run phase can read
# them) and propagates caller env (e.g. STATE_DIR) into the build.
echo "Running: sudo -E $BIN ${ARGS[*]}"
sudo -E "$BIN" "${ARGS[@]}"
- name: Get Job ID from GH API
id: get-job-id
if: inputs.mode == 'all' || inputs.mode == 'run'
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
jobs=$(gh api -F per_page=100 -X GET repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs)
job_id=$(echo "$jobs" | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}" and .status=="in_progress") | .id')
echo "job_id=${job_id}" >> "$GITHUB_OUTPUT"
- name: Run Benchmarkoor
id: run-benchmarkoor
if: inputs.mode == 'all' || inputs.mode == 'run'
shell: bash
env:
INPUT_RUN_CONFIG: ${{ inputs.run-config }}
INPUT_RUN_CONFIG_URLS: ${{ inputs.run-config-urls }}
run: |
BIN="${{ steps.extract-binary.outputs.binary }}"
mkdir -p "${{ runner.temp }}/results"
# Download URL configs if provided (comma-separated)
if [ -n "$INPUT_RUN_CONFIG_URLS" ]; then
IFS=',' read -ra CONFIG_URLS <<< "$INPUT_RUN_CONFIG_URLS"
for i in "${!CONFIG_URLS[@]}"; do
URL=$(echo "${CONFIG_URLS[$i]}" | xargs) # trim whitespace
echo "Downloading config from ${URL}"
curl -fsSL "${URL}" -o "${{ runner.temp }}/benchmarkoor-config-url-${i}.yaml"
done
fi
# Write inline config if provided
if [ -n "$INPUT_RUN_CONFIG" ]; then
echo "$INPUT_RUN_CONFIG" > "${{ runner.temp }}/benchmarkoor-config-inline.yaml"
fi
# Export benchmarkoor's own config env vars. Anything the caller
# set via `env:` on the action step is already in our process
# environment; `sudo -E` below propagates both sets to the
# benchmarkoor process (which it needs to be: root, for
# drop_memory_caches, schelk dm_era ops, rootful podman, etc.).
export BENCHMARKOOR_RUNNER_GITHUB_TOKEN="${{ inputs.github-token }}"
export BENCHMARKOOR_RUNNER_BENCHMARK_RESULTS_DIR="${{ runner.temp }}/results"
export BENCHMARKOOR_RUNNER_BENCHMARK_RESULTS_OWNER="$(id -u):$(id -g)"
export BENCHMARKOOR_RUNNER_DIRECTORIES_TMP_DATADIR="${{ inputs.tmp-dir }}"
export BENCHMARKOOR_RUNNER_DIRECTORIES_TMP_CACHEDIR="${{ inputs.tmp-dir }}/benchmarkoor-cache"
# Build argv as an array so quoted values survive intact.
ARGS=("run")
# Add config files in order: URL configs, then inline config (last wins).
for cfg in "${{ runner.temp }}"/benchmarkoor-config-url-*.yaml; do
[ -f "$cfg" ] && ARGS+=("--config=$cfg")
done
if [ -f "${{ runner.temp }}/benchmarkoor-config-inline.yaml" ]; then
ARGS+=("--config=${{ runner.temp }}/benchmarkoor-config-inline.yaml")
fi
# GitHub Actions context as metadata labels.
ARGS+=(
"--metadata.label=github.run_id=${{ github.run_id }}"
"--metadata.label=github.run_number=${{ github.run_number }}"
"--metadata.label=github.job=${{ github.job }}"
"--metadata.label=github.job_id=${{ steps.get-job-id.outputs.job_id }}"
"--metadata.label=github.repository=${{ github.repository }}"
"--metadata.label=github.workflow=${{ github.workflow }}"
"--metadata.label=github.sha=${{ github.sha }}"
"--metadata.label=github.actor=${{ github.actor }}"
"--metadata.label=github.event_name=${{ github.event_name }}"
"--metadata.label=github.ref=${{ github.ref }}"
)
# Append extra run args if provided (whitespace-split, same as before).
if [ -n "${{ inputs.run-args }}" ]; then
# shellcheck disable=SC2206 # intentional word-split for argv
EXTRA_ARGS=(${{ inputs.run-args }})
ARGS+=("${EXTRA_ARGS[@]}")
fi
echo "Running: sudo -E $BIN ${ARGS[*]}"
set +e
sudo -E "$BIN" "${ARGS[@]}"
EXIT_CODE=$?
set -e
# Find run directories
RUN_DIRS=""
if [ -d "${{ runner.temp }}/results/runs" ]; then
RUN_DIRS=$(find "${{ runner.temp }}/results/runs" -mindepth 1 -maxdepth 1 -type d | sort | tr '\n' ' ')
fi
echo "run-dirs=${RUN_DIRS}" >> "$GITHUB_OUTPUT"
if [ $EXIT_CODE -ne 0 ]; then
echo "Benchmarkoor failed with exit code $EXIT_CODE"
exit $EXIT_CODE
fi
echo "Benchmarkoor completed successfully"
- name: Generate markdown summaries
if: always() && steps.run-benchmarkoor.outputs.run-dirs != ''
shell: bash
run: |
BIN="${{ steps.extract-binary.outputs.binary }}"
for RUN_DIR_HOST in ${{ steps.run-benchmarkoor.outputs.run-dirs }}; do
RUN_DIR_NAME=$(basename "$RUN_DIR_HOST")
echo "Generating summary for ${RUN_DIR_NAME}"
"$BIN" generate-markdown-summary \
--run-dir="${RUN_DIR_HOST}" \
--output="${RUN_DIR_HOST}/summary.md"
if [ -f "${RUN_DIR_HOST}/summary.md" ]; then
cat "${RUN_DIR_HOST}/summary.md" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
fi
done
- name: Create results archive
if: always() && inputs.upload-artifacts == 'true' && inputs.mode != 'build'
shell: bash
run: |
if [ -d "${{ runner.temp }}/results" ]; then
tar -czf "${{ runner.temp }}/benchmarkoor-results.tar.gz" -C "${{ runner.temp }}" results
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always() && inputs.upload-artifacts == 'true' && inputs.mode != 'build'
with:
name: benchmarkoor-${{ github.run_id }}
path: ${{ runner.temp }}/benchmarkoor-results.tar.gz
- name: Cleanup
shell: bash
if: always()
run: |
echo "Cleaning up"
rm -rf "${{ runner.temp }}/results"
rm -f "${{ runner.temp }}/benchmarkoor-config-url-"*.yaml
rm -f "${{ runner.temp }}/benchmarkoor-config-inline.yaml"
rm -f "${{ runner.temp }}/benchmarkoor-build-config-url-"*.yaml
rm -f "${{ runner.temp }}/benchmarkoor-build-config-inline.yaml"
rm -f "${{ runner.temp }}/benchmarkoor-results.tar.gz"
rm -f "${{ runner.temp }}/benchmarkoor"