-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: rework mod publish with git test
In preparation for a later change where we add support for inclusion of LICENSE files from a VCS root where none exists in a module directory, we rework the registry_publish_with_git.txtar test. Even though we add more module dependencies to the test (again in support of the later change to verify LICENSE file inclusion), there is no semantic change in what is currently covered by this test. Signed-off-by: Paul Jolly <[email protected]> Change-Id: I04df8da1798674c669e752560d53478fa76e9aab Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195545 Reviewed-by: Daniel Martí <[email protected]> Reviewed-by: Chief Cueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
1 changed file
with
72 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,30 +10,47 @@ exec git init . | |
exec git add . | ||
exec git -c user.name=noone -c [email protected] commit -m 'initial commit' | ||
|
||
# Remove an file that's outside the module directory, which | ||
# makes the git repository unclean but the module subdirectory | ||
# remains clean. | ||
# Publish the root module | ||
cd $WORK/example | ||
exec cue mod publish v0.0.1 | ||
stdout '^published x.example/[email protected] to [^ ]+/x.example/root:v0.0.1$' | ||
|
||
# Now remove a file that's outside the root/a or root/b directory, which makes | ||
# the git repository unclean but the module subdirectories remain clean. | ||
rm $WORK/example/otherfile | ||
|
||
cd cuemodule | ||
cd $WORK/example/a | ||
exec cue mod publish v0.0.1 | ||
stdout '^published x.example/[email protected] to [^ ]+/x.example/e:v0.0.1$' | ||
stdout '^published x.example/root/[email protected] to [^ ]+/x.example/root/a:v0.0.1$' | ||
cd $WORK/example/b | ||
exec cue mod publish v0.0.1 | ||
stdout '^published x.example/root/[email protected] to [^ ]+/x.example/root/b:v0.0.1$' | ||
|
||
# Verify that we can evaluate based on those dependencies | ||
cd $WORK/main | ||
exec cue eval . | ||
cmp stdout ../expect-eval-stdout | ||
|
||
# Verify that we have a LICENSE files for all modules | ||
cmp ${CUE_CACHE_DIR}/mod/extract/x.example/[email protected]/LICENSE $WORK/example/LICENSE | ||
cmp ${CUE_CACHE_DIR}/mod/extract/x.example/root/[email protected]/LICENSE $WORK/example/a/LICENSE | ||
|
||
# TODO: support grabbing the LICENSE file from the VCS root if one is not | ||
# contained in the module | ||
# cmp ${CUE_CACHE_DIR}/mod/extract/x.example/root/[email protected]/LICENSE $WORK/example/LICENSE | ||
|
||
# Check that the manifest contains the expected git metadata | ||
# Note: we use cue vet rather than cmp because the | ||
# manifest contains information that's tricky to control/predict | ||
# in a test, such as git commit times and commit hashes. | ||
get-manifest $MEMREGISTRY/x.example/e:v0.0.1 $WORK/manifest0.json | ||
get-manifest $MEMREGISTRY/x.example/root:v0.0.1 $WORK/manifest0.json | ||
exec cue vet $WORK/manifest-schema.cue $WORK/manifest0.json | ||
|
||
# If the git directory is not clean, the publish should fail. We can | ||
# conveniently combine that check with the .gitignore removal. | ||
cd $WORK/example | ||
rm .gitignore | ||
cd cuemodule | ||
cd $WORK/example/a | ||
! exec cue mod publish v0.0.2 | ||
cmp stderr $WORK/expect-unclean-stderr | ||
|
||
|
@@ -42,10 +59,10 @@ cmp stderr $WORK/expect-unclean-stderr | |
cd $WORK/example | ||
exec git add . | ||
exec git -c user.name=noone -c [email protected] commit -m 'commit with no .gitignore' | ||
cd cuemodule | ||
cd $WORK/example/a | ||
exec cue mod publish v0.0.2 | ||
cd $WORK/main | ||
exec cue mod get x.example/e@v0.0.2 | ||
exec cue mod get x.example/root/a@v0.0.2 | ||
exec cue eval . | ||
cmp stdout $WORK/expect-eval-stdout2 | ||
|
||
|
@@ -60,40 +77,66 @@ annotations!: { | |
-- expect-publish-stdout -- | ||
published x.example/[email protected] | ||
-- expect-eval-stdout -- | ||
e: true | ||
root: true | ||
a: true | ||
b: true | ||
-- expect-unclean-stderr -- | ||
VCS state is not clean | ||
-- expect-eval-stdout2 -- | ||
e: true | ||
sensitive: true | ||
root: true | ||
a: true | ||
sensitive_a: true | ||
b: true | ||
-- main/cue.mod/module.cue -- | ||
module: "main.org@v0" | ||
language: version: "v0.9.0-alpha.0" | ||
source: kind: "self" | ||
|
||
deps: "x.example/e@v0": v: "v0.0.1" | ||
|
||
deps: "x.example/root@v0": v: "v0.0.1" | ||
deps: "x.example/root/a@v0": v: "v0.0.1" | ||
deps: "x.example/root/b@v0": v: "v0.0.1" | ||
-- main/main.cue -- | ||
package main | ||
import "x.example/e@v0" | ||
|
||
e | ||
import ( | ||
"x.example/root@v0" | ||
"x.example/root/a@v0" | ||
"x.example/root/b@v0" | ||
) | ||
|
||
-- example/cuemodule/cue.mod/module.cue -- | ||
module: "x.example/e@v0" | ||
root | ||
a | ||
b | ||
-- example/.gitignore -- | ||
/a/ignored.cue | ||
-- example/cue.mod/module.cue -- | ||
module: "x.example/root@v0" | ||
language: version: "v0.9.0-alpha.0" | ||
source: kind: "git" | ||
-- example/.gitignore -- | ||
/cuemodule/ignored.cue | ||
-- example/cuemodule/e.cue -- | ||
package e | ||
|
||
e: true | ||
|
||
-- example/cuemodule/ignored.cue -- | ||
package e | ||
|
||
sensitive: true | ||
-- example/LICENSE -- | ||
root LICENSE | ||
-- example/root.cue -- | ||
package root | ||
root: true | ||
-- example/a/cue.mod/module.cue -- | ||
module: "x.example/root/a@v0" | ||
language: version: "v0.9.0-alpha.0" | ||
source: kind: "git" | ||
-- example/a/LICENSE -- | ||
a LICENSE | ||
-- example/a/a.cue -- | ||
package a | ||
a: true | ||
-- example/a/ignored.cue -- | ||
package a | ||
sensitive_a: true | ||
-- example/b/cue.mod/module.cue -- | ||
module: "x.example/root/b@v0" | ||
language: version: "v0.9.0-alpha.0" | ||
source: kind: "git" | ||
-- example/b/b.cue -- | ||
package b | ||
b: true | ||
-- example/otherfile -- | ||
this will be removed but is outside the module so | ||
that shouldn't stop the publish working. |