Skip to content

Commit

Permalink
Run Travis & GH actions CI side by side (#314)
Browse files Browse the repository at this point in the history
Add initial GitHub workflow for running CI tests.
  • Loading branch information
armenzg authored Jan 14, 2021
1 parent db5fae9 commit 54ec3fa
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
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

0 comments on commit 54ec3fa

Please sign in to comment.