-
Notifications
You must be signed in to change notification settings - Fork 53
363 lines (309 loc) · 8.82 KB
/
build.yaml
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#
# CI Pipeline
#
# NOTES:
# This workflow builds and tests PSRule components.
# During this process linting and analysis tools are used to ensure code quality.
# You can read more about these linting tools and configuration options here:
# PSRule - https://aka.ms/ps-rule and https://github.com/Microsoft/PSRule.Rules.MSFT.OSS
# CodeQL - https://codeql.github.com/docs/codeql-overview/about-codeql/
# DevSkim - https://github.com/microsoft/DevSkim-Action and https://github.com/Microsoft/DevSkim
name: Build
on:
push:
branches: [main, 'release/*']
pull_request:
branches: [main, 'release/*']
schedule:
- cron: '24 22 * * 0' # At 10:24 PM, on Sunday each week
workflow_dispatch: {}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
permissions: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install dependencies
shell: pwsh
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1
- name: Build module
shell: pwsh
timeout-minutes: 5
run: Invoke-Build -Configuration Release -AssertStyle GitHubActions
- name: Lint .NET
shell: pwsh
timeout-minutes: 5
run: dotnet format --verify-no-changes
- name: Upload module
uses: actions/upload-artifact@v4
with:
name: Module
path: ./out/modules/PSRule/*
retention-days: 3
if-no-files-found: error
- name: Upload PSRule Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Results-PSRule
path: ./reports/ps-rule*.xml
retention-days: 3
if-no-files-found: error
test:
name: 🧪 Test (${{ matrix.rid }}-${{ matrix.shell }})
runs-on: ${{ matrix.os }}
needs: build
permissions:
contents: read
strategy:
# Get full test results from all platforms.
fail-fast: false
matrix:
os: ['ubuntu-latest']
rid: ['linux-x64']
shell: ['pwsh']
include:
- os: windows-latest
rid: win-x64
shell: pwsh
- os: windows-latest
rid: win-x64
shell: powershell
- os: ubuntu-latest
rid: linux-x64
shell: pwsh
- os: ubuntu-latest
rid: linux-musl-x64
shell: pwsh
- os: macos-latest
rid: osx-x64
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- if: ${{ matrix.shell == 'pwsh' }}
name: Install dependencies (PowerShell)
shell: pwsh
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1
- if: ${{ matrix.shell == 'powershell' }}
name: Install dependencies (Windows PowerShell)
shell: powershell
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1
- name: Download module
uses: actions/download-artifact@v4
with:
name: Module
path: ./out/modules/PSRule
- if: ${{ matrix.shell == 'pwsh' }}
name: Test module (PowerShell)
shell: pwsh
timeout-minutes: 15
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions
- if: ${{ matrix.shell == 'powershell' }}
name: Test module (Windows PowerShell)
shell: powershell
timeout-minutes: 30
run: Invoke-Build TestModule -Configuration Release -AssertStyle GitHubActions
build_extension:
name: Build extension
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install dependencies
timeout-minutes: 3
run: |
npm install --global @vscode/vsce --force
npm install
dotnet restore
- name: Build extension
timeout-minutes: 3
run: |
mkdir -p out/package/
npm run package -- 0.0.1
- name: Upload extension
uses: actions/upload-artifact@v4
with:
name: Extension
path: out/package/vscode-ps-rule-*.vsix
retention-days: 3
if-no-files-found: error
test_extension:
name: 🧪 Test extension (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build_extension
permissions:
contents: read
strategy:
# Get full test results from all platforms.
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
timeout-minutes: 3
run: |
npm install
- name: Configure environment
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Run tests
timeout-minutes: 5
run: |
npm test
env:
DISPLAY: ':99.0'
build_docs:
name: Build docs
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: 'x64'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install wheel
python3 -m pip install -r requirements-docs.txt
- name: Build site
run: mkdocs build
env:
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ secrets.GITHUB_TOKEN }}
# ------------------
# Run analysis tools
# ------------------
oss:
name: 🔍 Analyze with PSRule
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run PSRule analysis
uses: microsoft/[email protected]
with:
modules: PSRule.Rules.MSFT.OSS
prerelease: true
outputFormat: Sarif
outputPath: reports/ps-rule-results.sarif
option: ps-rule-ci.yaml
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: reports/ps-rule-results.sarif
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: PSRule-Sarif
path: reports/ps-rule-results.sarif
retention-days: 1
if-no-files-found: error
devskim:
name: 🔍 Analyze with DevSkim
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
with:
directory-to-scan: .
- name: Upload results to security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: devskim-results.sarif
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: DevSkim-Sarif
path: devskim-results.sarif
retention-days: 1
if-no-files-found: error
codeql:
name: 🔍 Analyze with CodeQL
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: 'csharp'
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
id: codeql-analyze
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: CodeQL-Sarif
path: ${{ steps.codeql-analyze.outputs.sarif-output }}
retention-days: 1
if-no-files-found: error