Files
lighthouse/testing/ef_tests/download_test_vectors.sh
Justin Traglia 2f807e21be Add support for nightly tests (#7538)
This PR adds the ability to download [nightly reference tests from the consensus-specs repo](https://github.com/ethereum/consensus-specs/actions/workflows/generate_vectors.yml). This will be used by spec maintainers to ensure that there are no unexpected test failures prior to new releases. Also, we will keep track of test compliance with [this website](https://jtraglia.github.io/nyx/); eventually this will be integrated into Hive.


  * A new script (`download_test_vectors.sh`) is added to handle downloads.
* The logic for downloading GitHub artifacts is a bit complex.
* Rename the variables which store test versions:
* `TESTS_TAG` to `CONSENSUS_SPECS_TEST_VERSION`.
* `BLS_TEST_TAG` to `BLS_TEST_VERSION`, for consistency.
* Delete tarballs after extracting them.
* I see no need to keep these; they just use extra disk.
* Consolidate `clean` rules into a single rule.
* Do `clean` prior to downloading/extracting tests.
* Remove `CURL` variable with GitHub token; don't need it for downloading releases.
* Do `mkdir -p` when creating directories.
* Probably more small stuff...
2025-06-05 12:28:06 +00:00

69 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
TESTS=("general" "minimal" "mainnet")
version=${1}
if [[ "$version" == "nightly" ]]; then
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
echo "Error GITHUB_TOKEN is not set"
exit 1
fi
for cmd in unzip jq; do
if ! command -v "${cmd}" >/dev/null 2>&1; then
echo "Error ${cmd} is not installed"
exit 1
fi
done
repo="ethereum/consensus-specs"
api="https://api.github.com"
auth_header="Authorization: token ${GITHUB_TOKEN}"
run_id=$(curl -s -H "${auth_header}" \
"${api}/repos/${repo}/actions/workflows/generate_vectors.yml/runs?branch=dev&status=success&per_page=1" |
jq -r '.workflow_runs[0].id')
if [[ "${run_id}" == "null" || -z "${run_id}" ]]; then
echo "No successful nightly workflow run found"
exit 1
fi
echo "Downloading nightly test vectors for run: ${run_id}"
curl -s -H "${auth_header}" "${api}/repos/${repo}/actions/runs/${run_id}/artifacts" |
jq -c '.artifacts[] | {name, url: .archive_download_url}' |
while read -r artifact; do
name=$(echo "${artifact}" | jq -r .name)
url=$(echo "${artifact}" | jq -r .url)
if [[ "$name" == "consensustestgen.log" ]]; then
continue
fi
echo "Downloading artifact: ${name}"
curl --progress-bar --location --show-error --retry 3 --retry-all-errors --fail \
-H "${auth_header}" -H "Accept: application/vnd.github+json" \
--output "${name}.zip" "${url}" || {
echo "Failed to download ${name}"
exit 1
}
unzip -qo "${name}.zip"
rm -f "${name}.zip"
done
else
for test in "${TESTS[@]}"; do
if [[ ! -e "${test}.tar.gz" ]]; then
echo "Downloading: ${version}/${test}.tar.gz"
curl --progress-bar --location --remote-name --show-error --retry 3 --retry-all-errors --fail \
"https://github.com/ethereum/consensus-spec-tests/releases/download/${version}/${test}.tar.gz" \
|| {
echo "Curl failed. Aborting"
rm -f "${test}.tar.gz"
exit 1
}
fi
done
fi