-
Notifications
You must be signed in to change notification settings - Fork 5
99 lines (81 loc) · 2.48 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: CI
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 }}
- name: Cache Go Modules and Build
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-${{ runner.go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-${{ runner.go }}-${{ hashFiles('**/go.sum') }}
- name: Initialize Project
run: make init
- name: Run Linter
run: make lint
- name: Run Tests and Generate Coverage
run: make coverage
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
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 Previous Code
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
path: previous
- name: Checkout New Code
uses: actions/checkout@v4
with:
path: new
- name: Set up Go for Benchmarking
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install Benchmark Dependencies
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Initialize Previous Code
working-directory: previous
run: make init
- name: Run Benchmark (Previous)
working-directory: previous
run: make benchmark test-options="-count=2" | tee benchmark.txt
- name: Initialize New Code
working-directory: new
run: make init
- name: Run Benchmark (New)
working-directory: new
run: make benchmark test-options="-count=2" | tee benchmark.txt
- name: Compare Benchmark Results
run: benchstat previous/benchmark.txt new/benchmark.txt