Skip to content

Commit db2b4c5

Browse files
committed
build: run tests and build golang.go-nightly
Building and testing the extension requires a custom docker image that includes Go, Node.js, jq, gopls, dlv, staticcheck, etc. build-ci-image.yaml is a workflow that builds and stores the image in Artifact Registry. (vscode-go-docker-repo/ci-image). release-nightly.yaml workflow uses the container. - The workflow clones the vscode-go repo (master branch). - Before packaging, the "prepare nightly release" step adjusts the package.json for golang.go-nightly use. - Then run tests. It's possible that the lint test and the tools/generate.go test may be unhappy about the spacing and formatting caused by the modification made during the previous step. However, the errors are not critical for packaging/publishing. Refactoring of all.bash was to skip the lint, generate.go tests during nightly release. The workflow uploads the built extension to the project's GCS bucket but does not publish the built extension to the marketplace yet. Change-Id: Ib48fdc45f1fd1c86fcfc2d293e7f60690b2cad11 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/510515 Reviewed-by: Robert Findley <[email protected]> TryBot-Result: kokoro <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
1 parent 60c8ec9 commit db2b4c5

File tree

4 files changed

+81
-19
lines changed

4 files changed

+81
-19
lines changed

build/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Release process
2+
3+
The golang.go-nightly extension is released daily during weekdays, based on the latest commit to the master branch.
4+
5+
(Note: the release process is currently in GH workflow. We are in process of moving it to a GCB workflow.)
6+
7+
* Dockerfile: defines the image containing tools and environments needed to build and test the extension. (e.g. Go, Node.js, jq, etc.)
8+
* build-ci-image.yaml: defines the workflow to build the container image used for extension testing and releasing.
9+
* release-nightly.yaml: defines the workflow that builds the nightly extension and runs tests. The built extension is pushed only after all tests pass.

build/all.bash

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash -e
1+
#!/usr/bin/env bash
2+
set -e
23

34
# Copyright (C) Microsoft Corporation. All rights reserved.
45
# Modification copyright 2020 The Go Authors. All rights reserved.
@@ -38,27 +39,31 @@ go_binaries_info() {
3839
go version
3940
}
4041

