From 94a444fe9ce568e4e7e90f6aca142de605874b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 29 Feb 2024 14:56:59 +0000 Subject: [PATCH] internal/e2e: partially revert using `cue mod init modpath@version` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í Change-Id: I2bd4c03a158a64fc5a844af9de9547a3eda6b736 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1177599 Reviewed-by: Roger Peppe TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine --- internal/e2e/testdata/script/github_app_private.txtar | 11 ++++++++++- internal/e2e/testdata/script/github_app_public.txtar | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/e2e/testdata/script/github_app_private.txtar b/internal/e2e/testdata/script/github_app_private.txtar index 997a2b642f8..ded47288f7b 100644 --- a/internal/e2e/testdata/script/github_app_private.txtar +++ b/internal/e2e/testdata/script/github_app_private.txtar @@ -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} @@ -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 diff --git a/internal/e2e/testdata/script/github_app_public.txtar b/internal/e2e/testdata/script/github_app_public.txtar index 82954a93a3a..10892c226b6 100644 --- a/internal/e2e/testdata/script/github_app_public.txtar +++ b/internal/e2e/testdata/script/github_app_public.txtar @@ -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} @@ -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