-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (122 loc) · 3.98 KB
/
Copy pathci.yml
File metadata and controls
150 lines (122 loc) · 3.98 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
name: CI
on:
push:
branches: [main]
paths:
- 'gearbox/**'
- '.github/workflows/ci.yml'
pull_request:
branches: [main]
paths:
- 'gearbox/**'
- '.github/workflows/ci.yml'
permissions: {}
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: ./gearbox
steps:
- name: Harden runner
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
with:
go-version-file: gearbox/go.mod
- name: Install Templ
run: go install github.com/a-h/templ/cmd/templ@v0.3.977
- name: Download dependencies
run: go mod download
- name: Generate Templ templates
run: templ generate
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
files: ./gearbox/coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: ./gearbox
steps:
- name: Harden runner
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
with:
go-version-file: gearbox/go.mod
- name: Install Templ
run: go install github.com/a-h/templ/cmd/templ@v0.3.977
- name: Generate Templ templates
run: templ generate
- name: Run golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
version: v2.8.0
working-directory: ./gearbox
args: --timeout=5m
build:
name: Build
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: ./gearbox
steps:
- name: Harden runner
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
with:
go-version-file: gearbox/go.mod
- name: Install Templ
run: go install github.com/a-h/templ/cmd/templ@v0.3.977
- name: Download dependencies
run: go mod download
- name: Generate Templ templates
run: templ generate
- name: Verify generated templates are up-to-date
run: |
git diff --exit-code -- '**/*_templ.go' || {
echo "::error::Generated templ files are out of date. Run 'templ generate' and commit the changes."
exit 1
}
- name: Build binary
run: |
CGO_ENABLED=0 go build \
-ldflags="-s -w -X main.Version=${{ github.ref_name }} -X main.CommitSHA=${{ github.sha }} -X main.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o bin/gearbox \
./cmd/server
- name: Upload binary artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: gearbox-${{ github.sha }}
path: gearbox/bin/gearbox
retention-days: 7