|
#!/usr/bin/env bash |
|
set -euo pipefail |
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
SOURCE_DIR="${WORKFLOW_SOURCE_DIR:-$ROOT_DIR}" |
|
|
|
if [ -f "$SOURCE_DIR/pr-preview-package.yml" ]; then |
|
PR_WORKFLOW="$SOURCE_DIR/pr-preview-package.yml" |
|
MAIN_WORKFLOW="$SOURCE_DIR/main-snapshot-package.yml" |
|
RELEASE_WORKFLOW="$SOURCE_DIR/release-package.yml" |
|
elif [ -f "$SOURCE_DIR/.github/workflows/pr-preview-package.yml" ]; then |
|
PR_WORKFLOW="$SOURCE_DIR/.github/workflows/pr-preview-package.yml" |
|
MAIN_WORKFLOW="$SOURCE_DIR/.github/workflows/main-snapshot-package.yml" |
|
RELEASE_WORKFLOW="$SOURCE_DIR/.github/workflows/release-package.yml" |
|
else |
|
echo "Could not find workflow templates in $SOURCE_DIR." >&2 |
|
echo "Run from the gist clone, or set WORKFLOW_SOURCE_DIR to a repo/workflow directory." >&2 |
|
exit 1 |
|
fi |
|
|
|
ACT_BIN="${ACT_BIN:-act}" |
|
ACTIONLINT_BIN="${ACTIONLINT_BIN:-actionlint}" |
|
ACT_IMAGE="${ACT_IMAGE:-ghcr.io/catthehacker/ubuntu:act-22.04}" |
|
ACT_ARCH="${ACT_ARCH:-linux/arm64}" |
|
TEST_ROOT="${TEST_ROOT:-$ROOT_DIR/.pkg-preview-workflow-test}" |
|
KEEP_TEST_ROOT="${KEEP_TEST_ROOT:-0}" |
|
MOCK_GITHUB_API_PORT="${MOCK_GITHUB_API_PORT:-18080}" |
|
|
|
require_tool() { |
|
if ! command -v "$1" >/dev/null 2>&1; then |
|
echo "Missing required tool: $1" >&2 |
|
exit 1 |
|
fi |
|
} |
|
|
|
require_tool git |
|
require_tool node |
|
require_tool npm |
|
require_tool "$ACT_BIN" |
|
require_tool "$ACTIONLINT_BIN" |
|
|
|
echo "Security note: this harness runs workflow commands locally through act --bind. Only run it against workflow templates you trust." |
|
|
|
cleanup() { |
|
if [ "$KEEP_TEST_ROOT" != "1" ]; then |
|
rm -rf "$TEST_ROOT" |
|
else |
|
echo "Kept test root: $TEST_ROOT" |
|
fi |
|
} |
|
trap cleanup EXIT |
|
|
|
rm -rf "$TEST_ROOT" |
|
mkdir -p "$TEST_ROOT/fixture/.github/workflows" "$TEST_ROOT/fixture/.github/events" "$TEST_ROOT/fixture/mock-bin" "$TEST_ROOT/logs" "$TEST_ROOT/artifacts" |
|
|
|
cp "$PR_WORKFLOW" "$TEST_ROOT/fixture/.github/workflows/pr-preview-package.yml" |
|
cp "$MAIN_WORKFLOW" "$TEST_ROOT/fixture/.github/workflows/main-snapshot-package.yml" |
|
cp "$RELEASE_WORKFLOW" "$TEST_ROOT/fixture/.github/workflows/release-package.yml" |
|
|
|
cat > "$TEST_ROOT/fixture/package.json" <<'JSON' |
|
{ |
|
"name": "@patrickjs/pkg-preview-fixture", |
|
"version": "1.2.3", |
|
"repository": "https://github.com/PatrickJS/pkg-preview-fixture", |
|
"scripts": { |
|
"build": "node -e \"console.log('build ok')\"", |
|
"test": "node -e \"console.log('test ok')\"" |
|
}, |
|
"publishConfig": { |
|
"registry": "https://registry.npmjs.org" |
|
} |
|
} |
|
JSON |
|
|
|
cat > "$TEST_ROOT/fixture/package-lock.json" <<'JSON' |
|
{ |
|
"name": "@patrickjs/pkg-preview-fixture", |
|
"version": "1.2.3", |
|
"lockfileVersion": 3, |
|
"requires": true, |
|
"packages": { |
|
"": { |
|
"name": "@patrickjs/pkg-preview-fixture", |
|
"version": "1.2.3", |
|
"license": "UNLICENSED" |
|
} |
|
} |
|
} |
|
JSON |
|
|
|
cat > "$TEST_ROOT/fixture/.github/events/pr.json" <<'JSON' |
|
{ |
|
"pull_request": { |
|
"number": 123, |
|
"head": { |
|
"sha": "0123456789abcdef0123456789abcdef01234567", |
|
"repo": { |
|
"full_name": "PatrickJS/pkg-preview-fixture" |
|
} |
|
} |
|
}, |
|
"repository": { |
|
"full_name": "PatrickJS/pkg-preview-fixture", |
|
"owner": { |
|
"login": "PatrickJS" |
|
} |
|
} |
|
} |
|
JSON |
|
|
|
cat > "$TEST_ROOT/fixture/.github/events/push.json" <<'JSON' |
|
{ |
|
"ref": "refs/heads/main", |
|
"after": "fedcba9876543210fedcba9876543210fedcba98", |
|
"repository": { |
|
"full_name": "PatrickJS/pkg-preview-fixture", |
|
"owner": { |
|
"login": "PatrickJS" |
|
} |
|
} |
|
} |
|
JSON |
|
|
|
cat > "$TEST_ROOT/fixture/.github/events/release.json" <<'JSON' |
|
{ |
|
"release": { |
|
"tag_name": "v1.2.3", |
|
"target_commitish": "main" |
|
}, |
|
"repository": { |
|
"full_name": "PatrickJS/pkg-preview-fixture", |
|
"owner": { |
|
"login": "PatrickJS" |
|
} |
|
} |
|
} |
|
JSON |
|
|
|
cat > "$TEST_ROOT/fixture/mock-bin/npm" <<'SH' |
|
#!/usr/bin/env bash |
|
set -euo pipefail |
|
|
|
mock_dir="$(cd "$(dirname "$0")" && pwd)" |
|
search_path=":$PATH:" |
|
search_path="${search_path//:$mock_dir:/:}" |
|
search_path="${search_path#:}" |
|
search_path="${search_path%:}" |
|
real_npm="$(PATH="$search_path" command -v npm || true)" |
|
|
|
log_line() { |
|
if [ -n "${MOCK_NPM_LOG:-}" ]; then |
|
printf 'npm' >> "$MOCK_NPM_LOG" |
|
printf ' %q' "$@" >> "$MOCK_NPM_LOG" |
|
printf '\n' >> "$MOCK_NPM_LOG" |
|
fi |
|
} |
|
|
|
contains_arg() { |
|
local needle="$1" |
|
shift |
|
local arg |
|
for arg in "$@"; do |
|
if [ "$arg" = "$needle" ]; then |
|
return 0 |
|
fi |
|
done |
|
return 1 |
|
} |
|
|
|
uses_registry() { |
|
local registry="$1" |
|
shift |
|
local arg |
|
for arg in "$@"; do |
|
if [ "$arg" = "$registry" ]; then |
|
return 0 |
|
fi |
|
done |
|
return 1 |
|
} |
|
|
|
command="${1:-}" |
|
log_line "$@" |
|
|
|
case "$command" in |
|
view) |
|
if [ "${MOCK_NPM_VIEW_FAIL:-0}" = "1" ]; then |
|
echo "npm ERR! mock npm view failure" >&2 |
|
exit 1 |
|
fi |
|
if [ "${MOCK_NPM_VIEW_EXISTS:-0}" = "1" ]; then |
|
echo "${MOCK_NPM_VIEW_VERSION:-1.2.3}" |
|
exit 0 |
|
fi |
|
echo "npm ERR! code E404" >&2 |
|
echo "npm ERR! 404 mock package version not found" >&2 |
|
exit 1 |
|
;; |
|
publish) |
|
if [ "${MOCK_NPM_PUBLISH_FAIL:-0}" = "1" ]; then |
|
echo "npm ERR! mock npm publish failure" >&2 |
|
exit 1 |
|
fi |
|
if uses_registry "https://registry.npmjs.org" "$@" && [ "${MOCK_NPM_PUBLISH_FAIL_NPM:-0}" = "1" ]; then |
|
echo "npm ERR! mock npm registry publish failure" >&2 |
|
exit 1 |
|
fi |
|
if uses_registry "https://npm.pkg.github.com" "$@" && [ "${MOCK_NPM_PUBLISH_FAIL_GITHUB:-0}" = "1" ]; then |
|
echo "npm ERR! mock GitHub Packages publish failure" >&2 |
|
exit 1 |
|
fi |
|
echo "mock npm publish $*" |
|
exit 0 |
|
;; |
|
dist-tag) |
|
if [ "${2:-}" = "add" ]; then |
|
if [ "${MOCK_NPM_DIST_TAG_FAIL:-0}" = "1" ]; then |
|
echo "npm ERR! mock npm dist-tag add failure" >&2 |
|
exit 1 |
|
fi |
|
echo "mock npm dist-tag $*" |
|
exit 0 |
|
fi |
|
;; |
|
esac |
|
|
|
if [ -z "$real_npm" ]; then |
|
echo "mock npm could not find the real npm for delegated command: $*" >&2 |
|
exit 1 |
|
fi |
|
|
|
exec "$real_npm" "$@" |
|
SH |
|
|
|
cat > "$TEST_ROOT/fixture/mock-bin/gh" <<'SH' |
|
#!/usr/bin/env bash |
|
set -euo pipefail |
|
|
|
if [ "${1:-}" != "api" ]; then |
|
echo "mock gh only supports: gh api" >&2 |
|
exit 1 |
|
fi |
|
|
|
if [ "${MOCK_GH_API_FAIL:-0}" = "1" ]; then |
|
echo "mock gh api failure" >&2 |
|
exit 1 |
|
fi |
|
|
|
endpoint="${2:-}" |
|
case "$endpoint" in |
|
repos/*/pulls/*) |
|
if [ "${MOCK_PR_HEAD_STALE:-0}" = "1" ]; then |
|
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
|
else |
|
echo "${PR_HEAD_SHA:-0123456789abcdef0123456789abcdef01234567}" |
|
fi |
|
;; |
|
repos/*/branches/*) |
|
if [ "${MOCK_MAIN_HEAD_STALE:-0}" = "1" ]; then |
|
echo "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" |
|
else |
|
echo "${SNAPSHOT_SHA:-${GITHUB_SHA:-fedcba9876543210fedcba9876543210fedcba98}}" |
|
fi |
|
;; |
|
*) |
|
echo "mock gh api does not recognize endpoint: $endpoint" >&2 |
|
exit 1 |
|
;; |
|
esac |
|
SH |
|
|
|
chmod +x "$TEST_ROOT/fixture/mock-bin/npm" "$TEST_ROOT/fixture/mock-bin/gh" |
|
|
|
cat > "$TEST_ROOT/fixture/mock-github-api.js" <<'JS' |
|
const http = require("node:http"); |
|
|
|
const port = Number(process.env.MOCK_GITHUB_API_PORT || 18080); |
|
const marker = "<!-- github-packages-pr-preview -->"; |
|
let comments = process.env.MOCK_EXISTING_COMMENT === "1" |
|
? [{ id: 1, body: `${marker}\nold body`, user: { login: "github-actions[bot]" }, url: `http://127.0.0.1:${port}/repos/PatrickJS/pkg-preview-fixture/issues/comments/1` }] |
|
: []; |
|
|
|
function readBody(request) { |
|
return new Promise((resolve, reject) => { |
|
let body = ""; |
|
request.setEncoding("utf8"); |
|
request.on("data", (chunk) => { |
|
body += chunk; |
|
}); |
|
request.on("end", () => resolve(body)); |
|
request.on("error", reject); |
|
}); |
|
} |
|
|
|
function send(response, status, value) { |
|
response.writeHead(status, { "content-type": "application/json" }); |
|
response.end(JSON.stringify(value)); |
|
} |
|
|
|
function commentIdFromPatchPath(url) { |
|
if (url.startsWith("/comments/")) { |
|
return Number(url.split("/").pop()); |
|
} |
|
const match = url.match(/^\/repos\/[^/]+\/[^/]+\/issues\/comments\/([0-9]+)$/); |
|
return match ? Number(match[1]) : NaN; |
|
} |
|
|
|
const server = http.createServer(async (request, response) => { |
|
if (process.env.MOCK_GITHUB_API_FAIL === "1") { |
|
send(response, 500, { message: "mock GitHub comments API failure" }); |
|
return; |
|
} |
|
|
|
if (request.method === "GET" && request.url === "/health") { |
|
send(response, 200, { ok: true }); |
|
return; |
|
} |
|
|
|
if (request.method === "GET" && request.url.startsWith("/repos/") && request.url.includes("/issues/123/comments")) { |
|
send(response, 200, comments); |
|
return; |
|
} |
|
|
|
if (request.method === "POST" && request.url.startsWith("/repos/") && request.url.includes("/issues/123/comments")) { |
|
const body = JSON.parse(await readBody(request) || "{}"); |
|
const id = comments.length + 1; |
|
const comment = { id, body: body.body || "", user: { login: "github-actions[bot]" }, url: `http://127.0.0.1:${port}/repos/PatrickJS/pkg-preview-fixture/issues/comments/${id}` }; |
|
comments.push(comment); |
|
send(response, 201, comment); |
|
return; |
|
} |
|
|
|
if (request.method === "PATCH") { |
|
const id = commentIdFromPatchPath(request.url); |
|
if (!Number.isFinite(id)) { |
|
send(response, 404, { message: `mock route not found: ${request.method} ${request.url}` }); |
|
return; |
|
} |
|
const body = JSON.parse(await readBody(request) || "{}"); |
|
const comment = comments.find((item) => item.id === id); |
|
if (!comment) { |
|
send(response, 404, { message: "comment not found" }); |
|
return; |
|
} |
|
comment.body = body.body || ""; |
|
send(response, 200, comment); |
|
return; |
|
} |
|
|
|
send(response, 404, { message: `mock route not found: ${request.method} ${request.url}` }); |
|
}); |
|
|
|
server.listen(port, "127.0.0.1", () => { |
|
console.log(`mock GitHub API listening on ${port}`); |
|
}); |
|
JS |
|
|
|
node - "$TEST_ROOT/fixture/.github/workflows" <<'NODE' |
|
const fs = require("node:fs"); |
|
const path = require("node:path"); |
|
|
|
const workflowDir = process.argv[2]; |
|
|
|
function read(name) { |
|
return fs.readFileSync(path.join(workflowDir, name), "utf8"); |
|
} |
|
|
|
function write(name, content) { |
|
fs.writeFileSync(path.join(workflowDir, name), content); |
|
} |
|
|
|
function replaceCheckout(content, stepName) { |
|
const pattern = new RegExp(` - name: ${stepName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\n uses: actions/checkout@[^\\n]+\\n with:\\n(?: [^\\n]+\\n)+`); |
|
const replacement = ` - name: ${stepName}\n run: echo "checkout skipped for local act fixture"\n`; |
|
if (!pattern.test(content)) { |
|
throw new Error(`Could not patch checkout step: ${stepName}`); |
|
} |
|
return content.replace(pattern, replacement); |
|
} |
|
|
|
function insertBefore(content, marker, block) { |
|
if (!content.includes(marker)) { |
|
throw new Error(`Could not find insertion marker: ${marker}`); |
|
} |
|
return content.replace(marker, `${block}\n${marker}`); |
|
} |
|
|
|
function prependRun(content, stepName, scriptLine) { |
|
const step = ` - name: ${stepName}\n`; |
|
const stepIndex = content.indexOf(step); |
|
if (stepIndex === -1) { |
|
throw new Error(`Could not find step: ${stepName}`); |
|
} |
|
const runMarker = " run: |\n"; |
|
const runIndex = content.indexOf(runMarker, stepIndex); |
|
if (runIndex === -1) { |
|
throw new Error(`Could not find run block for step: ${stepName}`); |
|
} |
|
const insertIndex = runIndex + runMarker.length; |
|
return `${content.slice(0, insertIndex)} ${scriptLine}\n${content.slice(insertIndex)}`; |
|
} |
|
|
|
let pr = read("pr-preview-package.yml"); |
|
pr = pr.replace(/\$\{\{ secrets\.GITHUB_TOKEN \}\}/g, "mock-token"); |
|
pr = replaceCheckout(pr, "Checkout PR head"); |
|
pr = insertBefore(pr, " - name: Download preview tarball\n", ` - name: Add mock command shims\n run: echo "$MOCK_BIN" >> "$GITHUB_PATH"\n`); |
|
pr = insertBefore(pr, " - name: Comment install commands\n", ` - name: Start mock GitHub comments API\n if: steps.pr_tag.outputs.current == 'true'\n run: |\n node mock-github-api.js > "$RUNNER_TEMP/mock-github-api.log" 2>&1 &\n for i in {1..50}; do\n if node -e "fetch('http://127.0.0.1:\${MOCK_GITHUB_API_PORT:-18080}/health').then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"; then\n break\n fi\n sleep 0.1\n done\n echo "GITHUB_API_URL=http://127.0.0.1:\${MOCK_GITHUB_API_PORT:-18080}" >> "$GITHUB_ENV"\n`); |
|
pr = pr.replace('process.env.GITHUB_API_URL || "https://api.github.com"', '`http://127.0.0.1:${process.env.MOCK_GITHUB_API_PORT || 18080}`'); |
|
pr = prependRun(pr, "Publish exact commit preview", 'export PATH="$MOCK_BIN:$PATH"'); |
|
pr = prependRun(pr, "Move PR dist-tag if this is still the current PR head", 'export PATH="$MOCK_BIN:$PATH"'); |
|
write("pr-preview-package.yml", pr); |
|
|
|
let main = read("main-snapshot-package.yml"); |
|
main = main.replace(/\$\{\{ secrets\.GITHUB_TOKEN \}\}/g, "mock-token"); |
|
main = replaceCheckout(main, "Checkout commit"); |
|
main = insertBefore(main, " - name: Publish exact main snapshot\n", ` - name: Add mock command shims\n run: echo "$MOCK_BIN" >> "$GITHUB_PATH"\n`); |
|
main = prependRun(main, "Publish exact main snapshot", 'export PATH="$MOCK_BIN:$PATH"'); |
|
main = prependRun(main, "Move main dist-tag if this is still current main", 'export PATH="$MOCK_BIN:$PATH"'); |
|
write("main-snapshot-package.yml", main); |
|
|
|
let release = read("release-package.yml"); |
|
release = release.replace(/\$\{\{ secrets\.GITHUB_TOKEN \}\}/g, "mock-token"); |
|
release = replaceCheckout(release, "Checkout release ref"); |
|
release = insertBefore(release, " - name: Download release tarballs\n", ` - name: Add mock command shims\n run: echo "$MOCK_BIN" >> "$GITHUB_PATH"\n`); |
|
release = prependRun(release, "Publish to npm with trusted publishing", 'export PATH="$MOCK_BIN:$PATH"'); |
|
release = prependRun(release, "Publish to GitHub Packages", 'export PATH="$MOCK_BIN:$PATH"'); |
|
write("release-package.yml", release); |
|
NODE |
|
|
|
( |
|
cd "$TEST_ROOT/fixture" |
|
git init >/dev/null |
|
git add package.json package-lock.json mock-github-api.js .github |
|
git commit -m "fixture" >/dev/null |
|
git remote add origin https://github.com/PatrickJS/pkg-preview-fixture.git |
|
) |
|
|
|
echo "Linting source workflows..." |
|
"$ACTIONLINT_BIN" -color=false "$PR_WORKFLOW" "$MAIN_WORKFLOW" "$RELEASE_WORKFLOW" |
|
|
|
echo "Linting local patched workflows..." |
|
"$ACTIONLINT_BIN" -color=false "$TEST_ROOT/fixture/.github/workflows/pr-preview-package.yml" "$TEST_ROOT/fixture/.github/workflows/main-snapshot-package.yml" "$TEST_ROOT/fixture/.github/workflows/release-package.yml" |
|
|
|
act_common=( |
|
--defaultbranch main |
|
-P "ubuntu-latest=$ACT_IMAGE" |
|
--container-architecture "$ACT_ARCH" |
|
--bind |
|
--container-daemon-socket - |
|
--env "MOCK_BIN=$TEST_ROOT/fixture/mock-bin" |
|
--env "MOCK_NPM_LOG=$TEST_ROOT/fixture/mock-npm.log" |
|
--env "MOCK_GITHUB_API_PORT=$MOCK_GITHUB_API_PORT" |
|
) |
|
|
|
run_case() { |
|
local name="$1" |
|
local expected="$2" |
|
local event="$3" |
|
local event_file="$4" |
|
local workflow="$5" |
|
local expected_text="$6" |
|
shift 6 |
|
|
|
local log="$TEST_ROOT/logs/${name}.log" |
|
local artifacts="$TEST_ROOT/artifacts/${name}" |
|
rm -rf "$artifacts" |
|
mkdir -p "$artifacts" |
|
git -C "$TEST_ROOT/fixture" restore package.json |
|
|
|
local cmd=( |
|
"$ACT_BIN" "$event" |
|
--eventpath ".github/events/$event_file" |
|
--workflows ".github/workflows/$workflow" |
|
--artifact-server-path "$artifacts" |
|
"${act_common[@]}" |
|
) |
|
local pair |
|
for pair in "$@"; do |
|
cmd+=(--env "$pair") |
|
done |
|
|
|
set +e |
|
( |
|
cd "$TEST_ROOT/fixture" |
|
"${cmd[@]}" |
|
) > "$log" 2>&1 |
|
local status=$? |
|
set -e |
|
|
|
if [ "$expected" = "pass" ] && [ "$status" -ne 0 ]; then |
|
echo "FAIL $name: expected pass, got exit $status" >&2 |
|
sed -n '1,220p' "$log" >&2 |
|
exit 1 |
|
fi |
|
|
|
if [ "$expected" = "fail" ] && [ "$status" -eq 0 ]; then |
|
echo "FAIL $name: expected failure, got exit 0" >&2 |
|
sed -n '1,220p' "$log" >&2 |
|
exit 1 |
|
fi |
|
|
|
if [ -n "$expected_text" ] && ! grep -Fq "$expected_text" "$log"; then |
|
echo "FAIL $name: expected log text not found: $expected_text" >&2 |
|
sed -n '1,260p' "$log" >&2 |
|
exit 1 |
|
fi |
|
|
|
echo "PASS $name" |
|
} |
|
|
|
echo "Validating workflow graphs with act dry-run..." |
|
( |
|
cd "$TEST_ROOT/fixture" |
|
"$ACT_BIN" pull_request --dryrun --validate --eventpath .github/events/pr.json --workflows .github/workflows/pr-preview-package.yml "${act_common[@]}" >/dev/null |
|
"$ACT_BIN" push --dryrun --validate --eventpath .github/events/push.json --workflows .github/workflows/main-snapshot-package.yml "${act_common[@]}" >/dev/null |
|
"$ACT_BIN" release --dryrun --validate --eventpath .github/events/release.json --workflows .github/workflows/release-package.yml "${act_common[@]}" >/dev/null |
|
) |
|
|
|
echo "Running mocked workflow cases..." |
|
run_case "pr-happy" pass pull_request pr.json pr-preview-package.yml "Success - Main Comment install commands" |
|
run_case "pr-existing-version" pass pull_request pr.json pr-preview-package.yml "Preview already exists" MOCK_NPM_VIEW_EXISTS=1 |
|
run_case "pr-publish-fails" fail pull_request pr.json pr-preview-package.yml "Failed to publish @patrickjs/pkg-preview-fixture@0.0.0-pr.123.sha.0123456789abcdef0123456789abcdef01234567 to GitHub Packages" MOCK_NPM_PUBLISH_FAIL=1 |
|
run_case "pr-stale-head" pass pull_request pr.json pr-preview-package.yml "Not moving pr-123" MOCK_PR_HEAD_STALE=1 |
|
run_case "pr-dist-tag-fails" fail pull_request pr.json pr-preview-package.yml "Failed to move GitHub Packages dist-tag pr-123" MOCK_NPM_DIST_TAG_FAIL=1 |
|
run_case "pr-comment-fails" fail pull_request pr.json pr-preview-package.yml "Failed to create or update PR preview package comment" MOCK_GITHUB_API_FAIL=1 |
|
|
|
run_case "main-happy" pass push push.json main-snapshot-package.yml "Moving main to @patrickjs/pkg-preview-fixture@0.0.0-main.sha." |
|
run_case "main-publish-fails" fail push push.json main-snapshot-package.yml "Failed to publish @patrickjs/pkg-preview-fixture@0.0.0-main.sha." MOCK_NPM_PUBLISH_FAIL=1 |
|
run_case "main-stale-head" pass push push.json main-snapshot-package.yml "Not moving main" MOCK_MAIN_HEAD_STALE=1 |
|
run_case "main-dist-tag-fails" fail push push.json main-snapshot-package.yml "Failed to move GitHub Packages dist-tag main" MOCK_NPM_DIST_TAG_FAIL=1 |
|
|
|
run_case "release-happy" pass release release.json release-package.yml "Moving GitHub Packages latest to @patrickjs/pkg-preview-fixture@1.2.3" |
|
run_case "release-existing-version" pass release release.json release-package.yml "npm version already exists" MOCK_NPM_VIEW_EXISTS=1 |
|
run_case "release-npm-publish-fails" fail release release.json release-package.yml "Failed to publish @patrickjs/pkg-preview-fixture@1.2.3 to npm" MOCK_NPM_PUBLISH_FAIL_NPM=1 |
|
run_case "release-github-publish-fails" fail release release.json release-package.yml "Failed to publish @patrickjs/pkg-preview-fixture@1.2.3 to GitHub Packages" MOCK_NPM_PUBLISH_FAIL_GITHUB=1 |
|
run_case "release-github-dist-tag-fails" fail release release.json release-package.yml "Failed to move GitHub Packages latest tag" MOCK_NPM_DIST_TAG_FAIL=1 |
|
|
|
echo "All mocked workflow tests passed." |