Repository navigation
86 lines (72 loc) · 2.85 KB
/
Copy pathCI_go.yml
File metadata and controls
86 lines (72 loc) · 2.85 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
# The plugins build, are formatted and vetted, and their tests pass with the race
# detector. Two guards keep plugins self-contained:
# - imports: only this module, the standard library and the approved dependencies;
# - network: net/http only in the fetch layer (core/fetch/, core/kit/) and the
# openapi test kit (kinds/openapi/openapitest/, recorded responses over httptest).
# The steps are Makefile targets, so `make check` runs exactly this locally.
# Until the Go code lands there is no go.mod, and every step after the first is skipped
# with a notice, so the check passes.
name: CI_go
on:
pull_request:
merge_group:
workflow_dispatch:
permissions:
contents: read
# A new push cancels the run it supersedes.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
go:
name: go build, vet, gofmt, test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: is there Go code yet
id: go
run: |
if [ -f go.mod ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::No go.mod yet: no Go packages to check. CI_go passes until the plugin code lands."
echo "present=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-go@v7
if: steps.go.outputs.present == 'true'
with:
go-version-file: go.mod
cache-dependency-path: go.sum
# Each step is a Makefile target; `make check` runs the same ones (plus
# the internal-names check) locally.
- name: go.mod and go.sum are tidy
if: steps.go.outputs.present == 'true'
run: make tidy
- name: go build
if: steps.go.outputs.present == 'true'
run: make build
- name: gofmt
if: steps.go.outputs.present == 'true'
run: make fmt
- name: go vet
if: steps.go.outputs.present == 'true'
run: make vet
# An allowlist (ALLOWED in the Makefile), so a plugin can't pull in a
# database driver, a cloud SDK or anything private. Adding a dependency
# means adding it there, in review.
- name: imports are this module, the standard library or approved
if: steps.go.outputs.present == 'true'
run: make imports
# Plugins fetch through env.Get / kit, never on their own.
- name: net/http only in the fetch layer
if: steps.go.outputs.present == 'true'
run: make nethttp
# A provider scaffolded with new-plugin, with a TODO(new-plugin) left.
- name: no TODO(new-plugin) left
if: steps.go.outputs.present == 'true'
run: make todos
# -race: the fetcher and the tests' HTTP servers run on other goroutines.
- name: go test
if: steps.go.outputs.present == 'true'
run: make test