extension: update go to go1.23.1
We want to use the latest go when developing our own release/testing support tools and scripts. So, let's update go.mod to do so. After go1.21, we shouldn't use `go run` to run the extension/tools/installtools script. The purpose of `installtools` is to install tools needed by integration tests and are compatible with the go version in the system. We arranged the CI systems to test with the go versions we support. If we use `go run` from our project, the toolchain switch will occur and may change `GOROOT`/`PATH` to enforce the compiled script to use the upgraded toolchain. That makes the CI setup useless. Therefore, in this CL, we build the binary (it's ok to build the binary with go1.23.1+), and then run the installed binary ourselves so the execution of the binary doesn't get affected by the modified GOROOT/PATH. Kokoro CI also uses the installtools script when building the docker container. (build/Dockerfile) There, the script source code is copied over to a scratch space and run with `go run <go file>` outside the vscode-go project repo. So, there is no go toolchain version switch involved already. And currently we test only with the latest go in Kokoro, so this toolchain switch issue doesn't apply. For golang/vscode-go#3411 Change-Id: I3e116cf48fb431196359ec42049e70c0b75814ef Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/616677 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Hongxiang Jiang <hxjiang@golang.org> Commit-Queue: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Родитель
151e9d90ae
Коммит
538900fdd7
|
@ -37,7 +37,7 @@ jobs:
|
|||
check-latest: true
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install NPM dependencies
|
||||
run: npm ci
|
||||
working-directory: ./extension
|
||||
|
||||
|
@ -45,14 +45,11 @@ jobs:
|
|||
run: npm run vscode:prepublish
|
||||
working-directory: ./extension
|
||||
|
||||
- name: Install Go tools (Modules mode)
|
||||
- name: Install tools dependencies
|
||||
run: |
|
||||
go version
|
||||
go run ./tools/installtools/main.go
|
||||
go install ./tools/installtools
|
||||
installtools
|
||||
working-directory: ./extension
|
||||
env:
|
||||
GO111MODULE: on
|
||||
EXT: "${{ matrix.os == 'windows-latest' && '.exe' || ''}}"
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm run unit-test
|
||||
|
|
|
@ -36,7 +36,7 @@ jobs:
|
|||
check-latest: true
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install NPM dependencies
|
||||
run: npm ci
|
||||
working-directory: ./extension
|
||||
|
||||
|
@ -44,14 +44,11 @@ jobs:
|
|||
run: npm run vscode:prepublish
|
||||
working-directory: ./extension
|
||||
|
||||
- name: Install Go tools (Modules mode)
|
||||
- name: Install tools dependencies
|
||||
run: |
|
||||
go version
|
||||
go run ./tools/installtools/main.go
|
||||
go install ./tools/installtools
|
||||
installtools
|
||||
working-directory: ./extension
|
||||
env:
|
||||
GO111MODULE: on
|
||||
EXT: "${{ matrix.os == 'windows-latest' && '.exe' || ''}}"
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm run unit-test
|
||||
|
|
|
@ -43,14 +43,11 @@ jobs:
|
|||
run: npm run vscode:prepublish
|
||||
working-directory: ./extension
|
||||
|
||||
- name: Install Go tools (Modules mode)
|
||||
- name: Install tools dependencies
|
||||
run: |
|
||||
go version
|
||||
go run ./tools/installtools/main.go
|
||||
go install ./tools/installtools
|
||||
installtools
|
||||
working-directory: ./extension
|
||||
env:
|
||||
GO111MODULE: on
|
||||
EXT: "${{ matrix.os == 'windows-latest' && '.exe' || ''}}"
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm run unit-test
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
module github.com/golang/vscode-go/extension
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.9
|
||||
go 1.23.1
|
||||
|
||||
require (
|
||||
github.com/golang/vscode-go v0.0.0-00010101000000-000000000000
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Binary installtools is a helper that installs Go tools extension tests depend on.
|
||||
// In order to allow this script to use the go version in the sytem or your choice,
|
||||
// avoid running this with `go run` (that may auto-upgrade the toolchain to meet
|
||||
// the go version requirement in extension/go.mod).
|
||||
// Instead, build this script, and run the compiled executable.
|
||||
// For example,
|
||||
//
|
||||
// go build -o /tmp/script . && /tmp/script
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -61,6 +68,7 @@ func main() {
|
|||
if ver < 21 {
|
||||
exitf("unsupported go version: 1.%v", ver)
|
||||
}
|
||||
fmt.Printf("installing tools for go1.%d...\n", ver)
|
||||
|
||||
bin, err := goBin()
|
||||
if err != nil {
|
||||
|
@ -80,7 +88,9 @@ func exitf(format string, args ...interface{}) {
|
|||
// goVersion returns an integer N if go's version is 1.N.
|
||||
func goVersion() (int, error) {
|
||||
cmd := exec.Command("go", "list", "-e", "-f", `{{context.ReleaseTags}}`, "--", "unsafe")
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=off")
|
||||
// GO111MODULE=off implicitly disables GOTOOLCHAIN switch,
|
||||
// but let's make sure it doesn't change.
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=off", "GOTOOLCHAIN=local")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("go list error: %v", err)
|
||||
|
@ -106,7 +116,8 @@ func goBin() (string, error) {
|
|||
if gobin := os.Getenv("GOBIN"); gobin != "" {
|
||||
return gobin, nil
|
||||
}
|
||||
out, err := exec.Command("go", "env", "GOPATH").Output()
|
||||
cmd := exec.Command("go", "env", "GOPATH")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -119,21 +130,14 @@ func goBin() (string, error) {
|
|||
|
||||
func installTools(binDir string, goMinorVersion int) error {
|
||||
installCmd := "install"
|
||||
if goMinorVersion < 16 {
|
||||
installCmd = "get"
|
||||
}
|
||||
|
||||
dir := ""
|
||||
if installCmd == "get" { // run `go get` command from an empty directory.
|
||||
dir = os.TempDir()
|
||||
}
|
||||
env := append(os.Environ(), "GO111MODULE=on")
|
||||
// For tools installation, ensure GOTOOLCHAIN=auto.
|
||||
env := append(os.Environ(), "GO111MODULE=on", "GOTOOLCHAIN=auto")
|
||||
for _, tool := range tools {
|
||||
ver := pickVersion(goMinorVersion, tool.versions, pickLatest(tool.path, tool.preferPreview))
|
||||
path := tool.path + "@" + ver
|
||||
cmd := exec.Command("go", installCmd, path)
|
||||
cmd.Env = env
|
||||
cmd.Dir = dir
|
||||
fmt.Println("go", installCmd, path)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("installing %v: %s\n%v", path, out, err)
|
||||
|
|
Загрузка…
Ссылка в новой задаче