Skip to content

Commit

Permalink
internal/e2e: partially revert using cue mod init modpath@version
Browse files Browse the repository at this point in the history
Up to this point, the deployed registry.cue.works used a relatively old
version of cmd/cue to do its "published module is tidy" checks.
Last week, I bumped this to a v0.8.0 alpha, to keep things up to date
and gearing up for the registry being publicly used.

One side effect of this is that the newer cmd/cue used in `cue mod tidy`
by the registry now adds `language: version: "v0.8.0-alpha.3"`
to cue.mod/module.cue if it doesn't exist.
So any CUE modules being published without a `language.version` field
get rejected with the error "module is not tidy".

This breaks the e2e tests as they `go install cuelang.org/go/cmd/cue`
from the very same repository via a replace directive,
so the version ends up being derived from the buildvcs info,
which does not include a tag/semver as seen by `cue version`.
Then, the `cue mod init` calls in the e2e tests omit `language.version`.

As a fix, go back to templating cue.mod/module.cue in the e2e tests,
which allows us to insert language.version manually.
At a later time, we can support programmatically adding the field
via a command mirroring Go's own `go mod edit`, so add a TODO as well.

Note that the "publish to gcloud" e2e test is unaffected,
as it performs no such module tidiness checks.

This partially reverts https://cuelang.org/cl/1176190.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I2bd4c03a158a64fc5a844af9de9547a3eda6b736
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1177599
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Feb 29, 2024
1 parent 93acaa3 commit 94a444f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion internal/e2e/testdata/script/github_app_private.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ env MODVER=${MODULE}@v0

cd publish

exec cue mod init ${MODVER}
# TODO: replace by "cue mod init" once we can programatically insert
# a language.version string, such as via "cue mod edit".
# Otherwise registry.cue.works complains about the lack of language.version.
# cue mod init ${MODVER}
env-fill cue.mod/module.cue

exec cue mod publish ${VERSION}

Expand All @@ -25,6 +29,11 @@ cmp stdout export.golden
# TODO(mvdan): Use another registry token without access to this private repo
# and check that they cannot list the module's versions or download any of them.

-- publish/cue.mod/module.cue --
module: "${MODVER}"
language: {
version: "v0.8.0-alpha.3"
}
-- publish/foo.cue --
package publish

Expand Down
11 changes: 10 additions & 1 deletion internal/e2e/testdata/script/github_app_public.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ env MODVER=${MODULE}@v0

cd publish

exec cue mod init ${MODVER}
# TODO: replace by "cue mod init" once we can programatically insert
# a language.version string, such as via "cue mod edit".
# Otherwise registry.cue.works complains about the lack of language.version.
# cue mod init ${MODVER}
env-fill cue.mod/module.cue

exec cue mod publish ${VERSION}

Expand All @@ -22,6 +26,11 @@ exec cue mod tidy
exec cue export
cmp stdout export.golden

-- publish/cue.mod/module.cue --
module: "${MODVER}"
language: {
version: "v0.8.0-alpha.3"
}
-- publish/foo.cue --
package publish

Expand Down

0 comments on commit 94a444f

Please sign in to comment.