ci: bump to go 1.20 (#375)

* Update CI Go version to 1.20/1.19
* Update `golangci-lint` to v1.51.2
* Update coverage collection to use new Go 1.20 tools
* Update coverage job to only run on latest Go version

Fixes #367
This commit is contained in:
Michael McLoughlin
2023-03-05 14:22:23 -08:00
committed by GitHub
parent 881df56d21
commit 1bba0bed7f
13 changed files with 98 additions and 86 deletions

View File

@@ -15,6 +15,7 @@ jobs:
required:
needs:
- test
- coverage
- lint
runs-on: ubuntu-latest
steps:
@@ -22,7 +23,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.18.x, 1.19.x]
go-version: [1.19.x, 1.20.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
@@ -40,6 +41,22 @@ jobs:
run: go build ./...
- name: Test
run: go test -bench . ./...
coverage:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.20.x
check-latest: true
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false
- name: Bootstrap
run: ./script/bootstrap
- name: Coverage
run: ./script/coverage
- name: Upload Unit Test Coverage
@@ -60,7 +77,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

View File

@@ -11,7 +11,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:

View File

@@ -12,7 +12,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:

View File

@@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -52,7 +52,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -98,7 +98,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -145,7 +145,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -180,7 +180,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -217,7 +217,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -252,7 +252,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -290,7 +290,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -325,7 +325,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -360,7 +360,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -410,7 +410,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -461,7 +461,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -514,7 +514,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -567,7 +567,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -612,7 +612,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -647,7 +647,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -684,7 +684,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -721,7 +721,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -756,7 +756,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -791,7 +791,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -826,7 +826,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -861,7 +861,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -901,7 +901,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -936,7 +936,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -974,7 +974,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -1012,7 +1012,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -1047,7 +1047,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
@@ -1082,7 +1082,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout avo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

View File

@@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

View File

@@ -18,7 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
with:
go-version: 1.19.x
go-version: 1.20.x
check-latest: true
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

View File

@@ -5,6 +5,7 @@ linters:
disable:
- cyclop
- deadcode
- dupword
- errname
- exhaustruct
- exhaustivestruct

View File

@@ -3,7 +3,7 @@ package gotypes
import (
"go/token"
"go/types"
"strings"
"regexp"
"testing"
"golang.org/x/tools/go/packages"
@@ -118,17 +118,22 @@ func TestParseSignature(t *testing.T) {
func TestParseSignatureErrors(t *testing.T) {
cases := []struct {
Expr string
ErrorContains string
Expr string
ErrorPattern string
}{
{"idkjklol", "undeclared name"},
{"struct{}", "not a function signature"},
{"uint32(0xfeedbeef)", "should have nil value"},
{"idkjklol", `(undeclared|undefined)`}, // error message changed in go 1.20
{"struct{}", `not a function signature`},
{"uint32(0xfeedbeef)", `should have nil value`},
}
for _, c := range cases {
errrx, err := regexp.Compile(c.ErrorPattern)
if err != nil {
t.Fatal(err)
}
s, err := ParseSignature(c.Expr)
if s != nil || err == nil || !strings.Contains(err.Error(), c.ErrorContains) {
t.Errorf("expect error from expression %s\ngot: %s\nexpect substring: %s\n", c.Expr, err, c.ErrorContains)
if s != nil || err == nil || !errrx.MatchString(err.Error()) {
t.Errorf("expect error from expression %s\ngot: %s\nexpect match: %s\n", c.Expr, err, c.ErrorPattern)
}
}
}

View File

@@ -17,7 +17,7 @@ type mov struct {
}
// NewMOV generates a function that will auto-select the correct MOV instruction
// based on operand types and and sizes.
// based on operand types and sizes.
func NewMOV(cfg printer.Config) Interface {
return GoFmt(&mov{cfg: cfg})
}

View File

@@ -4,16 +4,13 @@
go install ./internal/cmd/asmvet
# golangci-lint for linting
golangci_lint_version='v1.49.0'
golangci_lint_version='v1.51.2'
golangci_install_script="https://raw.githubusercontent.com/golangci/golangci-lint/${golangci_lint_version}/install.sh"
curl -sfL "${golangci_install_script}" | sh -s -- -b "$(go env GOPATH)/bin" "${golangci_lint_version}"
# embedmd required for documentation generation
go install github.com/campoy/embedmd@v1.0.0
# covertool for merging coverage reports
go install github.com/dlespiau/covertool@v0.0.0-20180314162135-b0c4c6d0583a
# asmfmt for enforcing assembly style
go install github.com/klauspost/asmfmt/cmd/asmfmt@v1.3.2

View File

@@ -1,7 +1,17 @@
#!/bin/bash -ex
#!/bin/bash
set -euo pipefail
ext=".coverprofile"
# Temporary working directory.
workdir=$(mktemp -d)
function cleanup() {
rm -rf "${workdir}"
}
trap cleanup EXIT
# Clean existing coverage files.
find . -name '*'${ext} | xargs rm -f
@@ -9,16 +19,27 @@ find . -name '*'${ext} | xargs rm -f
go test -covermode=count -coverprofile=unittests${ext} ./...
# Integration test coverage.
coverprofiles=()
#
# Collect for each individual avo assembly generator.
coverbase="${workdir}/cover"
coversingle="${coverbase}/test"
mkdir -p "${coversingle}"
coverdirs=()
for main in $(find . -name 'asm.go'); do
dir=$(dirname ${main})
name=$(basename ${dir})
coverprofile="${dir}/${name}${ext}"
./script/covermain ${main} ${coverprofile} > /dev/null
coverprofiles+=(${coverprofile})
coverdir="${coversingle}/${name}"
mkdir "${coverdir}"
GOCOVERDIR="${coverdir}" go run -tags=integration -cover "${main}" -out /dev/null
coverdirs+=("${coverdir}")
done
covertool merge --output integration${ext} ${coverprofiles[@]}
# Merge.
covertool merge --output all${ext} unittests${ext} integration${ext}
# Merge integration test coverage.
covermergeinputs=$(IFS=","; echo "${coverdirs[*]}")
covermergeoutput="${coverbase}/merge"
mkdir "${covermergeoutput}"
go tool covdata merge -i="${covermergeinputs}" -o="${covermergeoutput}"
go tool covdata textfmt -i="${covermergeoutput}" -o="integration${ext}"

View File

@@ -1,29 +0,0 @@
#!/bin/bash -e
main=$1
coverprofile=$2
# Temporary working directory.
workdir=$(mktemp -d tmpXXXXXXXX)
# Wrap the main function in a go test.
cp ${main} ${workdir}
cat > ${workdir}/main_test.go <<EOF
package main
import "testing"
func TestRunMain(t *testing.T) {
main()
}
EOF
# Execute the test with coverage.
testbin="${workdir}/testbin"
output="${workdir}/cover.out"
go test -tags=integration -o ${testbin} -covermode=count -coverpkg="github.com/mmcloughlin/avo/..." ${workdir}/*.go
${testbin} -test.coverprofile=${output}
cp ${output} ${coverprofile}
# Cleanup.
rm -rf ${workdir}

View File

@@ -102,7 +102,7 @@ func GenerateWorkflow(s *thirdparty.Suite) ([]byte, error) {
g.Linef("- name: Install Go")
g.Linef(" uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1")
g.Linef(" with:")
g.Linef(" go-version: 1.19.x")
g.Linef(" go-version: 1.20.x")
g.Linef(" check-latest: true")
// Checkout avo.