implement benchmarks in ci #93
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 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: "stable" | |
- name: Install go-junit-report | |
run: go install github.com/jstemmer/go-junit-report@latest | |
- name: Build | |
run: go build -v ./... | |
- name: Run Tests and Generate JUnit Report | |
run: | | |
mkdir -p reports | |
go test -v ./... 2>&1 | go-junit-report > reports/report.xml | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: reports/report.xml | |
- name: Report Test Results | |
uses: dorny/[email protected] # Используем обновленную версию | |
if: always() # Обеспечивает выполнение шага даже при сбое тестов | |
with: | |
name: Go Tests | |
path: reports/report.xml | |
reporter: github-pr-review # Публикует результаты как комментарий в PR | |
fail-on-error: false # Не прерывает workflow при ошибках в отчете | |
require-tests: true # Указывает, что должны быть тесты | |
check-name: Unit Tests # Имя проверки в статусах PR | |
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: rhysd/github-action-benchmark@v1 | |
with: | |
tool: "go" | |
benchmark-data: benchmarks/benchmark.txt | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
compare-with: "main" # Измените на нужную вам ветку | |
comment-on-alert: true | |
alert-threshold: "15%" | |
fail-on-alert: true | |
summary-always: true |