diff --git a/.travis.yml b/.travis.yml index 680a500..3073a03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,15 +39,16 @@ env: - GO111MODULE=on - GOPROXY=https://proxy.golang.org -# When updating Go versions: -# In addition to changing the "go:" versions below, edit the version -# test in internal/runtests.sh. - jobs: + # When updating Go versions: + # In addition to changing the "go:" versions below, edit the version + # test in ./internal/runtests.sh. include: - - go: "1.13.x" + - go: "1.15.x" os: linux - - go: "1.13.x" + - go: "1.16.x" + os: linux + - go: "1.16.x" os: osx - - go: "1.13.x" + - go: "1.16.x" os: windows diff --git a/go.mod b/go.mod index b2233dc..7335ae1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,9 @@ go 1.12 require ( github.com/google/go-cmp v0.2.0 - github.com/google/subcommands v1.0.1 + github.com/google/subcommands v1.2.0 github.com/pmezard/go-difflib v1.0.0 - golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b + golang.org/x/mod v0.4.1 // indirect + golang.org/x/sys v0.0.0-20210216224549-f992740a1bac // indirect + golang.org/x/tools v0.1.0 ) diff --git a/go.sum b/go.sum index 132636d..ff9cc31 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,34 @@ github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/subcommands v1.0.1 h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k= -github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b h1:NVD8gBK33xpdqCaZVVtd6OFJp+3dxkXuz7+U7KaVN6s= -golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/alldeps b/internal/alldeps index e2ede73..7a7b3f0 100644 --- a/internal/alldeps +++ b/internal/alldeps @@ -1,4 +1,7 @@ github.com/google/subcommands github.com/google/wire github.com/pmezard/go-difflib +golang.org/x/mod +golang.org/x/sys golang.org/x/tools +golang.org/x/xerrors diff --git a/internal/check_api_change.sh b/internal/check_api_change.sh index fdbf988..19265ba 100755 --- a/internal/check_api_change.sh +++ b/internal/check_api_change.sh @@ -31,23 +31,19 @@ set -euo pipefail UPSTREAM_BRANCH="${TRAVIS_BRANCH:-master}" echo "Checking for incompatible API changes relative to ${UPSTREAM_BRANCH}..." -INSTALL_DIR="$(mktemp -d)" MASTER_CLONE_DIR="$(mktemp -d)" PKGINFO_BRANCH=$(mktemp) PKGINFO_MASTER=$(mktemp) function cleanup() { - rm -rf "$INSTALL_DIR" rm -rf "$MASTER_CLONE_DIR" rm -f "$PKGINFO_BRANCH" rm -f "$PKGINFO_MASTER" } trap cleanup EXIT -# Move to a temporary directory while installing apidiff to avoid changing -# the local .mod file. -( cd "$INSTALL_DIR" && exec go mod init unused ) -( cd "$INSTALL_DIR" && exec go install golang.org/x/exp/cmd/apidiff ) +# Install apidiff. +go install golang.org/x/exp/cmd/apidiff@latest git clone -b "$UPSTREAM_BRANCH" . "$MASTER_CLONE_DIR" &> /dev/null diff --git a/internal/runtests.sh b/internal/runtests.sh index 2e7915e..75fee90 100755 --- a/internal/runtests.sh +++ b/internal/runtests.sh @@ -41,16 +41,26 @@ if [[ "${TRAVIS_OS_NAME:-linux}" != "linux" ]]; then exit $result fi -echo -echo "Ensuring .go files are formatted with gofmt -s..." -mapfile -t go_files < <(find . -name '*.go' -type f | grep -v testdata) -DIFF="$(gofmt -s -d "${go_files[@]}")" -if [ -n "$DIFF" ]; then - echo "FAIL: please run gofmt -s and commit the result" - echo "$DIFF"; - result=1; -else - echo "OK" +# Update the regexp below when upgrading to a +# new Go version. Some checks below we only run +# for the latest Go version. +latest_go_version=0 +if [[ $(go version) == *go1\.16* ]]; then + latest_go_version=1 +fi + +if [[ ${latest_go_version} -eq 1 ]]; then + echo + echo "Ensuring .go files are formatted with gofmt -s..." + mapfile -t go_files < <(find . -name '*.go' -type f | grep -v testdata) + DIFF="$(gofmt -s -d "${go_files[@]}")" + if [ -n "$DIFF" ]; then + echo "FAIL: please run gofmt -s and commit the result" + echo "$DIFF"; + result=1; + else + echo "OK" + fi; fi; @@ -59,13 +69,13 @@ fi; # ./internal/alldeps # # Whenever project dependencies change, rerun ./internal/listdeps.sh -if [[ $(go version) == *go1\.12* ]]; then +if [[ ${latest_go_version} -eq 1 ]]; then echo echo "Ensuring that there are no dependencies not listed in ./internal/alldeps..." (./internal/listdeps.sh | diff ./internal/alldeps - && echo "OK") || { echo "FAIL: dependencies changed; run: internal/listdeps.sh > internal/alldeps" # Module behavior may differ across versions. - echo "using go version 1.12." + echo "using the latest go version." result=1 } fi @@ -73,7 +83,7 @@ fi # For pull requests, check if there are undeclared incompatible API changes. # Skip this if we're already going to fail since it is expensive. -if [[ ${result} -eq 0 ]] && [[ ! -z "${TRAVIS_BRANCH:-x}" ]] && [[ ! -z "${TRAVIS_PULL_REQUEST_SHA:-x}" ]]; then +if [[ ${latest_go_version} -eq 1 ]] && [[ ${result} -eq 0 ]] && [[ ! -z "${TRAVIS_BRANCH:-x}" ]] && [[ ! -z "${TRAVIS_PULL_REQUEST_SHA:-x}" ]]; then echo ./internal/check_api_change.sh || result=1; fi