CI: pin a commit when testing against Go tip

Since it changes rapidly, especially during merge cycles, and we don't
want CI to surprisingly blow up in our faces from one day to another.

Pin this to a commit from yesterday which works, since some changes
merged today moved where the Go build version is recorded and broke
garble.

While at it, replace "git clone" with a wget of a source archive. This
is much, much faster, mainly because a tarball is significantly smaller.
We now download about 20MiB instead of over 350MiB.

One downside is that, without git, make.bash can't construct a devel
version on its own. For that reason, add a pretty basic manual version
via the VERSION file.

This means that we must not reject custom devel version strings. This is
a good thing anyway, because custom devel strings are already common
when building Go in custom ways. Those people tend to be advanced users,
such as CI, so fall back to assuming they know what they are doing and
don't error.

Plus, starting last week, devel versions in Go master now contain the
major Go version like in build tags, such as "go1.17-commit...", so we
will soon start relying on that instead of parsing dates:

	$ go version
	go version devel go1.17-a7e16abb22 Thu Apr 8 07:33:58 2021 +0000 linux/amd64
pull/306/head
Daniel Martí 3 years ago
parent d38dfd4e90
commit 5de519694a

@ -30,9 +30,18 @@ jobs:
continue-on-error: true # master breaks sometimes continue-on-error: true # master breaks sometimes
steps: steps:
- name: Install Go - name: Install Go
env:
GO_COMMIT: f60aa7a18cedd8f09dabbef9840893442fd2bda4 # 2021-04-07
run: | run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip cd $HOME
cd $HOME/gotip/src mkdir $HOME/gotip
cd $HOME/gotip
wget -O gotip.tar.gz https://go.googlesource.com/go/+archive/${GO_COMMIT}.tar.gz
tar -xf gotip.tar.gz
echo "devel go1.17-${GO_COMMIT}" >VERSION
cd src
./make.bash ./make.bash
echo "GOROOT=$HOME/gotip" >>$GITHUB_ENV echo "GOROOT=$HOME/gotip" >>$GITHUB_ENV
echo "$HOME/gotip/bin" >>$GITHUB_PATH echo "$HOME/gotip/bin" >>$GITHUB_PATH

@ -204,16 +204,16 @@ How to install Go: https://golang.org/doc/install
// Remove commit hash and architecture from version // Remove commit hash and architecture from version
startDateIdx := strings.IndexByte(commitAndDate, ' ') + 1 startDateIdx := strings.IndexByte(commitAndDate, ' ') + 1
endDateIdx := strings.LastIndexByte(commitAndDate, ' ') endDateIdx := strings.LastIndexByte(commitAndDate, ' ')
if endDateIdx <= 0 { if endDateIdx <= 0 || endDateIdx <= startDateIdx {
fmt.Fprintf(os.Stderr, "Can't recognize devel build timestamp") // Custom version; assume the user knows what they're doing.
return false return true
} }
date := commitAndDate[startDateIdx:endDateIdx] date := commitAndDate[startDateIdx:endDateIdx]
versionDate, err := time.Parse(gitTimeFormat, date) versionDate, err := time.Parse(gitTimeFormat, date)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Can't recognize devel build timestamp: %v\n", err) // Custom version; assume the user knows what they're doing.
return false return true
} }
if versionDate.After(minGoVersionDate) { if versionDate.After(minGoVersionDate) {

@ -9,16 +9,6 @@ env GO_VERSION=''
! garble build ! garble build
stderr 'Can''t get Go version' stderr 'Can''t get Go version'
# An invalid devel string.
env GO_VERSION='go version devel someinvalidversion'
! garble build
stderr 'Can''t recognize devel build timestamp'
# An invalid devel date.
env GO_VERSION='go version devel +afb5fca Sun Sep 99 99:99:99 9999 +0000 linux/amd64'
! garble build
stderr 'Can''t recognize devel build timestamp: parsing time'
# We should error on a devel version that's too old. # We should error on a devel version that's too old.
env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64' env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64'
! garble build ! garble build
@ -40,6 +30,11 @@ env GO_VERSION='go version go1.16.2 windows/amd64'
! garble build ! garble build
stderr 'mocking the real build' stderr 'mocking the real build'
# We should accept custom devel strings.
env GO_VERSION='go version devel somecustomversion linux/amd64'
! garble build
stderr 'mocking the real build'
-- go.mod -- -- go.mod --
module test/main module test/main

Loading…
Cancel
Save