-
Notifications
You must be signed in to change notification settings - Fork 3
159 lines (136 loc) · 4.09 KB
/
Copy pathgo.yml
File metadata and controls
159 lines (136 loc) · 4.09 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Go
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
pull_request:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
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@v6
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@v6
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@v6
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 }}
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
needs: test
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@v6
with:
go-version: stable
# step 3: install main project dependencies
- name: Install main Go dependencies
run: go mod download
# step 4: install e2e test dependencies
- name: Install E2E test dependencies
run: cd tests/e2e && go mod download
# step 5: run e2e tests with verbose output
- name: Run E2E tests
run: cd tests/e2e && go test -v ./...