diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcadb2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0ea8357..4a6b29e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,15 +18,8 @@ jobs: build: strategy: matrix: - # Run most recent version of Go on all supported OSs. - # When updating Go versions, also edit the version test in - # internal/runtests.sh. os: [ubuntu-latest, macos-latest, windows-latest] - go-version: 1.17.x - # Also run previous version of Go, but only on Ubuntu. - include: - - os: ubuntu-latest - go-version: 1.16.x + go-version: [1.17.x] runs-on: ${{ matrix.os }} steps: - name: Install Go @@ -35,5 +28,8 @@ jobs: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v2 - - name: Test - run: './internal/runtests.sh' + with: + fetch-depth: 2 # required for codecov + - name: Run Tests + shell: bash + run: 'internal/runtests.sh' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3073a03..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2018 The Wire Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -language: go -go_import_path: github.com/google/wire - -before_install: - # The Bash that comes with OS X is ancient. - # grep is similar: it's not GNU grep, which means commands aren't portable. - # Homebrew installs grep as ggrep if you don't build from source, so it needs - # moving so it takes precedence in the PATH. - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - HOMEBREW_NO_AUTO_UPDATE=1 brew install bash grep; - mv $(brew --prefix)/bin/ggrep $(brew --prefix)/bin/grep; - fi - -install: - # Re-checkout files preserving line feeds. This prevents Windows builds from - # converting \n to \r\n. - - "git config --global core.autocrlf input" - - "git checkout -- ." - -script: - - 'internal/runtests.sh' - -env: - global: - - GO111MODULE=on - - GOPROXY=https://proxy.golang.org - -jobs: - # When updating Go versions: - # In addition to changing the "go:" versions below, edit the version - # test in ./internal/runtests.sh. - include: - - go: "1.15.x" - os: linux - - go: "1.16.x" - os: linux - - go: "1.16.x" - os: osx - - go: "1.16.x" - os: windows diff --git a/_tutorial/wire.go b/_tutorial/wire.go index a0e0571..9f5b747 100644 --- a/_tutorial/wire.go +++ b/_tutorial/wire.go @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build wireinject +//go:build wireinject +// +build wireinject // The build tag makes sure the stub is not built in the final build. package main diff --git a/_tutorial/wire_gen.go b/_tutorial/wire_gen.go index 46ce25c..7a93a7b 100644 --- a/_tutorial/wire_gen.go +++ b/_tutorial/wire_gen.go @@ -1,7 +1,8 @@ // Code generated by Wire. DO NOT EDIT. //go:generate go run github.com/google/wire/cmd/wire -//+build !wireinject +//go:build !wireinject +// +build !wireinject package main diff --git a/internal/runtests.sh b/internal/runtests.sh index 75fee90..11f9d5f 100755 --- a/internal/runtests.sh +++ b/internal/runtests.sh @@ -24,7 +24,7 @@ fi # Run Go tests. Only do coverage for the Linux build # because it is slow, and codecov will only save the last one anyway. result=0 -if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then +if [[ "${RUNNER_OS:-}" == "Linux" ]]; then echo "Running Go tests (with coverage)..." go test -mod=readonly -race -coverpkg=./... -coverprofile=coverage.out ./... || result=1 if [ -f coverage.out ] && [ $result -eq 0 ]; then @@ -36,31 +36,21 @@ else fi # No need to run other checks on OSs other than linux. -# We default TRAVIS_OS_NAME to "linux" so that we don't abort here when run locally. -if [[ "${TRAVIS_OS_NAME:-linux}" != "linux" ]]; then +# We default RUNNER_OS to "Linux" so that we don't abort here when run locally. +if [[ "${RUNNER_OS:-Linux}" != "Linux" ]]; then exit $result fi -# 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; +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; @@ -69,21 +59,19 @@ fi; # ./internal/alldeps # # Whenever project dependencies change, rerun ./internal/listdeps.sh -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 the latest go version." - result=1 - } -fi +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 the latest go version." + result=1 +} # 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 [[ ${latest_go_version} -eq 1 ]] && [[ ${result} -eq 0 ]] && [[ ! -z "${TRAVIS_BRANCH:-x}" ]] && [[ ! -z "${TRAVIS_PULL_REQUEST_SHA:-x}" ]]; then +if ${result} -eq 0 ]] && [[ ! -z "${GITHUB_HEAD_REF:-x}" ]]; then echo ./internal/check_api_change.sh || result=1; fi