-
Notifications
You must be signed in to change notification settings - Fork 23
261 lines (227 loc) · 8.71 KB
/
ci.yml
File metadata and controls
261 lines (227 loc) · 8.71 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
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
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions: {}
env:
DOTNET_VERSION: '8.0.x'
NODE_VERSION: '20.x'
jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
psdocs: ${{ steps.filter.outputs.psdocs }}
psdocs-azure: ${{ steps.filter.outputs.psdocs-azure }}
vscode: ${{ steps.filter.outputs.vscode }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Detect changed paths
id: filter
run: |
if [ "${{ github.event_name }}" = "push" ]; then
BASE_SHA="${{ github.event.before }}"
else
BASE_SHA="${{ github.event.pull_request.base.sha }}"
fi
CHANGED=$(git diff --name-only "$BASE_SHA" "${{ github.sha }}" 2>/dev/null || echo "")
echo "psdocs=$(echo "$CHANGED" | grep -qE '^(packages/psdocs/|build/|scripts/|build\.ps1)' && echo true || echo false)" >> $GITHUB_OUTPUT
echo "psdocs-azure=$(echo "$CHANGED" | grep -qE '^(packages/psdocs-azure/|packages/psdocs/|build/|scripts/|build\.ps1)' && echo true || echo false)" >> $GITHUB_OUTPUT
echo "vscode=$(echo "$CHANGED" | grep -qE '^(packages/vscode-extension/|\.github/workflows/vscode-ci\.yml)' && echo true || echo false)" >> $GITHUB_OUTPUT
build-psdocs:
needs: changes
if: needs.changes.outputs.psdocs == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: |
7.0.x
${{ env.DOTNET_VERSION }}
- name: Setup PowerShell
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name InvokeBuild -MinimumVersion 5.4.0 -Scope CurrentUser -Force
if (Test-Path packages/psdocs/pipeline.build.ps1) {
Set-Location packages/psdocs
Invoke-Build Build -File ./pipeline.build.ps1
} else {
Write-Host "PSDocs package not yet added - skipping build"
}
- name: Test PSDocs
shell: pwsh
run: |
if (Test-Path packages/psdocs/pipeline.build.ps1) {
Set-Location packages/psdocs
Invoke-Build Test -File ./pipeline.build.ps1
}
- name: Upload PSDocs Module
if: success() && hashFiles('packages/psdocs/out/modules/PSDocs/**') != ''
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: psdocs-module
path: packages/psdocs/out/modules/PSDocs/
build-psdocs-azure:
needs: [changes, build-psdocs]
if: |
always() &&
(needs.changes.outputs.psdocs-azure == 'true' || github.event_name == 'push') &&
(needs.build-psdocs.result == 'success' || needs.build-psdocs.result == 'skipped')
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
shell: pwsh
timeout-minutes: 3
run: ./scripts/pipeline-deps.ps1
- name: Download PSDocs Module
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: psdocs-module
path: packages/psdocs/out/modules/PSDocs/
continue-on-error: true
- name: Install PSDocs from Gallery (fallback)
shell: pwsh
run: |
if (-not (Test-Path packages/psdocs/out/modules/PSDocs)) {
Install-Module -Name PSDocs -Scope CurrentUser -Force
}
- name: Build PSDocs.Azure
shell: pwsh
working-directory: packages/psdocs-azure
run: |
Invoke-Build Build -File ./pipeline.build.ps1 -Configuration Release -AssertStyle GitHubActions
- name: Upload PSDocs.Azure Module
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: psdocs-azure-module
path: packages/psdocs-azure/out/modules/PSDocs.Azure/
- name: Upload PSRule Results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: Module.PSRule.TestResults
path: packages/psdocs-azure/reports/ps-rule*.xml
retention-days: 3
if-no-files-found: ignore
test:
name: Test (${{ matrix.rid }}-${{ matrix.shell }})
needs: build-psdocs-azure
if: needs.build-psdocs-azure.result == 'success'
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
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:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- 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@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: psdocs-azure-module
path: packages/psdocs-azure/out/modules/PSDocs.Azure
- if: ${{ matrix.shell == 'pwsh' }}
name: Test module (PowerShell)
shell: pwsh
timeout-minutes: 15
working-directory: packages/psdocs-azure
run: Invoke-Build TestModule -File ./pipeline.build.ps1 -Configuration Release -AssertStyle GitHubActions
- if: ${{ matrix.shell == 'powershell' }}
name: Test module (Windows PowerShell)
shell: powershell
timeout-minutes: 30
working-directory: packages/psdocs-azure
run: Invoke-Build TestModule -File ./pipeline.build.ps1 -Configuration Release -AssertStyle GitHubActions
build-vscode:
needs: changes
if: needs.changes.outputs.vscode == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Check for VS Code extension
id: check
run: |
if [ -f "packages/vscode-extension/package.json" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.check.outputs.exists == 'true'
working-directory: packages/vscode-extension
run: npm ci
- name: Lint
if: steps.check.outputs.exists == 'true'
working-directory: packages/vscode-extension
run: npm run lint
- name: Build
if: steps.check.outputs.exists == 'true'
working-directory: packages/vscode-extension
run: npm run compile
- name: Package VSIX
if: steps.check.outputs.exists == 'true'
working-directory: packages/vscode-extension
run: npx @vscode/vsce package --out psdocs-vscode.vsix
- name: Upload VSIX
if: steps.check.outputs.exists == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: vscode-vsix
path: packages/vscode-extension/psdocs-vscode.vsix