Repository navigation
188 lines (175 loc) · 6.43 KB
/
Copy pathci.yml
File metadata and controls
188 lines (175 loc) · 6.43 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
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
permissions: {}
env:
# renovate: datasource=github-releases depName=goreleaser/goreleaser
GORELEASER_VERSION: v2.20.3
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
permissions:
contents: read
pull-requests: read
checks: write
name: Linter
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Check approved Go release line
run: go env GOVERSION | grep -Eq '^go1\.26\.[0-9]+$'
- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.15.0
check-license:
name: License scan
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
env:
# renovate: datasource=go depName=github.com/google/go-licenses/v2
GO_LICENSES_VERSION: v2.0.1
REPORT_FILE: gl-license-scanning-report.json
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Verify MIT-0 license unsupported by go-licenses
run: |
go mod download github.com/segmentio/asm
printf '%s %s\n' \
cca993712df289a5958bdef69031a5dac0f951ac15afeb313f9eeea55ed59443 \
"$(go list -m -f '{{.Dir}}/LICENSE' github.com/segmentio/asm)" |
sha256sum --check
- name: License scanning
run: |
scripts/install-go-tool.sh "github.com/google/go-licenses/v2@${GO_LICENSES_VERSION}"
go-licenses check . --disallowed_types=forbidden,restricted --ignore=github.com/segmentio/asm/
- name: Generate license report
run: |
go-licenses report . --ignore=github.com/segmentio/asm/ > licenses.csv
printf 'github.com/segmentio/asm,https://github.com/segmentio/asm/blob/%s/LICENSE,MIT-0\n' \
"$(go list -m -f '{{.Version}}' github.com/segmentio/asm)" >> licenses.csv
- name: Save license scan report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: license_scanning
path: licenses.csv
check-go-releaser:
name: Go releaser check
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
with:
distribution: goreleaser
version: ${{ env.GORELEASER_VERSION }}
args: check
test:
name: Tests
needs:
- lint
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Run release orchestration tests
run: python3 -m unittest discover -s .github/scripts -p "test_*.py"
- name: Run tests
run: |
scripts/install-go-tool-test.sh
go test -v ./...
security:
name: GoReleaser artifacts - govulncheck, Trivy secrets/vulns, Grype
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
env:
# renovate: datasource=go depName=golang.org/x/vuln
GOVULNCHECK_VERSION: v1.9.0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Test govulncheck warning and error handling
run: scripts/govulncheck-inform-test.sh
- name: Install govulncheck
run: scripts/install-go-tool.sh "golang.org/x/vuln/cmd/govulncheck@${GOVULNCHECK_VERSION}"
- name: Report reachable Go vulnerabilities in the source
run: scripts/govulncheck-inform.sh ./...
- name: Test that the symbol-table guard rejects a stripped binary
run: scripts/assert-go-symbols-test.sh
- name: Build GoReleaser snapshot artifacts
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
with:
distribution: goreleaser
version: ${{ env.GORELEASER_VERSION }}
args: release --snapshot --clean --skip=publish
- name: Verify and prepare all release artifacts
run: scripts/prepare-artifact-scan-rootfs.sh
- name: Report reachable Go vulnerabilities in each release binary
run: scripts/govulncheck-release-binaries.sh
- name: Import release artifacts for scanning
run: docker import artifact-scan/rootfs.tar stackstate-backup-cli:security-scan
- name: Scan release artifacts with Trivy, Grype, and VEX
uses: StackVista/image-pipeline/.github/actions/scan-image@79dd6718168651ffc846eed98c3c0cb646eb15a0 # v1.0.1
with:
image: stackstate-backup-cli:security-scan
mode: inform
severity: CRITICAL,HIGH,MEDIUM,LOW
with-grype: "true"
upload-sarif: "false"
- name: Upload security evidence
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-artifact-security
path: |
artifact-scan/metadata/
dist/*_checksums.txt
reports/
if-no-files-found: warn