-
Notifications
You must be signed in to change notification settings - Fork 69
130 lines (112 loc) · 3.34 KB
/
Copy pathgo.yml
File metadata and controls
130 lines (112 loc) · 3.34 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Go
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
pull_request:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: run golangci-lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
test:
name: Test
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: run test
- name: Run coverage
run: go test -race -shuffle=on -count=1 -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./...
# step 5: upload coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
if: false
permissions:
contents: read
pull-requests: write
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: restore previous benchmark history (if exists)
- name: Restore benchmark history
id: benchmark-cache
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-benchmark-
# step 5: run benchmark
- name: Run benchmarks
run: go test -run=^$ -bench=. -benchmem ./... | tee benchmark.txt
# step 6: upload benchmark
- name: Upload benchmark results
uses: benchmark-action/github-action-benchmark@v1
with:
# What benchmark tool the benchmark.txt came from
tool: "go"
# Where the output from the benchmark tool is stored
output-file-path: benchmark.txt
# Where the previous data file is stored
external-data-json-path: ./cache/benchmark-data.json
# Workflow will fail when an alert happens
fail-on-alert: true
# step 7: persist updated benchmark history
- name: Save benchmark history
if: always()
uses: actions/cache/save@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}-${{ github.run_id }}