Skip to content

Commit

Permalink
Realign Go versions with x-go dependent projects
Browse files Browse the repository at this point in the history
As of today the minimum Go version for projects directly or
indirectly dependant on x-go is as follows:

snapd:  Go v1.18 (tracking but not importing x-go)
chisel: Go v1.18 (not currently using x-go)
pebble: Go v1.14 (importing x-go)

- Update x-go to match the minimum Go version of Pebble
  (1.13 => 1.14)
- Update the gopkg.in/yaml.v2 package used by strutil to match Snapd
  (2.3.0 => 2.4.0)
- Change CI tests to Go v1.14 and Go v1.18
  • Loading branch information
flotter committed May 17, 2023
1 parent 0ccdb0b commit d665a0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.19', '1.18', '1.13']
go: ['1.14', '1.18']

name: run-checks-with-go-v${{ matrix.go }}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/canonical/x-go

go 1.13
go 1.14

require (
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2 v2.4.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
27 changes: 17 additions & 10 deletions run-checks
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,25 @@ run() {
fi
}

# Install staticcheck from the correct source so that it
# will compile and install for the Go version on the host.
#
# shellcheck disable=SC2317
#
install_staticcheck() {
pkg="honnef.co/go/tools/cmd/staticcheck"
# go1.18+ will no longer build/install packages. Here "go install"
# must be used but it will only fetch remote packages if the @latest
# (or similar syntax is used). Instead of checking the version we
# check if the "go install" help mentions this new feature.
if go help install | grep -q @latest; then
# Go v1.8+
go install "${pkg}"@latest
# We build from source to make this architecture independent.
# However, staticcheck releases are dependent on specific Go
# versions, so we cannot simply build the latest.
PKG="honnef.co/go/tools/cmd/staticcheck"
GO_VERSION="$(go version | cut -d' ' -f3 | cut -d'.' -f1-2 | sed 's/go//' | sed 's/\.//')"

# This list will be updated as x-go moves to later Go versions.
if [ "$GO_VERSION" -ge "118" ]; then
# Go v1.18
go install "${PKG}@2022.1.3"
else
# Go v1.3
go get "${pkg}@2019.2.3"
# Go v1.14
go get "${PKG}@2021.1.2"
fi
}

Expand Down

0 comments on commit d665a0c

Please sign in to comment.