all: fix Github Workflow for tests, drop Travis

This commit is contained in:
Robert van Gent
2021-08-30 15:21:53 -07:00
committed by GitHub
parent 8b20581338
commit 737d4615ed
6 changed files with 33 additions and 100 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text eol=lf

View File

@@ -18,15 +18,8 @@ jobs:
build: build:
strategy: strategy:
matrix: 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] os: [ubuntu-latest, macos-latest, windows-latest]
go-version: 1.17.x go-version: [1.17.x]
# Also run previous version of Go, but only on Ubuntu.
include:
- os: ubuntu-latest
go-version: 1.16.x
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Install Go - name: Install Go
@@ -35,5 +28,8 @@ jobs:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Test with:
run: './internal/runtests.sh' fetch-depth: 2 # required for codecov
- name: Run Tests
shell: bash
run: 'internal/runtests.sh'

View File

@@ -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

View File

@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//go:build wireinject
// +build wireinject // +build wireinject
// The build tag makes sure the stub is not built in the final build. // The build tag makes sure the stub is not built in the final build.

View File

@@ -1,6 +1,7 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run github.com/google/wire/cmd/wire
//go:build !wireinject
// +build !wireinject // +build !wireinject
package main package main

View File

@@ -24,7 +24,7 @@ fi
# Run Go tests. Only do coverage for the Linux build # Run Go tests. Only do coverage for the Linux build
# because it is slow, and codecov will only save the last one anyway. # because it is slow, and codecov will only save the last one anyway.
result=0 result=0
if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then if [[ "${RUNNER_OS:-}" == "Linux" ]]; then
echo "Running Go tests (with coverage)..." echo "Running Go tests (with coverage)..."
go test -mod=readonly -race -coverpkg=./... -coverprofile=coverage.out ./... || result=1 go test -mod=readonly -race -coverpkg=./... -coverprofile=coverage.out ./... || result=1
if [ -f coverage.out ] && [ $result -eq 0 ]; then if [ -f coverage.out ] && [ $result -eq 0 ]; then
@@ -36,20 +36,11 @@ else
fi fi
# No need to run other checks on OSs other than linux. # 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. # We default RUNNER_OS to "Linux" so that we don't abort here when run locally.
if [[ "${TRAVIS_OS_NAME:-linux}" != "linux" ]]; then if [[ "${RUNNER_OS:-Linux}" != "Linux" ]]; then
exit $result exit $result
fi 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
echo "Ensuring .go files are formatted with gofmt -s..." echo "Ensuring .go files are formatted with gofmt -s..."
mapfile -t go_files < <(find . -name '*.go' -type f | grep -v testdata) mapfile -t go_files < <(find . -name '*.go' -type f | grep -v testdata)
@@ -61,7 +52,6 @@ if [[ ${latest_go_version} -eq 1 ]]; then
else else
echo "OK" echo "OK"
fi; fi;
fi;
# Ensure that the code has no extra dependencies (including transitive # Ensure that the code has no extra dependencies (including transitive
@@ -69,7 +59,6 @@ fi;
# ./internal/alldeps # ./internal/alldeps
# #
# Whenever project dependencies change, rerun ./internal/listdeps.sh # Whenever project dependencies change, rerun ./internal/listdeps.sh
if [[ ${latest_go_version} -eq 1 ]]; then
echo echo
echo "Ensuring that there are no dependencies not listed in ./internal/alldeps..." echo "Ensuring that there are no dependencies not listed in ./internal/alldeps..."
(./internal/listdeps.sh | diff ./internal/alldeps - && echo "OK") || { (./internal/listdeps.sh | diff ./internal/alldeps - && echo "OK") || {
@@ -78,12 +67,11 @@ if [[ ${latest_go_version} -eq 1 ]]; then
echo "using the latest go version." echo "using the latest go version."
result=1 result=1
} }
fi
# For pull requests, check if there are undeclared incompatible API changes. # For pull requests, check if there are undeclared incompatible API changes.
# Skip this if we're already going to fail since it is expensive. # 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 echo
./internal/check_api_change.sh || result=1; ./internal/check_api_change.sh || result=1;
fi fi