Skip to content

Migrate test toolchain to the new Spago (spago.yaml + registry)#114

Merged
Unisay merged 1 commit into
mainfrom
issue-55/spago-yaml-migration
Jun 23, 2026
Merged

Migrate test toolchain to the new Spago (spago.yaml + registry)#114
Unisay merged 1 commit into
mainfrom
issue-55/spago-yaml-migration

Conversation

@Unisay

@Unisay Unisay commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #55. Builds on #54 (toolchain provider → purescript-overlay).

Migrates the test-project toolchain from the legacy Haskell spago (0.21.0, Dhall) to the new PureScript spago (1.0.4, spago.yaml + registry + spago.lock). This is the interim migration that lands the test project; the broader follow-ups (adding spago.yaml to the fork repos, registering pslua as a first-class spago backend, the README backend example) are intentionally out of scope, per the issue's own recommendation.

What changed

  • flake.nixspago-bin.spago-0_21_0spago-bin.spago-1_0_4. purs stays 0.15.16, so the compiler that stamps builtWith is unchanged.
  • test/ps/spago.yaml (new) — a registry: 77.8.0 baseline (pure, no-FFI packages) plus extraPackages git overrides for every FFI-bearing Lua fork (purescript-lua/purescript-lua-*, current tags), with dependency lists inlined and mirrored from the Lua package set's packages.dhall. This replaces the old upstream-ps // upstream-lua Dhall set where the forks won. No registry set is built for purs 0.15.16, so the baseline uses the latest 0.15.15 set — the same proven-compatible pairing the old Dhall set used.
  • No-op backendbackend: { cmd: "true" }. The new spago manages codegen itself and rejects --codegen in --purs-args; declaring a backend is the supported way to make it emit CoreFn (--codegen corefn), which is all the harness needs. This also sidesteps the corefn-staleness bug (spago build didn't update corefn in output directory purescript/spago#643).
  • test/ps/spago.lock (new, committed) — pins the resolved fork commits for reproducible golden inputs.
  • golden/ → src/ — the new spago only globs src/ and test/, so the golden sources move under src/. The .lua FFI files stay co-located next to each .purs, so the harness's foreign resolution (which searches next to the source file) keeps working.
  • Golden/Spec.hs — build command spago build -u '-g corefn'spago build.
  • Docs — CLAUDE.md and docs/GOLDEN_TESTING.md updated for spago.yaml, the new build command, the src/ layout, and PSLUA_GOLDEN_ACCEPT as the safe regeneration path (note: golden_reset destroys the hand-verified eval/golden.txt oracle).

Why PR #41 was incomplete

PR #41 added a spago.yaml but left the sources under golden/, so the new spago compiled zero project modules and the harness silently read stale committed corefn.json. Verified here: without src/, a clean build emits 0 Golden corefn out of 211. Relocating the sources is the fix #41 missed. #41 also used outdated Unisay/* fork URLs (the forks now live under purescript-lua/*) and ignored spago.lock.

Verification

  • golden.lua is byte-identical (0 of 52 changed) — the generated Lua is unchanged because the migration preserves the exact same fork versions. Only corefn.json modulePath (golden/src/) and golden.ir library paths (.spago/<pkg>/<ver>/.spago/p/<pkg>/<commit-hash>/) churn.
  • eval/golden.txt oracles are untouched and pass — semantics preserved across the package-set move.
  • Full suite green both with PSLUA_GOLDEN_ACCEPT=1 (regeneration) and without it (at-rest, CI-equivalent): 314 examples, 0 failures.

Swap the dev-shell spago pin from legacy 0.21.0 to the overlay's 1.0.4 and
migrate test/ps from spago.dhall/packages.dhall to spago.yaml + spago.lock.
The package set is a registry baseline (pure packages) plus extraPackages git
overrides for the Lua FFI forks, mirroring the old upstream-ps // upstream-lua
Dhall set where the forks won.

- flake.nix: spago-bin.spago-0_21_0 -> spago-bin.spago-1_0_4 (purs unchanged)
- test/ps/spago.yaml: registry 77.8.0 baseline + git overrides for the
  purescript-lua/* forks (current tags, deps inlined since the forks lack their
  own spago.yaml). A no-op backend (cmd: "true") makes spago emit CoreFn: the
  new spago manages codegen itself and rejects --codegen in --purs-args.
- test/ps/spago.lock: committed for reproducible golden inputs.
- move golden sources golden/ -> src/ (the new spago only globs src/ and test/);
  .lua FFI files stay co-located next to each .purs so foreign resolution works.
- Golden/Spec.hs: build command "spago build -u '-g corefn'" -> "spago build".
- regenerate goldens: golden.lua is byte-identical (same fork versions), only
  corefn.json modulePath and golden.ir .spago/p/<hash> paths churn; the
  eval/golden.txt oracles are untouched and stay green (314/0).
- docs: CLAUDE.md + GOLDEN_TESTING.md (spago.yaml, build cmd, src/ paths,
  PSLUA_GOLDEN_ACCEPT regeneration instead of golden_reset).

Out of scope (separate follow-ups): adding spago.yaml to the fork repos,
registering pslua as a first-class spago backend, and the README backend
example.

Closes #55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the PureScript golden-test project (test/ps) from legacy Dhall-based Spago to the PureScript Spago toolchain (spago.yaml + registry + spago.lock), aligning the harness and repository docs with the new build behavior and source layout.

Changes:

  • Bump the dev-shell Spago pin to spago-bin.spago-1_0_4 and switch the test project config to test/ps/spago.yaml (registry baseline + extraPackages fork overrides + no-op backend for CoreFn emission).
  • Relocate golden PureScript sources under test/ps/src/ (Spago 1.x globbing) and update the golden harness to run spago build.
  • Regenerate/adjust committed golden artifacts (corefn.json, golden.ir, etc.) to reflect the new source paths and .spago/p/... layout; update docs accordingly.

Reviewed changes

Copilot reviewed 77 out of 147 changed files in this pull request and generated no comments.

Show a summary per file
File Description
flake.nix Bumps pinned Spago in the dev shell to the PureScript Spago release used by the migrated test project.
test/ps/spago.yaml New Spago 1.x configuration: registry package set + Lua fork overrides + no-op backend to force CoreFn output.
test/ps/spago.dhall Removes legacy Dhall Spago project config.
test/ps/packages.dhall Removes legacy Dhall package-set composition (upstream-ps // upstream-lua).
test/Language/PureScript/Backend/Lua/Golden/Spec.hs Updates harness compilation step to spago build (Spago 1.x workflow).
lib/Language/PureScript/Backend/IR/Types.hs Updates comment references to the new test/ps/src/... golden source location.
docs/GOLDEN_TESTING.md Updates golden-testing documentation for src/ layout and new Spago/CoreFn behavior.
CLAUDE.md Updates contributor docs for Spago 1.x, spago.yaml/lockfile usage, and golden regeneration workflow.
test/ps/src/Golden/Values/Test.purs Golden input source now under src/ for Spago 1.x globbing.
test/ps/src/Golden/Unbinding/Test.purs Golden input source now under src/.
test/ps/src/Golden/TailRecM2Shadow/Test.purs Golden regression module added under src/.
test/ps/src/Golden/StringCodePoints/Test.purs Adds an end-to-end CodePoints golden under src/ targeting registry + forked strings.
test/ps/src/Golden/ReturnTableField/Test.purs Golden module under src/ for foreign-import table-field behavior.
test/ps/src/Golden/ReturnTableField/Test.lua Co-located Lua FFI file under src/ to preserve foreign resolution behavior.
test/ps/src/Golden/Reexport/Test.purs Golden input source now under src/.
test/ps/src/Golden/Reexport/ReExports.purs Golden input source now under src/.
test/ps/src/Golden/Reexport/Exports.purs Golden input source now under src/.
test/ps/src/Golden/RecursiveBindings/Test.purs Golden input source now under src/ (includes explanatory comments).
test/ps/src/Golden/RecordsUpdate/Test.purs Golden input source now under src/.
test/ps/src/Golden/RecordsAccess/Test.purs Golden input source now under src/.
test/ps/src/Golden/RecDataDefs/Test.purs Golden input source now under src/.
test/ps/src/Golden/ProfunctorDictLens/Test.purs Golden input source now under src/ for dictionary-lambda regression coverage.
test/ps/src/Golden/PatternMatching/Test2.purs Golden input source now under src/.
test/ps/src/Golden/PatternMatching/Test1.purs Golden input source now under src/.
test/ps/src/Golden/Newtype/Test.purs Golden input source now under src/.
test/ps/src/Golden/Nested/Test.purs Golden input source now under src/.
test/ps/src/Golden/NameShadowing/Test.purs Golden input source now under src/.
test/ps/src/Golden/MaybeChainModule/Test.purs Golden input source now under src/.
test/ps/src/Golden/MaybeChain/Test.purs Golden input source now under src/.
test/ps/src/Golden/LongWriterBind/Test.purs Golden input source now under src/ (stress test for deep binds).
test/ps/src/Golden/LongStateBind/Test.purs Golden input source now under src/ (stress test for deep binds).
test/ps/src/Golden/LongStackBind/Test.purs Golden input source now under src/ (stress test for deep binds).
test/ps/src/Golden/LongReaderBind/Test.purs Golden input source now under src/ (stress test for deep binds).
test/ps/src/Golden/LongDoBlock/Test.purs Golden input source now under src/ (large do-block stress case).
test/ps/src/Golden/LongBindFlipped/Test.purs Golden input source now under src/ (deep bind-flipped chain stress).
test/ps/src/Golden/LongApplyChain/Test.purs Golden input source now under src/ (deep applicative chain stress).
test/ps/src/Golden/Issue37/Test.purs Golden input source now under src/ for issue #37 repro.
test/ps/src/Golden/Inline/Test.purs Golden input source now under src/.
test/ps/src/Golden/HelloPrelude/Test.purs Golden input source now under src/.
test/ps/src/Golden/GenericEqTwoTypes/Test.purs Golden input source now under src/.
test/ps/src/Golden/Foreign/Test.purs Golden input source now under src/ (foreign vs local binding behavior).
test/ps/src/Golden/Foreign/Test.lua Co-located Lua FFI under src/.
test/ps/src/Golden/Foreign/Lib.purs Golden input source now under src/ (foreign imports).
test/ps/src/Golden/Foreign/Lib.lua Co-located Lua FFI under src/.
test/ps/src/Golden/Fibonacci/Test.purs Golden input source now under src/.
test/ps/src/Golden/DerivedFunctor/Test.purs Golden input source now under src/.
test/ps/src/Golden/DataDeclarations/Test2.purs Golden input source now under src/.
test/ps/src/Golden/DataDeclarations/Test1.purs Golden input source now under src/.
test/ps/src/Golden/Currying/Test.purs Golden input source now under src/.
test/ps/src/Golden/CharLiterals/Test.purs Golden input source now under src/ (char escaping regression coverage).
test/ps/src/Golden/CaseStatements/Test.purs Golden input source now under src/ (case/guard lowering coverage).
test/ps/src/Golden/BugListGenericEq/Test.purs Golden input source now under src/.
test/ps/src/Golden/Bug1/Test.purs Golden input source now under src/.
test/ps/src/Golden/Beta/Test.purs Golden input source now under src/.
test/ps/src/Golden/ArrayPatternMatch/Test.purs Golden input source now under src/ (array pattern binder indexing regression).
test/ps/src/Golden/ArrayOfUnits/Test.purs Golden input source now under src/.
test/ps/src/Golden/Annotations/M2.purs Golden input source now under src/ (annotation/inline behavior).
test/ps/src/Golden/Annotations/M1.purs Golden input source now under src/ (annotation/inline behavior).
test/ps/src/Golden/Annotations/M1.lua Co-located Lua FFI under src/.
test/ps/output/Golden.Values.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Unbinding.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.TestReturnTableField/golden.ir Updates IR source path from golden/ to src/.
test/ps/output/Golden.TestReturnTableField/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.TailRecM2Shadow.Test/golden.ir Updates IR .spago/... paths to the new .spago/p/<pkg>/<commit>/... layout.
test/ps/output/Golden.Reexport.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Reexport.ReExports/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Reexport.Exports/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.RecordsUpdate.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.RecordsAccess.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.RecDataDefs.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Newtype.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Nested.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.MaybeChain.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongWriterBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongStateBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongStackBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongReaderBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongMaybeBindModule.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongMaybeBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongExceptBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongEitherBind.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongDoBlock.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongCallbackChain.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongBindFlipped.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.LongApplyChain.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Issue37.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Inline.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.HelloPrelude.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.HelloPrelude.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Foreign.Test/golden.ir Updates IR source paths from golden/ to src/.
test/ps/output/Golden.Foreign.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Foreign.Lib/golden.ir Updates IR source paths from golden/ to src/.
test/ps/output/Golden.Foreign.Lib/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Fibonacci.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.DerivedFunctor.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.DataDeclarations.Test2/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.DataDeclarations.Test1/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Currying.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.CharLiterals.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.BugListGenericEq.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Bug1.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Beta.Test/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.ArrayPatternMatch.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.ArrayOfUnits.Test/golden.ir Updates IR .spago/... paths to .spago/p/... layout.
test/ps/output/Golden.Annotations.M2/golden.ir Updates IR source paths from golden/ to src/.
test/ps/output/Golden.Annotations.M2/corefn.json Updates committed CoreFn modulePath from golden/ to src/.
test/ps/output/Golden.Annotations.M1/golden.ir Updates IR source paths from golden/ to src/.
test/ps/output/Golden.Annotations.M1/corefn.json Updates committed CoreFn modulePath from golden/ to src/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Unisay Unisay merged commit 73adadb into main Jun 23, 2026
3 checks passed
@Unisay Unisay deleted the issue-55/spago-yaml-migration branch June 23, 2026 13:54
@Unisay Unisay self-assigned this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate toolchain to the new Spago (spago.yaml + registry), including the Lua package-set forks

2 participants