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:
committed by
GitHub
parent
881df56d21
commit
1bba0bed7f
@@ -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
|
||||
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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}
|
||||
Reference in New Issue
Block a user