-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (130 loc) · 3.62 KB
/
Copy pathci.yml
File metadata and controls
158 lines (130 loc) · 3.62 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
# Continuous Integration Workflow
# Runs tests, linting, and build checks on all code changes
name: CI
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
workflow_dispatch:
inputs:
debug:
description: 'Enable debug logging'
required: false
default: 'false'
type: boolean
# Cancel in-progress runs for the same branch
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION_FILE: go.mod
GOWORK: off
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
cache: true
- name: Download dependencies
run: go mod download
- name: Build
run: go build -o /dev/null ./...
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
cache: true
- name: Download dependencies
run: go mod download
- name: Run tests with race detection
run: go test -p 1 -race -v ./...
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
cache: true
- name: Download dependencies
run: go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: latest
skip-cache: true
args: --timeout=5m
proto:
name: Proto
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for breaking change detection
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
cache: true
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint protos
run: buf lint
- name: Check for breaking changes
if: github.event_name == 'pull_request'
env:
BASE_REF: ${{ github.base_ref }}
run: |
git fetch origin $BASE_REF:$BASE_REF
buf breaking --against ".git#branch=${BASE_REF}"
- name: Verify generated code is up-to-date
run: |
buf generate
if [ -n "$(git status --porcelain api/proto/gen)" ]; then
echo "::error::Generated proto code is out of date. Run 'make proto' and commit."
git diff api/proto/gen
exit 1
fi
ci-complete:
name: CI Complete
runs-on: ubuntu-latest
needs: [build, test, lint, proto]
if: always()
steps:
- name: Check results
env:
BUILD_RESULT: ${{ needs.build.result }}
TEST_RESULT: ${{ needs.test.result }}
LINT_RESULT: ${{ needs.lint.result }}
PROTO_RESULT: ${{ needs.proto.result }}
run: |
if [ "$BUILD_RESULT" == "failure" ] || [ "$TEST_RESULT" == "failure" ] || [ "$LINT_RESULT" == "failure" ] || [ "$PROTO_RESULT" == "failure" ]; then
echo "CI failed"
exit 1
fi
echo "CI passed"