Repository navigation
226 lines (203 loc) · 7.56 KB
/
Copy pathvalidate.yaml
File metadata and controls
226 lines (203 loc) · 7.56 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
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Validate
on:
# Post-merge validation only. Feature branches are validated by their
# pull_request run, so a branch push with an open PR no longer triggers
# a duplicate (previously cancelled) push run.
push:
branches:
- master
# All pull requests.
pull_request:
branches:
- '**'
# Least-privilege token; the validate workflow only needs to read the repo.
permissions:
contents: read
# A push and its pull_request both trigger this workflow on the same
# branch. Group them so only one full matrix runs, and cancel runs that
# are superseded by a newer commit on the same branch/PR.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
build:
name: Validate on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- run: go test ./...
- run: go build -o cmd/desync/ ./cmd/desync
# Fast signal for the BSD builds. The VM jobs below run the actual
# tests, but they have to boot a VM first, so a broken build is
# reported here within seconds instead of minutes. Covers every BSD
# release artifact target; dragonfly is amd64-only in Go.
- name: Cross-compile BSDs
if: runner.os == 'Linux'
run: |
for target in freebsd/amd64 freebsd/arm64 netbsd/amd64 netbsd/arm64 \
openbsd/amd64 openbsd/arm64 dragonfly/amd64; do
echo "==> $target"
GOOS=${target%/*} GOARCH=${target#*/} go build -o /dev/null ./cmd/desync
done
- name: Race detector
if: runner.os == 'Linux'
run: go test -race ./...
- name: Static analysis
if: runner.os == 'Linux'
run: |
go vet ./...
test -z "$(gofmt -l .)" || { echo "Files need gofmt:"; gofmt -l .; exit 1; }
go mod tidy -diff
# Separate from the build matrix so lint failures and test failures are
# reported side by side rather than one hiding the other.
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
# Runs errcheck, govet, ineffassign, staticcheck and unused; see
# .golangci.yml for what is enabled and why.
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.12
# The reference under docs/cli is generated, so it can only be wrong by
# being stale. Regenerating and diffing is what keeps it honest.
- name: CLI reference is current
run: |
go run ./cmd/desync gendocs docs/cli
git add -N docs/cli
git diff --exit-code docs/cli
# The hand-written docs describe options in their own words, which the
# generated reference can't check. This at least catches a flag that
# doesn't exist: the README shipped a `--writeable` that was really
# `--writable`, in a command meant to be copied and pasted. Checked
# against the generated pages, which are the only source of truth for
# what the commands actually define.
- name: Documented flags exist
run: |
allow='--hard-dereference|--rm'
missing=""
for f in $(grep -ohE -- '--[a-z0-9][a-z0-9-]+' README.md docs/*.md docs/cli/README.md | sort -u); do
echo "$f" | grep -qE "^($allow)$" && continue
grep -qhE -- "\\$f([^a-z0-9-]|$)" docs/cli/desync*.md || missing="$missing $f"
done
if [ -n "$missing" ]; then
echo "docs mention flags that no command defines:$missing"
exit 1
fi
# govulncheck reports only vulnerabilities the code actually reaches, so a
# finding here is worth acting on rather than triaging away. It runs on the
# current stable toolchain rather than the go.mod version: most findings are
# in the standard library, and the fix for those is a Go upgrade, which is
# exactly what this should be telling us.
vulncheck:
name: Vulnerabilities
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: stable
- run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
# None of the BSDs have a GitHub-hosted runner, so their tests run in a VM on
# the Linux runner. Booting one costs a few minutes, hence the separate jobs
# rather than steps in the matrix above. They can't be a matrix either: the
# VM image is chosen by which action is named in `uses`, and that field
# doesn't accept expressions.
#
# `go version` is echoed because the toolchain comes from each system's own
# package repo. Those lag, and go.mod sets a minimum, so "the package is too
# old" is the failure mode worth being able to read straight off the log.
#
# -buildvcs=false because git exits 128 on the rsynced-in tree, which would
# otherwise fail the build over version stamping rather than anything about
# the code. Release builds stamp via goreleaser's ldflags regardless.
freebsd:
name: Validate on FreeBSD
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Test in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
usesh: true
copyback: false
prepare: |
pkg install -y go
run: |
go version
go test ./...
go build -buildvcs=false -o cmd/desync/ ./cmd/desync
netbsd:
name: Validate on NetBSD
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Test in NetBSD VM
uses: vmactions/netbsd-vm@v1
with:
usesh: true
copyback: false
prepare: |
/usr/sbin/pkg_add go
run: |
# pkgsrc has no unversioned `go`: the meta-package installs no
# files of its own, and the versioned one it depends on lands as
# /usr/pkg/bin/go126 plus /usr/pkg/go126/bin/go. Glob for it rather
# than hard-coding a version that pkgsrc will bump. Only the one
# the meta-package pulled in is installed, so this matches once.
PATH=$(ls -d /usr/pkg/go[0-9]*/bin 2>/dev/null | tail -1):/usr/pkg/bin:$PATH
export PATH
go version
go test ./...
go build -buildvcs=false -o cmd/desync/ ./cmd/desync
openbsd:
name: Validate on OpenBSD
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Test in OpenBSD VM
uses: vmactions/openbsd-vm@v1
with:
usesh: true
copyback: false
prepare: |
pkg_add -I go
run: |
go version
go test ./...
go build -buildvcs=false -o cmd/desync/ ./cmd/desync
dragonfly:
name: Validate on DragonFly BSD
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Test in DragonFly BSD VM
uses: vmactions/dragonflybsd-vm@v1
with:
usesh: true
copyback: false
prepare: |
pkg install -y go
run: |
go version
go test ./...
go build -buildvcs=false -o cmd/desync/ ./cmd/desync