Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements support for emulating
spago test
from nix's building environment.N.B. It's currently built on top of several other branches. It will be rebased and declared ready for a proper code review once those land. This PR is sent out to facilitate a concrete albeit preliminary discussion about alternatives.
The only relevant commit is ba1b2c1.
Motivation
Being able to run an equivalent of
spago test
from within nix makes CI easy.nix flake check
/nix build .#my_website
.Design
checkPhase
ofbuildSpagoLock
by invokingpurs
, similarly to how it's today invoked frombuildPhase
. This is the right place for it because the compilation cache is readily available. The nix package will refuse to build if tests fail.buildSpagoLock
.slimlock
to buildnpmDependencies
for testing. Expose them by changing the user-facing API ofbuildSpagoLock
to return{ jsArtifacts, npmDependencies }
, whereoutput/
directory. This is whatbuildSpagoLock
returns today.slimlock
ran on$src/package-lock.json
.Considerations
npmDependencies
and doesn't enable tests, they won't be built due to nix's laziness.slimlock
in scope, which requires the user to have installed it via overlay. This is to allow user not to depend on it, when it's not needed.super.callPackage
is changed toself.callPackage
to allow the user to inject theslimlock
. Seems correct to have it this way for other reasons too (e.g. allow user to override the node version), but I'm not 100% confident this won't lead to looping in some edge case.Test.Main
is currently hardcoded as the main module of the test because we have no way of usingfromYAML
onspago.yaml
(it may contain comments).spago
could be modified to include this information in thespago.lock
.Alternatives
slimlock
allow the user to pass in the node dependencies explicitly.slimlock
missing from the overlays, when testing is enabled.js
, node2nix useslib
.backend-optimizer