Skip to content

Commit baab7be

Browse files
committed
extension/tools/release: add test for rc
This test ensures release publish command skips 'npx vsce publish' when tags include "rc.N" format label. See diff between testdata/publish-v0.0.0.golden and testdata/publish-v0.0.0-rc.1.golden. Change-Id: Ic6fb35ea22d04d4654866bcf4ea859d0f151a5a2 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/563355 TryBot-Result: kokoro <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 7bfbcaf commit baab7be

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

extension/tools/release/release_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ func TestRelease(t *testing.T) {
2727
moduleRoot := string(bytes.TrimSpace(out))
2828

2929
for _, command := range []string{"package", "publish"} {
30-
t.Run(command, func(t *testing.T) {
31-
testRelease(t, moduleRoot, command)
32-
})
30+
for _, tagName := range []string{"v0.0.0", "v0.0.0-rc.1"} {
31+
t.Run(command+"-"+tagName, func(t *testing.T) {
32+
testRelease(t, moduleRoot, command, tagName)
33+
})
34+
}
3335
}
3436
}
3537

36-
func testRelease(t *testing.T, moduleRoot, command string) {
38+
func testRelease(t *testing.T, moduleRoot, command, tagName string) {
3739
cmd := exec.Command("go", "run", "-C", moduleRoot, "tools/release/release.go", "-n", command)
3840
cmd.Env = append(os.Environ(),
3941
// Provide dummy environment variables required to run release.go commands.
40-
"TAG_NAME=v0.0.0", // release tag
42+
"TAG_NAME="+tagName, // release tag
4143
"GITHUB_TOKEN=dummy", // github token needed to post release notes
4244
"VSCE_PAT=dummy", // vsce token needed to publish the extension
4345
"COMMIT_SHA=4893cd984d190bdf2cd65e11c425b42819ae6f57", // bogus commit SHA used to post release notes
@@ -47,12 +49,12 @@ func testRelease(t *testing.T, moduleRoot, command string) {
4749
t.Fatalf("failed to run release package: %v", err)
4850
}
4951
if *flagUpdate {
50-
if err := os.WriteFile(filepath.Join("testdata", command+".golden"), output, 0644); err != nil {
52+
if err := os.WriteFile(filepath.Join("testdata", command+"-"+tagName+".golden"), output, 0644); err != nil {
5153
t.Fatal("failed to write golden file:", err)
5254
}
5355
return
5456
}
55-
golden, err := os.ReadFile(filepath.Join("testdata", command+".golden"))
57+
golden, err := os.ReadFile(filepath.Join("testdata", command+"-"+tagName+".golden"))
5658
if err != nil {
5759
t.Fatal("failed to read golden file:", err)
5860
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jq -r .version package.json
2+
cp ../README.md README.md
3+
npx vsce package -o go-0.0.0-rc.1.vsix --baseContentUrl https://github.com/golang/vscode-go/raw/v0.0.0-rc.1 --baseImagesUrl https://github.com/golang/vscode-go/raw/v0.0.0-rc.1 --no-update-package-json --no-git-tag-version 0.0.0-rc.1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jq -r .version package.json
2+
stat go-0.0.0-rc.1.vsix
3+
release create --generate-notes --target 4893cd984d190bdf2cd65e11c425b42819ae6f57 --title Release v0.0.0-rc.1 --draft
4+
gh release create --generate-notes --target 4893cd984d190bdf2cd65e11c425b42819ae6f57 --title Release v0.0.0-rc.1 --draft --prerelease -R github.com/golang/vscode-go v0.0.0-rc.1 go-0.0.0-rc.1.vsix

0 commit comments

Comments
 (0)