-
Notifications
You must be signed in to change notification settings - Fork 15
226 lines (193 loc) · 7.16 KB
/
test.yml
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: Test
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
paths:
- .github/workflows/test.yml
- cmd/**/*.go
- testdata/**/*
- makefile
- .golangci.yml
- go.mod
- go.sum
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Declare default permissions as read only.
permissions: read-all
jobs:
lint:
name: Lint
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: go.mod
check-latest: true
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: latest
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Check formatting
run: |
make format-check
vulnerability-check:
name: "Vulnerability check"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Scan for Vulnerabilities
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
with:
go-version-file: go.mod
check-latest: true
go-package: ./...
# Make sure local_repository.pidx is linted against PackIndex.xsd
xmllint:
name: Xmllint
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install libxml2-utils
- name: Check if local_repository.pidx is valid
run: |
make test-xmllint-localrepository
test-amd64:
strategy:
matrix:
# Tests on Mac are currently broken
goos: [windows, linux, darwin]
include:
- goos: windows
runs-on: windows-latest
- goos: linux
runs-on: ubuntu-latest
- goos: darwin
runs-on: macos-latest
name: "${{ matrix.goos }} | amd64"
runs-on: ${{ matrix.runs-on }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@14d61e6e75e3f3c74551d757ad936e8e88014464 # v2.1.0
- name: Run unit tests
run: |
mkdir -p build
make test > build/cpackgettests-${{ matrix.goos }}-amd64.txt
- name: Generate JUnit test report
if: always()
run: |
go-junit-report -set-exit-code -in build/cpackgettests-${{ matrix.goos }}-amd64.txt -iocopy -out build/cpackget-testreport-${{ matrix.goos }}-amd64.xml
- name: Publish coverage report to Code Climate
if: ${{ startsWith(matrix.runs-on, 'ubuntu') && (github.workflow != 'Release') }}
uses: paambaati/codeclimate-action@f429536ee076d758a24705203199548125a28ca7 # v9.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
debug: true
coverageLocations: ./cover.out:gocov
prefix: github.com/open-cmsis-pack/cpackget
- name: Archive unit test results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: test-results-${{ matrix.goos }}-amd64
path: ./build/cpackget-testreport-${{ matrix.goos }}-amd64.xml
if-no-files-found: error
test-linux-arm64:
name: "linux | arm64"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Unit testing
uses: uraimo/run-on-arch-action@ac33288c3728ca72563c97b8b88dda5a65a84448 # v2
with:
arch: aarch64
distro: ubuntu_latest
env: |
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
install: |
apt-get update -qq -y
apt-get install -qq -y software-properties-common git make
add-apt-repository -y ppa:longsleep/golang-backports
apt-get update -qq -y
apt-get install -qq -y golang-1.22
setup: |
mkdir -p "${PWD}/artifacts"
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts"
run: |
export PATH=$PATH:/usr/lib/go-1.22/bin
git clone --depth 1 ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
cd cpackget
git fetch --depth 1 origin ${GITHUB_REF}
git checkout FETCH_HEAD
mkdir -p build
make test > build/cpackgettests-linux-arm64.txt
cp build/cpackgettests-linux-arm64.txt "/artifacts/cpackgettests-linux-arm64.txt"
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: '1.22'
check-latest: true
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@14d61e6e75e3f3c74551d757ad936e8e88014464 # v2.1.0
- name: Generate JUnit test report
run: |
go-junit-report -set-exit-code -in ${PWD}/artifacts/cpackgettests-linux-arm64.txt -iocopy -out ./cpackget-testreport-linux-arm64.xml
- name: Archive unit test results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: test-results-linux-arm64
path: ./cpackget-testreport-linux-arm64.xml
if-no-files-found: error