refactor: remove duplicated code #1949
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-22.04 ] | |
go: [ '1.23' ] | |
name: Check ${{ matrix.os }} @ Go ${{ matrix.go }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go }} | |
- uses: actions/cache@v4 | |
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 lint | |
- run: make coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.out | |
fail_ci_if_error: false | |
benchmark: | |
needs: check | |
if: github.ref == 'refs/heads/main' | |
strategy: | |
matrix: | |
os: [ ubuntu-22.04 ] | |
go: [ '1.22' ] | |
name: Benchmark comparison ${{ matrix.os }} @ Go ${{ matrix.go }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
steps: | |
- name: Checkout Code (Previous) | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.base_ref }} | |
path: previous | |
- name: Checkout Code (New) | |
uses: actions/checkout@v4 | |
with: | |
path: new | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Install Dependencies | |
run: go install golang.org/x/perf/cmd/benchstat@latest | |
- name: Init (Previous) | |
working-directory: previous | |
run: make init | |
- name: Run Benchmark (Previous) | |
working-directory: previous | |
run: make benchmark test-options="-count=2" | tee benchmark.txt | |
- name: Init (New) | |
working-directory: new | |
run: make init | |
- name: Run Benchmark (New) | |
working-directory: new | |
run: make benchmark test-options="-count=2" | tee benchmark.txt | |
- name: Run Benchstat | |
run: benchstat previous/benchmark.txt new/benchmark.txt |