Added benchmark testings #110
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
name: action | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Build | |
run: go build -v ./... | |
- name: Lint | |
uses: golangci/golangci-lint-action@v3 | |
- name: Test | |
run: | | |
n=0 | |
until go test -cpu 2 -timeout 2m -race -v ./...; do | |
if [ $n -ge 3 ]; then | |
exit 1 | |
fi | |
echo Test coverage failed, retrying in 3 seconds... | |
n=$(($n+1)) | |
sleep 3 | |
done | |
- name: Perform benchmark testing | |
run: go test -bench=Benchmark . -run Benchmark | |
- name: Test coverage | |
run: | | |
until go test -v -p 1 -covermode=count -coverprofile=coverage.out ./...; do | |
echo Test coverage failed, retrying in 3 seconds... | |
sleep 3 | |
done | |
- name: Tool cover to func | |
run: go tool cover -func=coverage.out -o=cover.out | |
- name: Obtain coverage | |
run: echo "COVERAGE=$(grep -e 'total' cover.out | awk '{print $3;}')" >> $GITHUB_ENV | |
- name: Create coverage badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: c77b22000b3e249510dfb4542847c708 | |
filename: test_coverage.json | |
label: coverage | |
message: ${{ env.COVERAGE }} | |
valColorRange: ${{ env.COVERAGE }} | |
maxColorRange: 100 | |
minColorRange: 0 | |
- name: Tool cover to html | |
run: go tool cover -html=coverage.out -o=cover.html | |
- name: Upload html coverage | |
uses: exuanbo/actions-deploy-gist@v1 | |
with: | |
token: ${{ secrets.GIST_SECRET }} | |
gist_id: c77b22000b3e249510dfb4542847c708 | |
file_path: cover.html | |
file_type: text |