Repository navigation
chore: carry the template's prose-token documents verbatim and the julia test (replaces #24) #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| # Focused regressions for PR #240: package UUIDv8 minting and job timeouts. | ||
| # Executes the recipe's actual UUID block, with tool availability isolated | ||
| # from the host. No mint, network access, Bun or Julia installation is needed. | ||
| # Usage: bash tests/workflows/julia_library_test.sh | ||
| set -euo pipefail | ||
| repo=$(git rev-parse --show-toplevel) | ||
| fixture=$(mktemp -d) | ||
| trap 'rm -rf "$fixture"' EXIT | ||
| bash_bin=$(command -v bash) | ||
| sha_bin=$(command -v sha256sum) || { echo 'FAIL: sha256sum is needed to exercise the shipped fallback' >&2; exit 1; } | ||
| tr_bin=$(command -v tr) || { echo 'FAIL: tr is needed for owner normalization' >&2; exit 1; } | ||
| checks=0 | ||
| # Print all arguments as a failure message to stderr and exit the test with status 1. | ||
| fail() { echo "FAIL: $*" >&2; exit 1; } | ||
| # Compare actual $1 with expected $2, using $3 as the diagnostic label. | ||
| # Increment checks on equality; otherwise report the mismatch and exit with status 1. | ||
| equal() { | ||
| [ "$1" = "$2" ] || fail "$3: got '$1', expected '$2'" | ||
|
Check warning on line 20 in tests/workflows/julia_library_test.sh
|
||
| checks=$((checks + 1)) | ||
| } | ||
|
|
||
| # Match the outer indentation so the nested if/elif/else remains intact. | ||
| # Stop after the first block: a later Julia block handles .in renames. | ||
| # Strip the recipe's four spaces as Just does, including inside the generator block. | ||
| awk ' | ||
| /^ if \[ "\$ARCHETYPE" = "julia-library" \]; then$/ { copying = 1 } | ||
| copying { last = ($0 ~ /^ fi$/); sub(/^ /, ""); print; if (last) exit } | ||
| ' "$repo/build/just/repo-init.just" > "$fixture/mint.sh" | ||
| [ -s "$fixture/mint.sh" ] || fail 'package UUID block not found in repo-init' | ||
|
Check failure on line 31 in tests/workflows/julia_library_test.sh
|
||
|
|
||
| mkdir -p "$fixture/common" "$fixture/shell" "$fixture/bun" "$fixture/bun-only" "$fixture/empty" "$fixture/broken" | ||
| # Every branch canonicalizes the owner, even when no UUID generator exists. | ||
| # Expose only tr as a shared utility so the host cannot supply a generator. | ||
| ln -s "$tr_bin" "$fixture/common/tr" | ||
| ln -s "$sha_bin" "$fixture/shell/sha256sum" | ||
| # An installed uuidgen must never restore the old v5 package mint. | ||
| printf '#!%s\nexit 91\n' "$bash_bin" > "$fixture/shell/uuidgen" | ||
| chmod +x "$fixture/shell/uuidgen" | ||
|
|
||
| # derive TOOL_DIR OWNER REPO [STANDARDS_SCRIPT [ARCHETYPE [REPO_UUID]]] | ||
| # Execute the shipped UUID rule with the supplied identity and isolated tools. | ||
| # Print PACKAGE_UUID and write NUL-separated substitutions to fixture/sed.args; | ||
| # return the subprocess status, including generator failures. | ||
| # env -i prevents host Bun or SHA-256 tools, user config and exported functions from | ||
| # accidentally satisfying a branch. The subprocess only needs Bash builtins, | ||
| # tr and whichever generator this test explicitly places on PATH. | ||
| derive() { | ||
| env -i PATH="$1:$fixture/common" OWNER="$2" REPO="$3" \ | ||
|
Check warning on line 50 in tests/workflows/julia_library_test.sh
|
||
| STANDARDS_UUID_V8_JS="${4:-}" ARCHETYPE="${5:-julia-library}" \ | ||
| REPO_UUID="${6:-UNASSIGNED}" RSR_PACKAGE_UUID="${7:-}" RSR_MINT_REPLAY="${8:-0}" BUN_LOG="$fixture/bun.args" \ | ||
| "$bash_bin" -c ' | ||
| set -euo pipefail | ||
| LB="{{" RB="}}" PACKAGE_UUID=UNTOUCHED | ||
| SED_ARGS=() | ||
| cd "$3" | ||
| source "$1" >/dev/null | ||
| printf "%s\n" "$PACKAGE_UUID" | ||
| if [ "${#SED_ARGS[@]}" -gt 0 ]; then | ||
| printf "%s\0" "${SED_ARGS[@]}" > "$2" | ||
| else | ||
| : > "$2" | ||
| fi | ||
| ' _ "$fixture/mint.sh" "$fixture/sed.args" "$repo" | ||
| } | ||
|
|
||
| # Assert a generator's exact failure status so missing utilities or syntax | ||
| # errors cannot masquerade as successful negative controls. | ||
| fails_with() { | ||
| local expected_status=$1 | ||
| shift | ||
| if derive "$@" > /dev/null; then | ||
| fail "generator succeeded; expected exit $expected_status" | ||
| else | ||
| equal "$?" "$expected_status" 'generator failure status is preserved' | ||
| fi | ||
| } | ||
|
|
||
| # Fixed vectors independently calculated with Node crypto (SHA-256). These | ||
| # exercise version/variant replacement AND preservation of the remaining bits. | ||
| # Additional short/numeric identity and quoting vectors use sha256sum. | ||
| while read -r owner name expected; do | ||
| equal "$(derive "$fixture/shell" "$owner" "$name")" "$expected" "UUID for $owner/$name" | ||
| done <<'VECTORS' | ||
| hyperpolymath mintcheck b4839a75-05b9-8c83-a497-2aa751ab7f19 | ||
| example-owner MintCheck.jl 9271df15-3174-8475-ac0b-136d649c1f76 | ||
| other-owner MintCheck.jl a77b0d36-98a4-81aa-9457-25af7f040243 | ||
| example-owner OtherPackage.jl 86fa698a-692e-88c1-82ad-c1a986e8700d | ||
| example-owner mint-check 88f60d1e-793d-8026-8c30-5ceb4c99a728 | ||
| a a 737a297a-72a8-87df-afe7-622f2c0db843 | ||
| 123 1 dc555c1d-cf7b-8cbc-a0b5-76ab2aa4e8fb | ||
| O'Brien MintCheck.jl 55719f5a-ef9d-819a-a8ee-24cf43f886eb | ||
| VECTORS | ||
| expected=9271df15-3174-8475-ac0b-136d649c1f76 | ||
| # GitHub owner spelling must not change package identity. Keep the repository | ||
| # spelling intact: the registered preimage includes the supplied package name. | ||
| for owner in EXAMPLE-OWNER Example-Owner eXaMpLe-OwNeR; do | ||
| equal "$(derive "$fixture/shell" "$owner" MintCheck.jl)" "$expected" "owner casing for $owner" | ||
| done | ||
| # Owner is passed as an argument to uuid-v8.sh, never interpolated into shell code. | ||
| # These malformed logins deliberately probe that boundary without executing it. | ||
| equal "$(derive "$fixture/shell" 'owner-$(exit 97)-`exit 98`' MintCheck.jl)" \ | ||
| b665f02d-54bf-88c2-99cd-94a7963df9ea 'owner shell expressions remain literal data' | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl)" "$expected" 're-mint is deterministic' | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl '' julia-library 00000000-0000-8000-8000-000000000000)" \ | ||
| "$expected" 'package identity is independent of the repository UUID' | ||
|
|
||
| # Verify the real substitution expression reaches Project.toml, including | ||
| # every occurrence of the token in the new explanatory comment. | ||
| mapfile -d '' -t sed_args < "$fixture/sed.args" | ||
| sed "${sed_args[@]}" "$repo/archetypes/julia-library/overlay/Project.toml.in" > "$fixture/Project.toml" | ||
| equal "$(sed -n 's/^uuid = "\([^"]*\)"$/\1/p' "$fixture/Project.toml")" "$expected" 'minted Project.toml UUID' | ||
| if grep -qF '{{PACKAGE_UUID}}' "$fixture/Project.toml"; then fail 'package UUID token survived substitution'; fi | ||
|
|
||
| # Bun is preferred only when the standards implementation exists. The stub | ||
| # checks the invocation contract; the shell implementation above (uuid-v8.sh) owns | ||
| # the digest assertions. A path with spaces must remain a single argument. | ||
| standards="$fixture/standards tools/uuid-v8.js" | ||
| mkdir -p "$(dirname "$standards")" | ||
| : > "$standards" | ||
| { | ||
| printf '#!%s\n' "$bash_bin" | ||
| cat <<'BUN' | ||
| set -euo pipefail | ||
| printf '%s\n' "$@" > "$BUN_LOG" | ||
| printf '%s\n' '9271df15-3174-8475-ac0b-136d649c1f76' | ||
| BUN | ||
| } > "$fixture/bun/bun" | ||
| printf '#!%s\nexit 92\n' "$bash_bin" > "$fixture/bun/sha256sum" | ||
| chmod +x "$fixture/bun/bun" "$fixture/bun/sha256sum" | ||
| equal "$(derive "$fixture/bun" example-owner MintCheck.jl "$standards")" "$expected" 'Bun takes precedence over uuid-v8.sh' | ||
| equal "$(cat "$fixture/bun.args")" "$(printf '%s\n' "$standards" c julia-package-identity github.com/example-owner/MintCheck.jl)" \ | ||
| 'Bun receives the standards path, profile, domain and preimage' | ||
| equal "$(derive "$fixture/bun" ExAmPlE-OWNER MintCheck.jl "$standards")" "$expected" 'mixed-case owner uses Bun' | ||
| equal "$(cat "$fixture/bun.args")" "$(printf '%s\n' "$standards" c julia-package-identity github.com/example-owner/MintCheck.jl)" \ | ||
| 'Bun receives the canonical owner and original repository spelling' | ||
|
|
||
| # Bun without a usable standards file falls back to uuid-v8.sh, including when | ||
| # the setting names a missing file or a directory rather than a regular file. | ||
| ln -s "$fixture/bun/bun" "$fixture/shell/bun" | ||
| ln -s "$fixture/missing.js" "$fixture/dangling.js" | ||
| for unavailable in '' "$fixture/missing.js" "$fixture/standards tools" "$fixture/dangling.js"; do | ||
| rm -f "$fixture/bun.args" | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl "$unavailable")" "$expected" 'unavailable standards script uses uuid-v8.sh' | ||
| [ ! -e "$fixture/bun.args" ] || fail 'Bun ran without a standards file' | ||
|
Check failure on line 146 in tests/workflows/julia_library_test.sh
|
||
| done | ||
|
|
||
| # A standards file on its own is insufficient when Bun is absent. | ||
| rm "$fixture/shell/bun" | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl "$standards")" "$expected" 'standards script without Bun uses uuid-v8.sh' | ||
| equal "$(derive "$fixture/empty" example-owner MintCheck.jl)" UNASSIGNED 'no generator leaves identity unassigned' | ||
| mapfile -d '' -t sed_args < "$fixture/sed.args" | ||
| equal "$(sed "${sed_args[@]}" <<< 'uuid = "{{PACKAGE_UUID}}"')" 'uuid = "UNASSIGNED"' 'unassigned fallback reaches the package manifest' | ||
| ln -s "$fixture/bun/bun" "$fixture/bun-only/bun" | ||
| equal "$(derive "$fixture/bun-only" example-owner MintCheck.jl "$standards")" "$expected" 'Bun with standards works without uuid-v8.sh' | ||
| equal "$(derive "$fixture/bun-only" example-owner MintCheck.jl)" UNASSIGNED 'Bun without standards or a SHA-256 tool leaves identity unassigned' | ||
| equal "$(derive "$fixture/empty" ExAmPlE-OWNER MintCheck.jl "$standards")" UNASSIGNED 'standards without either generator leaves identity unassigned' | ||
| equal "$(derive "$fixture/bun" example-owner MintCheck.jl '' other-archetype)" UNTOUCHED 'other archetypes do not mint a package UUID' | ||
| [ ! -s "$fixture/sed.args" ] || fail 'other archetype gained a package UUID substitution' | ||
|
Check failure on line 160 in tests/workflows/julia_library_test.sh
|
||
|
|
||
| # A failing generator must fail loudly rather than emitting a successful mint. | ||
| printf '#!%s\nexit 93\n' "$bash_bin" > "$fixture/broken/sha256sum" | ||
| chmod +x "$fixture/broken/sha256sum" | ||
| fails_with 2 "$fixture/broken" example-owner MintCheck.jl | ||
| printf '#!%s\nexit 94\n' "$bash_bin" > "$fixture/broken/bun" | ||
| chmod +x "$fixture/broken/bun" | ||
| fails_with 94 "$fixture/broken" example-owner MintCheck.jl "$standards" | ||
| # Even an available working SHA-256 tool must not hide a failing preferred generator. | ||
| ln -s "$fixture/broken/bun" "$fixture/shell/bun" | ||
| fails_with 94 "$fixture/shell" example-owner MintCheck.jl "$standards" | ||
| rm "$fixture/shell/bun" | ||
|
|
||
| # Inspect only direct job fields: a timeout on another job or nested step | ||
| # must not satisfy a missing timeout. Duplicate timeout keys also fail. | ||
| workflow="$repo/archetypes/julia-library/overlay/.github/workflows/julia-ci.yml.in" | ||
| for job in fmt jet test; do | ||
| minutes=10 | ||
| [ "$job" != test ] || minutes=15 | ||
|
Check failure on line 179 in tests/workflows/julia_library_test.sh
|
||
| actual=$(awk -v job="$job" ' | ||
| /^ [A-Za-z0-9_-]+:/ { selected = ($0 == " " job ":") } | ||
| selected && /^ timeout-minutes:/ { print $2 } | ||
| ' "$workflow") | ||
| equal "$actual" "$minutes" "$job job timeout" | ||
| done | ||
| # A replay supplies the recorded uuid (mint-answers :package-uuid), so the | ||
| # drift gate gives the same answer on a host with neither bun nor a SHA-256 tool | ||
| # (Codex review of #275). A recorded UNASSIGNED replays as UNASSIGNED even | ||
| # where a generator exists; a malformed value is ignored, not trusted. | ||
| equal "$(derive "$fixture/empty" example-owner MintCheck.jl '' julia-library UNASSIGNED "$expected" 1)" "$expected" \ | ||
| 'a recorded package uuid replays without bun or a SHA-256 tool' | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl '' julia-library UNASSIGNED UNASSIGNED 1)" UNASSIGNED \ | ||
| 'a recorded UNASSIGNED replays as UNASSIGNED' | ||
| equal "$(derive "$fixture/empty" example-owner MintCheck.jl '' julia-library UNASSIGNED 'not-a-uuid' 1)" UNASSIGNED \ | ||
| 'a malformed recorded uuid is ignored' | ||
| # Outside a replay the value is never trusted (Codex review of #275): an | ||
| # ordinary mint derives the uuid even when the environment carries one. | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl '' julia-library UNASSIGNED 00000000-0000-8000-8000-000000000000)" "$expected" \ | ||
| 'an ordinary mint ignores RSR_PACKAGE_UUID and derives the uuid' | ||
| equal "$(derive "$fixture/shell" example-owner MintCheck.jl '' julia-library UNASSIGNED UNASSIGNED)" "$expected" \ | ||
| 'an ordinary mint ignores a stray UNASSIGNED' | ||
| echo "PASS: $checks Julia library UUID and timeout checks; generator failures rejected" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this minted repository,
build/just/repo-init.justdeliberately removes the entirearchetypes/directory, so the newly advertisedbash tests/workflows/julia_library_test.shcommand always exits here withsed: can't read .../archetypes/julia-library/overlay/Project.toml.in; the later workflow check has the same missing-fixture dependency. Either avoid carrying this template-only test into minted trees or make it skip the overlay-specific assertions whenarchetypes/julia-libraryis absent.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified, and it is real: bactrian main has no archetypes/ directory (the mint removes it), while tests/workflows/julia_library_test.sh reads archetypes/julia-library/overlay/... at line 112 and line 176, so the test cannot pass in a minted tree. Two facts bound it: the file is carried byte-identical because mint-verbatim.txt lists it, and nothing in this repository's CI invokes it (only the template's own tests/e2e/julia_mint_test.sh does), so no check here goes red from it. The fix belongs at the source, not in this repository: the template either stops carrying template-only tests into children or lets them say so explicitly. That is a design choice for the owner, raised with the sweep; no local edit, since a divergent copy would break the byte-identity this PR exists to keep. Not claimed fixed.
Generated by Claude Code