-
Notifications
You must be signed in to change notification settings - Fork 120
213 lines (172 loc) · 5.11 KB
/
build.yml
File metadata and controls
213 lines (172 loc) · 5.11 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Build and Test
permissions:
contents: write
packages: write
pages: write
on:
push:
branches:
- master
pull_request:
paths-ignore: ['docs/**', 'mkdocs.yml']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache-dependency-path: 'go.sum'
- name: Setup Protobuf
uses: ./.github/actions/setup-protobuf
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Cache npm packages
uses: actions/cache@v5
with:
path: |
internal/webui/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-npm-
- name: WebUI Build
run: |
cd internal/webui
yarn install --network-timeout 100000
yarn build
- name: Go Build
run: |
go generate ./api/pb/
go build ./cmd/pgwatch
- name: Upload webui as artifact
uses: actions/upload-artifact@v6
with:
name: webui-build
path: internal/webserver/build
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
test:
if: true # false to skip job during debug
needs: build
runs-on: ubuntu-latest
name: Test
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache-dependency-path: 'go.sum'
- name: Download webui artifact
uses: actions/download-artifact@v7
with:
name: webui-build
path: internal/webserver/build
- name: Setup Protobuf
uses: ./.github/actions/setup-protobuf
- name: Test
run: |
go generate ./api/pb/
go test -failfast -v -timeout=300s -p 1 -coverprofile=profile.cov ./cmd/... ./internal/...
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
file: profile.cov
goreleaser:
if: true # false to skip job during debug
needs: [build, test]
runs-on: ubuntu-latest
name: GoReleaser
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache-dependency-path: 'go.sum'
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Setup Protobuf
uses: ./.github/actions/setup-protobuf
- name: Generate protobuf files
run: go generate ./api/pb/
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --snapshot --skip=publish --clean
test-docker-images:
if: true # false to skip job during debug
needs: [build, test, goreleaser]
name: Test Docker Image Build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Prepare build metadata
id: meta
run: |
echo "GIT_HASH=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "GIT_TIME=$(git show -s --format=%cI HEAD)" >> $GITHUB_OUTPUT
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: Test build Docker image (fast, amd64 only)
uses: ./.github/actions/build-docker
with:
dockerfile: docker/Dockerfile
image-name: cybertecpostgresql/pgwatch
platforms: linux/amd64
push: 'false'
cache-scope: test-build
build-args: |
GIT_HASH=${{ steps.meta.outputs.GIT_HASH }}
GIT_TIME=${{ steps.meta.outputs.GIT_TIME }}
VERSION=${{ steps.meta.outputs.VERSION }}
build-docs:
if: true # false to skip job during debug
needs: [build, test]
name: Build Docs
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Configure Git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Set up gopages
run: go install github.com/johnstarich/go/gopages@v0.1.29
- name: Build Developer Docs
run: gopages -out "docs/godoc" -base "/devel/godoc" -internal
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install dependencies
run: pip install mike mkdocs-material mkdocs-glightbox
- name: Check if we should push to gh-pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
git fetch origin gh-pages --depth=1
echo "push_opt=--push" >> $GITHUB_ENV
- name: Build mkdocs
run: mike deploy ${{ env.push_opt }} devel