fix CI and improve benchmark reporting #102
Workflow file for this run
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: Go | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: read | |
pull-requests: write | |
statuses: write | |
checks: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: "stable" | |
- name: Build | |
run: go build -v ./... | |
- name: Install go-junit-report | |
run: go install github.com/jstemmer/go-junit-report/v2@latest | |
- name: Run Tests and Generate Test Report | |
run: | | |
mkdir -p reports | |
go test -v ./... 2>&1 | go-junit-report > reports/report.xml | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: 'reports/report.xml' | |
check_name: 'Go Tests' | |
comment_title: 'Go Test Results' | |
commit: ${{ github.event.pull_request.head.sha || github.sha }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
hide_comments: 'all but latest' | |
deduplicate_classes_by_file_name: true | |
benchmark: | |
name: Run Go benchmarks | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.x' | |
- name: Run benchmarks | |
run: | | |
mkdir -p benchmarks | |
go test -bench . -benchmem -run=^$ ./... > benchmarks/benchmark.txt | |
- name: Post Benchmark Results | |
uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
tool: 'go' | |
output-file-path: 'benchmarks/benchmark.txt' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
ref: 'main' | |
comment-on-alert: true | |
alert-threshold: '15%' | |
fail-on-alert: true | |
summary-always: true |