refactor: change focus interface #1
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: check | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: ["push"] | |
jobs: | |
check: | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04, macos-latest ] | |
go: [ '1.21' ] | |
name: Check ${{ matrix.os }} @ Go ${{ matrix.go }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- run: make init | |
- run: make check test-options="-race --coverprofile=coverage.coverprofile --covermode=atomic" | |
- name: Upload coverage to Codecov | |
if: success() && matrix.go == '1.21' && matrix.os == 'ubuntu-20.04' | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.coverprofile | |
fail_ci_if_error: false | |
benchmark: | |
needs: check | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04 ] | |
go: [ '1.21' ] | |
name: Benchmark comparison ${{ matrix.os }} @ Go ${{ matrix.go }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
steps: | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
root-reserve-mb: 512 | |
swap-size-mb: 1024 | |
remove-dotnet: 'true' | |
- name: Checkout Code (Previous) | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.base_ref }} | |
path: previous | |
- name: Checkout Code (New) | |
uses: actions/checkout@v3 | |
with: | |
path: new | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Install Dependencies | |
run: go install golang.org/x/perf/cmd/benchstat@latest | |
- name: Init (Previous) | |
run: | | |
cd previous | |
make init | |
- name: Run Benchmark (Previous) | |
run: | | |
cd previous | |
go test -run="-" -bench=".*" -count=7 ./... | tee benchmark.txt | |
- name: Init (New) | |
run: | | |
cd new | |
make init | |
- name: Run Benchmark (New) | |
run: | | |
cd new | |
go test -run="-" -bench=".*" -count=7 ./... | tee benchmark.txt | |
- name: Run Benchstat | |
run: benchstat previous/benchmark.txt new/benchmark.txt |