-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
185 additions
and
3 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,69 @@ | ||
name: bench | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
env: | ||
GO111MODULE: "on" | ||
jobs: | ||
bench: | ||
strategy: | ||
matrix: | ||
go-version: [ 1.16.x ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Restore vendor | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
vendor | ||
key: ${{ runner.os }}-go${{ matrix.go-version }}-vendor-${{ hashFiles('**/go.mod') }} | ||
- name: Populate dependencies | ||
run: | | ||
(test -d vendor && echo vendor found) || (go mod vendor && du -sh vendor && du -sh ~/go/pkg/mod) | ||
- name: Restore benchstat | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/bin/benchstat | ||
key: ${{ runner.os }}-benchstat | ||
- name: Restore base benchmark result | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
bench-master.txt | ||
bench-main.txt | ||
# Use base sha for PR or new commit hash for master/main push in benchmark result key. | ||
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }} | ||
- name: Benchmark | ||
id: bench | ||
run: | | ||
export REF_NAME=${GITHUB_REF##*/} | ||
BENCH_COUNT=5 make bench-run bench-stat | ||
OUTPUT=$(make bench-stat) | ||
OUTPUT="${OUTPUT//'%'/'%25'}" | ||
OUTPUT="${OUTPUT//$'\n'/'%0A'}" | ||
OUTPUT="${OUTPUT//$'\r'/'%0D'}" | ||
echo "::set-output name=result::$OUTPUT" | ||
- name: Comment Benchmark Result | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
header: bench | ||
message: | | ||
### Benchmark Result | ||
<details><summary>Benchmark diff with base branch</summary> | ||
``` | ||
${{ steps.bench.outputs.result }} | ||
``` | ||
</details> |
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,75 @@ | ||
name: test-unit | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
env: | ||
GO111MODULE: "on" | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [ 1.16.x ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Restore base test coverage | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
unit-base.txt | ||
# Use base sha for PR or new commit hash for master/main push in test result key. | ||
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }} | ||
- name: Restore vendor | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
vendor | ||
key: ${{ runner.os }}-go${{ matrix.go-version }}-vendor-${{ hashFiles('**/go.mod') }} | ||
- name: Populate dependencies | ||
run: | | ||
(test -d vendor && echo vendor found) || (go mod vendor && du -sh vendor && du -sh ~/go/pkg/mod) | ||
- name: Test | ||
id: test | ||
run: | | ||
make test-unit | ||
go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > unit.txt | ||
OUTPUT=$(test -e unit-base.txt && (diff unit-base.txt unit.txt || exit 0) || cat unit.txt) | ||
OUTPUT="${OUTPUT//'%'/'%25'}" | ||
OUTPUT="${OUTPUT//$'\n'/'%0A'}" | ||
OUTPUT="${OUTPUT//$'\r'/'%0D'}" | ||
TOTAL=$(grep 'total:' unit.txt) | ||
echo "::set-output name=diff::$OUTPUT" | ||
echo "::set-output name=total::$TOTAL" | ||
- name: Store base coverage | ||
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} | ||
run: cp unit.txt unit-base.txt | ||
- name: Comment Test Coverage | ||
if: matrix.go-version == '1.16.x' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
header: unit-test | ||
message: | | ||
### Unit Test Coverage | ||
${{ steps.test.outputs.total }} | ||
<details><summary>Coverage diff with base branch</summary> | ||
```diff | ||
${{ steps.test.outputs.diff }} | ||
``` | ||
</details> | ||
- name: Upload code coverage | ||
if: matrix.go-version == '1.16.x' | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./unit.coverprofile | ||
flags: unittests |
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ linters: | |
- goerr113 | ||
- wrapcheck | ||
- exhaustivestruct | ||
- cyclop | ||
|
||
issues: | ||
exclude-use-default: false | ||
|
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
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
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
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,19 @@ | ||
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= | ||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= | ||
github.com/bool64/dev v0.1.18 h1:uMN5MsHrVWmtRoauefI8wD86b8vbXYnrCZlIhFGyuXI= | ||
github.com/bool64/dev v0.1.18/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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