ver 0.1
This commit is contained in:
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# smoke-test.sh — quick runtime self-test for the runner image
|
||||
# Run inside the container to validate the tool chain before production use.
|
||||
set -euo pipefail
|
||||
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
ok() { echo "[SMOKE] PASS : $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo "[SMOKE] FAIL : $1"; FAIL=$((FAIL + 1)); }
|
||||
|
||||
echo "======================================"
|
||||
echo " custom-gitea-runner smoke test"
|
||||
echo "======================================"
|
||||
|
||||
# Binary presence and basic execution
|
||||
for bin in bash curl git jq node npm act_runner tini docker; do
|
||||
if command -v "$bin" &>/dev/null; then
|
||||
ok "${bin} found: $(command -v "$bin")"
|
||||
else
|
||||
fail "${bin} not found"
|
||||
fi
|
||||
done
|
||||
|
||||
# Version output checks
|
||||
echo "--- versions ---"
|
||||
git --version && ok "git --version" || fail "git --version failed"
|
||||
node --version && ok "node --version" || fail "node --version failed"
|
||||
npm --version && ok "npm --version" || fail "npm --version failed"
|
||||
act_runner --version 2>&1 | head -1 && ok "act_runner --version" || fail "act_runner --version failed"
|
||||
docker --version && ok "docker --version" || fail "docker --version failed"
|
||||
|
||||
# Node.js can run a basic script
|
||||
if node -e "process.exit(0)" 2>/dev/null; then
|
||||
ok "node can execute scripts"
|
||||
else
|
||||
fail "node cannot execute scripts"
|
||||
fi
|
||||
|
||||
# jq parses JSON
|
||||
if echo '{"test":1}' | jq .test > /dev/null 2>&1; then
|
||||
ok "jq parses JSON"
|
||||
else
|
||||
fail "jq cannot parse JSON"
|
||||
fi
|
||||
|
||||
# curl is usable (don't actually make a request in smoke test)
|
||||
if curl --version &>/dev/null; then
|
||||
ok "curl is usable"
|
||||
else
|
||||
fail "curl is not usable"
|
||||
fi
|
||||
|
||||
echo "======================================"
|
||||
echo " Results: ${PASS} passed, ${FAIL} failed"
|
||||
echo "======================================"
|
||||
|
||||
[ "$FAIL" -eq 0 ] && exit 0 || exit 1
|
||||
Reference in New Issue
Block a user