Repository navigation
157 lines (135 loc) · 5.39 KB
/
Copy pathci.yml
File metadata and controls
157 lines (135 loc) · 5.39 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
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Check formatting
run: |
gofmt -w .
git diff --exit-code
- name: Check installer syntax
shell: bash
run: |
sh -n scripts/install.sh
pwsh -NoProfile -Command '$tokens = $null; $parseErrors = $null; [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path "scripts/install.ps1"), [ref]$tokens, [ref]$parseErrors) | Out-Null; if ($parseErrors.Count) { $parseErrors | ForEach-Object { Write-Error $_ }; exit 1 }'
- name: Test installer behavior
run: sh .github/test-install.sh
- name: Verify dependencies
run: |
go mod download
go mod verify
- name: Check known Go vulnerabilities
run: go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
- name: Vet
run: go vet ./...
- name: Test with race detector
run: go test -race -count=1 ./...
- name: Build
run: go build -trimpath ./...
- name: Verify release targets compile
shell: bash
run: |
set -euo pipefail
for target in darwin/arm64 darwin/amd64 linux/arm64 linux/amd64 windows/amd64; do
os="${target%/*}"
arch="${target#*/}"
output="${RUNNER_TEMP}/psirtmap-${os}-${arch}"
if [[ "$os" == "windows" ]]; then
output="${output}.exe"
fi
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
go build -trimpath -o "$output" .
done
# Every commit needs a Signed-off-by trailer asserting the contributor has
# the right to submit the change (see CONTRIBUTING.md). This checks the
# commits in the pull request, not just the merge commit, so a rebase or
# a squash can't paper over one that's missing it. Merge commits are
# excluded: they bring in another branch's already-certified history
# rather than contributing new content of their own.
dco:
name: DCO sign-off
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: every commit is signed off
run: |
set -euo pipefail
git fetch origin "${{ github.base_ref }}"
missing=""
for sha in $(git rev-list --no-merges "origin/${{ github.base_ref }}..HEAD"); do
if ! git log -1 --format=%B "$sha" | grep -qE '^Signed-off-by: .+ <.+>$'; then
missing="$missing$sha "
fi
done
if [ -n "$missing" ]; then
echo "commits missing a Signed-off-by trailer: $missing" >&2
echo "fix with: git rebase --signoff origin/${{ github.base_ref }}" >&2
exit 1
fi
# SonarQube Cloud analysis: quality gate, security/reliability/maintainability
# ratings and coverage, surfaced as README badges. Skipped on fork PRs, which
# cannot see the SONAR_TOKEN secret, and skipped entirely when no token is
# configured at all, so a repo without one shows a skipped check instead of
# a permanently failing one.
sonarqube:
name: SonarQube Cloud
runs-on: ubuntu-latest
# The `secrets` context can only be read from `env:` or `with:`, never
# from an `if:` at any level (job or step) - actionlint catches this,
# GitHub's own validator only fails the whole workflow file at run time,
# which is why every push and PR failed with zero jobs created. Stage it
# through a job-level env var instead, which `if:` can read.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
HAS_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN != '' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: env.HAS_SONAR_TOKEN == 'true'
with:
fetch-depth: 0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
if: env.HAS_SONAR_TOKEN == 'true'
with:
go-version-file: go.mod
cache: false
- name: coverage
if: env.HAS_SONAR_TOKEN == 'true'
run: go test -count=1 -coverprofile=coverage.out ./... || true
- name: SonarQube Cloud scan
if: env.HAS_SONAR_TOKEN == 'true'
uses: SonarSource/sonarqube-scan-action@d209202bc7d53ff1cc128f7f907dac145c9d6ae9 # v8.3.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
dependency-review:
name: Dependency review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Scan dependency changes
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
with:
config-file: ./.github/dependency-review-config.yml