The job token cannot read daniel/gitdan-crates, so CI authenticates with a read-only deploy key. The action writes it 0600 outside the workspace, pins the forge's host key (RSA, the only type offered, confirmed against the trusted known_hosts record and a fresh keyscan), exports GIT_SSH_COMMAND, proves access with ls-remote, and fails on a Cargo.lock with two commits of the crates repo. The selftest is wired into selftest.sh. Existing actions and scripts are untouched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MfBCVNDv3y5gm2djeZSAk4
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs every selftest in this directory and reports a single verdict.
|
|
#
|
|
# bash scripts/selftest.sh # everything
|
|
# bash scripts/selftest.sh --fast # skip the ones that invoke a compiler
|
|
#
|
|
# The compiler-backed tests (hardlink-clone, restore-mtimes) are the ones that
|
|
# verify behaviour against real Cargo rather than against a fixture, so
|
|
# --fast is for iterating, not for signing off a change.
|
|
set -uo pipefail
|
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
FAST=0
|
|
[ "${1:-}" = "--fast" ] && FAST=1
|
|
|
|
FIXTURE_TESTS=(cache-root-selftest.sh seed-target-dir-selftest.sh publish-snapshot-selftest.sh prune-cache-selftest.sh release-v1-selftest.sh crates-access-selftest.sh)
|
|
CARGO_TESTS=(hardlink-clone-selftest.sh restore-mtimes-selftest.sh)
|
|
|
|
TESTS=("${FIXTURE_TESTS[@]}")
|
|
if [ "$FAST" = "0" ]; then TESTS+=("${CARGO_TESTS[@]}"); fi
|
|
|
|
failed=()
|
|
for t in "${TESTS[@]}"; do
|
|
echo
|
|
echo "############################################################"
|
|
echo "# $t"
|
|
echo "############################################################"
|
|
if bash "$script_dir/$t"; then
|
|
echo "--> $t OK"
|
|
else
|
|
echo "--> $t FAILED"
|
|
failed+=("$t")
|
|
fi
|
|
done
|
|
|
|
echo
|
|
if [ "${#failed[@]}" -eq 0 ]; then
|
|
echo "selftest: all ${#TESTS[@]} suites passed"
|
|
[ "$FAST" = "1" ] && echo "NOTE: --fast skipped ${CARGO_TESTS[*]}"
|
|
exit 0
|
|
fi
|
|
echo "selftest: ${#failed[@]} of ${#TESTS[@]} suites FAILED: ${failed[*]}"
|
|
exit 1
|