Skip to content

Commit

Permalink
Merge pull request #161 from shogo82148/improve-readme-github-actions
Browse files Browse the repository at this point in the history
Improve readme GitHub actions
  • Loading branch information
shogo82148 authored Jan 13, 2020
2 parents 482eb48 + 61665a2 commit 3dca685
Showing 1 changed file with 53 additions and 7 deletions.
60 changes: 53 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ test suite.

## Github Actions

[shogo82148/actions-goveralls](https://github.com/marketplace/actions/actions-goveralls) is available on GitHub Marketplace.
It provides the shorthand of the GitHub Actions YAML configure.

```yaml
name: Quality
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
on: [push, pull_request]
jobs:
test:
name: Test with Coverage
Expand All @@ -56,7 +54,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: '1.13'
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
Expand All @@ -71,6 +69,54 @@ jobs:
run: |
GO111MODULE=off go get github.com/mattn/goveralls
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
# or use shogo82148/actions-goveralls
# - name: Send coverage
# uses: shogo82148/actions-goveralls@v1
# with:
# path-to-profile: profile.cov
```

### Test with Legacy GOPATH mode

If you want to use Go 1.10 or earlier, you have to set `GOPATH` environment value and the working directory.
See <https://github.com/golang/go/wiki/GOPATH> for more detail.

Here is an example for testing `example.com/owner/repo` package.

```yaml
name: Quality
on: [push, pull_request]
jobs:
test:
name: Test with Coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.10'

# add this step
- name: Set up GOPATH
run: |
echo "::set-env name=GOPATH::${{ github.workspace }}"
echo "::add-path::${{ github.workspace }}/bin"
- name: Check out code
uses: actions/checkout@v2
with:
path: src/example.com/owner/repo # add this
- name: Run Unit tests
run: |
go test -race -covermode atomic -coverprofile=profile.cov ./...
working-directory: src/example.com/owner/repo # add this
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
GO111MODULE=off go get github.com/mattn/goveralls
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
working-directory: src/example.com/owner/repo # add this
```
## Travis CI
Expand Down

0 comments on commit 3dca685

Please sign in to comment.