-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Travis & GH actions CI side by side (#314)
Add initial GitHub workflow for running CI tests.
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: go-workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
jobs: | ||
golang-tests: | ||
name: tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
matrix: | ||
go-version: ["1.15", "1.14", "1.13"] | ||
go111module: ["on", "off"] | ||
include: | ||
# includes goflags when go111module is on | ||
- go111module: "on" | ||
goflags: -mod=readonly | ||
env: | ||
GO111MODULE: ${{ matrix.go111module }} | ||
# XXX: Investigate why GOPATH is needed for Modules off | ||
GOPATH: ${{ github.workspace }} | ||
# Required for building with GOPATH | ||
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-a-gopath-build | ||
defaults: | ||
run: | ||
working-directory: ${{ github.workspace }}/src/github.com/getsentry/sentry-go | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# Relative path under Github workspace | ||
path: ${{ github.workspace }}/src/github.com/getsentry/sentry-go | ||
# Getting all history enables using `git merge-base origin/master HEAD` | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version}} | ||
- name: Adjustments for Module mode enabled | ||
if: matrix.go111module == 'on' | ||
run: | | ||
echo "GOFLAGS=${{ matrix.goflags }}" >> $GITHUB_ENV | ||
- name: Adjustments for Module mode disabled | ||
if: matrix.go111module == 'off' | ||
run: | | ||
# Iris does not supported in legacy GOPATH mode. We delete the source code | ||
# because otherwise lint, build, and test steps would fail. | ||
rm -vrf ./iris/ ./example/iris/ | ||
# go get is not required in Module mode | ||
go get -v -t ./... | ||
- name: Build | ||
run: go build ./... | ||
- name: Tests | ||
run: | | ||
go test ./... | ||
go test ./... -race | ||
- name: Run linting if Go Module is on | ||
if: matrix.go111module == 'on' | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.27.0/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 | ||
git fetch origin master:remotes/origin/master | ||
$(go env GOPATH)/bin/golangci-lint run --new-from-rev=$(git merge-base origin/master HEAD) | ||
golang-outside-gopath: | ||
name: Module support outside GOPATH | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
env: | ||
GO111MODULE: on | ||
GOFLAGS: -mod=readonly | ||
GOPATH: ${{ github.workspace }} | ||
# Required for building with GOPATH | ||
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-a-gopath-build | ||
defaults: | ||
run: | ||
working-directory: ${{ env.GOPATH }}/src/github.com/getsentry/sentry-go | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# Relative path under Github workspace | ||
path: src/github.com/getsentry/sentry-go | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
- name: Run tests outside of GOPATH | ||
run: | | ||
mv $GOPATH/src/github.com/getsentry/sentry-go ~/sentry-go | ||
cd ~/sentry-go | ||
export GOPATH= | ||
go env GOPATH | ||
go test ./... | ||
go test ./... -race | ||