41-
run_test() {
42+
run_doc_test() {
4243
df -h | grep shm
4344

4445
echo "**** Run settings generator ****"
4546
go run ./tools/generate.go -w=false -gopls=true
4647

47-
echo "**** Run Go tests ****"
48-
go test ./...
49-
5048
echo "**** Test build ****"
5149
npm ci
5250
npm run compile
51+
}
52+
53+
run_test() {
54+
echo "**** Run Go tests ****"
55+
go test ./...
5356

5457
echo "**** Run test ****"
5558
npm run unit-test
5659
npm test --silent
60+
}
5761

62+
run_lint() {
63+
echo "**** Run lint ****"
5864
npm run lint
5965
}
6066

61-
6267
run_test_in_docker() {
6368
which npm && npm version || echo "no npm"
6469
which go && go version || echo "no go"
@@ -75,8 +80,7 @@ prepare_nightly() {
7580
# on 2020/01/05 10:00
7681
local VER=`git log -1 --format=%cd --date="format:%Y.%-m.%-d%H"`
7782
local COMMIT=`git log -1 --format=%H`
78-
echo "**** Preparing nightly release : $VER ***"
79-
83+
echo "**** Preparing nightly release : ${VER} (${COMMIT}) ***"
8084
# Update package.json
8185
(cat package.json | jq --arg VER "${VER}" '
8286
.version=$VER |
@@ -86,7 +90,7 @@ prepare_nightly() {
8690
.publisher="golang" |
8791
.description="Rich Go language support for Visual Studio Code (Nightly)" |
8892
.contributes.configuration.properties."go.delveConfig".properties.hideSystemGoroutines.default=true
89-
') > /tmp/package.json && mv /tmp/package.json package.json
93+
') > /tmp/package.json && cp /tmp/package.json package.json
9094

9195
# Replace CHANGELOG.md with CHANGELOG.md + Release commit info.
9296
printf "**Release ${VER} @ ${COMMIT}** \n\n" | cat - CHANGELOG.md > /tmp/CHANGELOG.md.new && mv /tmp/CHANGELOG.md.new CHANGELOG.md
@@ -113,11 +117,17 @@ main() {
113117
"ci")
114118
go_binaries_info
115119
setup_virtual_display
120+
run_doc_test
116121
run_test
122+
run_lint
117123
;;
118124
"prepare_nightly")
119125
prepare_nightly
120126
;;
127+
"test_nightly")
128+
setup_virtual_display
129+
run_test
130+
;;
121131
*)
122132
usage
123133
exit 2

build/build-ci-image.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Usage: gcloud builds submit --config build/build-ci-image.yaml .
2+
steps:
3+
- name: 'gcr.io/cloud-builders/docker'
4+
entrypoint: 'bash'
5+
args: ['-c', 'docker pull us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image:latest || exit 0']
6+
- name: 'gcr.io/cloud-builders/docker'
7+
# https://cloud.google.com/build/docs/optimize-builds/speeding-up-builds
8+
args: [
9+
'build',
10+
'-t', 'us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image:latest',
11+
'--cache-from', 'us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image:latest',
12+
'-f', 'build/Dockerfile',
13+
'.']
14+
images: ['us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image']

build/release-nightly.yaml

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1+
# This workflow will be triggered daily.
2+
# For local testing, run:
3+
# gcloud builds submit --config release-nightly.yaml
4+
# This will check out the vscode-go repo master branch and run the build from it.
15
steps:
2-
# TODO: check build/test status
3-
#
4-
# Install dependencies
5-
- name: node
6+
# TODO: check build/test status
7+
- id: clone vscode-go repo
8+
name: "gcr.io/cloud-builders/git"
9+
args: ['clone', '--branch=master', "--depth=1", 'https://go.googlesource.com/vscode-go', 'vscode-go']
10+
- id: adjust file permissions
11+
name: "gcr.io/cloud-builders/docker"
12+
entrypoint: "chown"
13+
args: ["-R", "1000:1000", "/workspace", "/builder/home"] # ci-image sets USER to node whose uid/gid are 1000.
14+
dir: "/"
15+
- id: install npm dependencies
16+
name: "us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image"
617
entrypoint: npm
7-
args: ['ci']
8-
# Build .vsix
9-
- name: node
18+
args: ["ci"]
19+
dir: "vscode-go"
20+
- id: prepare nightly release
21+
name: "us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image"
22+
entrypoint: "bash"
23+
args: ["build/all.bash", 'prepare_nightly']
24+
dir: "vscode-go"
25+
- id: build .vsix
26+
name: "us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image"
1027
entrypoint: npm
11-
args: ['run', 'package']
28+
args: ["run", "package"] # we build vsix before running tests to avoid including unintentional changes.
29+
dir: "vscode-go"
30+
- id: run tests
31+
name: "us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image"
32+
entrypoint: "bash"
33+
args: ["build/all.bash", "test_nightly"]
34+
dir: "vscode-go"
35+
env:
36+
- "IN_RELEASE_WORKFLOW=true"
37+
options:
38+
substitution_option: "ALLOW_LOOSE"
39+
machineType: 'E2_HIGHCPU_8' # tests need powerful cpus to avoid timeout.
40+
images: ['us-docker.pkg.dev/$PROJECT_ID/vscode-go-docker-repo/ci-image:latest']
1241
artifacts:
1342
objects:
14-
location: 'gs://$PROJECT_ID/nightly/$BUILD_ID'
15-
paths: ['*.vsix']
43+
location: "gs://$PROJECT_ID/nightly"
44+
paths: ["vscode-go/*.vsix"] # vsix file base name includes the extension version.

0 commit comments

Comments
 (0)