-
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (150 loc) · 4.75 KB
/
Copy pathci.yml
File metadata and controls
177 lines (150 loc) · 4.75 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Cancel in-progress runs when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
# Detect what files changed to skip tests on doc-only changes
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/**'
- '.golangci.yml'
- 'Makefile'
test:
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Download dependencies
run: go mod download
- name: Run unit tests
run: go test -v -race -timeout=10m ./...
lint:
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout 5m
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
run: govulncheck ./...
build:
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build
run: go build -v ./...
- name: Cross-compile check
run: |
echo "Cross-compiling for Linux (amd64)..."
GOOS=linux GOARCH=amd64 go build -v ./...
echo "Cross-compiling for Linux (arm64)..."
GOOS=linux GOARCH=arm64 go build -v ./...
echo "Cross-compiling for Windows (amd64)..."
GOOS=windows GOARCH=amd64 go build -v ./...
echo "Cross-compiling for macOS (amd64)..."
GOOS=darwin GOARCH=amd64 go build -v ./...
echo "Cross-compiling for macOS (arm64)..."
GOOS=darwin GOARCH=arm64 go build -v ./...
coverage:
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Run tests with coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
fail_ci_if_error: false
fuzz:
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Run fuzz tests (iso9660)
run: |
go test -fuzz='^FuzzISO9660Open$' -fuzztime=10s ./iso9660/
go test -fuzz='^FuzzParseCue$' -fuzztime=10s ./iso9660/
- name: Run fuzz tests (binary)
run: |
go test -fuzz='^FuzzFindBytes$' -fuzztime=10s ./internal/binary/
go test -fuzz='^FuzzFindBytesInRange$' -fuzztime=10s ./internal/binary/
go test -fuzz='^FuzzCleanString$' -fuzztime=10s ./internal/binary/
go test -fuzz='^FuzzExtractPrintable$' -fuzztime=10s ./internal/binary/
go test -fuzz='^FuzzBytesEqual$' -fuzztime=10s ./internal/binary/
- name: Run fuzz tests (identifier)
run: |
go test -fuzz='^FuzzSNESIdentify$' -fuzztime=10s ./identifier/
go test -fuzz='^FuzzN64Identify$' -fuzztime=10s ./identifier/
go test -fuzz='^FuzzGenesisIdentify$' -fuzztime=10s ./identifier/
go test -fuzz='^FuzzGBIdentify$' -fuzztime=10s ./identifier/