-
Notifications
You must be signed in to change notification settings - Fork 6
175 lines (153 loc) · 4.88 KB
/
Copy pathci.yml
File metadata and controls
175 lines (153 loc) · 4.88 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# CI pipeline for octo-speech
# Runs on every pull request targeting main or release/** branches.
# Designed to be used as required status checks in branch rulesets.
name: CI
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
branches:
- main
- 'release/**'
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "docs/**"
- ".github/ISSUE_TEMPLATE/**"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GO_VERSION: '1.25.x'
jobs:
changes:
name: Detect changed paths
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
code: ${{ github.event_name == 'pull_request' && steps.filter.outputs.code || 'true' }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
if: github.event_name == 'pull_request'
with:
persist-credentials: false
- uses: dorny/paths-filter@6852f92c20ea7fd3b0c25de3b5112db3a98da050 # v3
id: filter
if: github.event_name == 'pull_request'
with:
predicate-quantifier: 'every'
filters: |
code:
- '!**/*.md'
- '!docs/**'
- '!.github/ISSUE_TEMPLATE/**'
build:
needs: [changes]
if: |
(github.event_name != 'pull_request' || !github.event.pull_request.draft) &&
needs.changes.outputs.code == 'true'
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build speech binary
run: CGO_ENABLED=0 go build -v ./cmd/speech/...
- name: Build admin binary
run: CGO_ENABLED=0 go build -v ./cmd/admin/...
test:
needs: [changes]
if: |
(github.event_name != 'pull_request' || !github.event.pull_request.draft) &&
needs.changes.outputs.code == 'true'
name: Test
runs-on: ubuntu-latest
timeout-minutes: 30
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: demo
MYSQL_DATABASE: test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -pdemo"
--health-interval=5s
--health-timeout=5s
--health-retries=20
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install MySQL client tooling
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq mysql-client
- name: Wait for MySQL
run: |
for _ in $(seq 1 30); do
if mysqladmin ping -h 127.0.0.1 -uroot -pdemo --silent; then
echo "mysql ready"
exit 0
fi
sleep 2
done
echo "mysql did not become ready" >&2
exit 1
- name: Run tests
run: |
set -euo pipefail
fail=0
while read -r pkg; do
mysql -h 127.0.0.1 -uroot -pdemo -e "DROP DATABASE IF EXISTS test; CREATE DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
echo "::group::go test $pkg"
if ! go test -race -shuffle=on -count=1 -timeout 5m "$pkg"; then
fail=1
fi
echo "::endgroup::"
done < <(go list ./...)
exit $fail
vet:
needs: [changes]
if: |
(github.event_name != 'pull_request' || !github.event.pull_request.draft) &&
needs.changes.outputs.code == 'true'
name: Vet
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Vet
run: go vet ./...
lint:
needs: [changes]
if: |
(github.event_name != 'pull_request' || !github.event.pull_request.draft) &&
needs.changes.outputs.code == 'true'
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.12.2
args: --timeout=5m