From eed490860711c787a1a313d17b25b4bd178b4849 Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Mon, 13 Jan 2020 16:04:04 +0900 Subject: [PATCH 1/2] add "Test with Legacy GOPATH mode" section --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 053fb10..fa2a4bf 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,7 @@ test suite. ```yaml name: Quality -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - master +on: [push, pull_request] jobs: test: name: Test with Coverage @@ -56,7 +51,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 @@ -73,6 +68,49 @@ jobs: $(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github ``` +### 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 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 ### GitHub Integration From 61665a284e62ab8ee2d4c8c5505a4475a219c3de Mon Sep 17 00:00:00 2001 From: Ichinose Shogo Date: Mon, 13 Jan 2020 17:03:18 +0900 Subject: [PATCH 2/2] add reference to shogo82148/actions-goveralls --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index fa2a4bf..ddf947d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ 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: [push, pull_request] @@ -66,6 +69,11 @@ 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