-
Notifications
You must be signed in to change notification settings - Fork 13
258 lines (235 loc) · 13 KB
/
continuous-integration.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
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
name: Continuous Integration
on:
push:
branches: [ master ]
paths:
- 'Source/**'
- '*.TXT'
- '*.MD'
pull_request:
branches: [ master ]
env:
ISHGITHUB_RUN_NUMBER: ${{ github.run_number }}
ISHGITHUB_SERVER_URL: ${{ github.server_url }}
ISHGITHUB_REPOSITORY: ${{ github.repository }}
ISHGITHUB_RUN_ID: ${{ github.run_id }}
jobs:
build:
runs-on: windows-latest
steps:
- name: PowerShell Update to latest stable (initially because 7.2.13/lts had issues, forced latest stable 7.3.6 or higher)
uses: bjompen/UpdatePWSHAction@v1.0.0
with:
ReleaseVersion: 'Stable'
- name: "Info: My Github Workflows Setup"
shell: pwsh
run: |
echo "My Github Workflows Setup Information..."
echo ("PSVersionTable info PSEdition["+$PSVersionTable.PSEdition+"] PSVersion["+$PSVersionTable.PSVersion+"]")
echo "GITHUB_ACTIONS[$env:GITHUB_ACTIONS]"
echo "GITHUB_WORKFLOW[$env:GITHUB_WORKFLOW]"
echo "GITHUB_RUN_NUMBER[$env:GITHUB_RUN_NUMBER]"
echo "GITHUB_RUN_ATTEMPT[$env:GITHUB_RUN_ATTEMPT]"
echo "ISHGITHUB_RUN_NUMBER[$env:ISHGITHUB_RUN_NUMBER]"
echo "ISHGITHUB_SERVER_URL[$env:ISHGITHUB_SERVER_URL]"
echo "ISHGITHUB_REPOSITORY[$env:ISHGITHUB_REPOSITORY]"
echo "ISHGITHUB_RUN_ID[$env:ISHGITHUB_RUN_ID]"
- uses: actions/checkout@v4
- name: Setup .NET 6.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Explicit restore of multi-target/conditional ProjectReference and dependencies
shell: pwsh
run: |
# See Github #180
# dotnet restore Source/ISHRemote/Trisoft.ISHRemote.OpenApiAM10\Trisoft.ISHRemote.OpenApiAM10.NET48.csproj
# dotnet restore Source/ISHRemote/Trisoft.ISHRemote.OpenApiAM10\Trisoft.ISHRemote.OpenApiAM10.NET60.csproj
# dotnet restore Source/ISHRemote/Trisoft.ISHRemote.OpenApiISH30\Trisoft.ISHRemote.OpenApiISH30.NET48.csproj
# dotnet restore Source/ISHRemote/Trisoft.ISHRemote.OpenApiISH30\Trisoft.ISHRemote.OpenApiISH30.NET60.csproj
dotnet restore Source/ISHRemote/ISHRemote.sln
- name: Build Solution
shell: pwsh
run: dotnet build --no-restore --no-incremental --configuration release Source/ISHRemote/ISHRemote.sln
- name: Setup PowerShell PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path Source/ISHRemote/Trisoft.ISHRemote/Scripts -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Warning "There were $($errors.Count) errors and $($warnings.Count) warnings total."
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
- name: Archive ISHRemote module
uses: actions/upload-artifact@v4
with:
name: ISHRemote-MainCI-Module
path: Source/ISHRemote/Trisoft.ISHRemote/bin/Release/ISHRemote/
- name: Pester Test Preparation (...products.com) on Windows using PowerShell 7.x
shell: pwsh
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: |
$filePath = 'Source/ISHRemote/Trisoft.ISHRemote/ISHRemote.PesterSetup.Debug.ps1'
Add-Content -Path $filePath -Value '# File[$filePath] is generated through continuous-integration.yml section PowerShell 7.x'
Add-Content -Path $filePath -Value '$baseUrl = $env:ISH_BASE_URL'
Add-Content -Path $filePath -Value 'if ($baseUrl -like "*.sdlproducts.com*")'
Add-Content -Path $filePath -Value '{'
Add-Content -Path $filePath -Value ' $ishEventTypeToPurge = ''TESTBACKGROUNDTASK''' # before 14SP4 use ''PUSHTRANSLATIONS'''
Add-Content -Path $filePath -Value ' $ishLngLabel = ''en-us'''
Add-Content -Path $filePath -Value ' $ishLngTarget1 = ''VLANGUAGEESES'''
Add-Content -Path $filePath -Value ' $ishLngTarget1Label = ''es-es'''
Add-Content -Path $filePath -Value ' $ishLngTarget2 = ''VLANGUAGEDEDE'''
Add-Content -Path $filePath -Value ' $ishLngTarget2Label = ''de-de'''
Add-Content -Path $filePath -Value ' $ishLngCombination = ''en-us'''
Add-Content -Path $filePath -Value '}'
- name: Pester Test Prerequisites on Windows using PowerShell 7.x
shell: pwsh
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: Invoke-Pester -Path Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/_TestEnvironment/TestPrerequisite.Tests.ps1 -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: ISHRemote-MainCI-PesterPrerequisiteOnPowerShellCore
path: Cmdlets.Pester.Tests.xml
- name: Pester Test Cmdlets on Windows using PowerShell 7.x
shell: pwsh
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: Invoke-Pester -Path Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/ -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: ISHRemote-MainCI-PesterOnPowerShellCore
path: Cmdlets.Pester.Tests.xml
if: ${{ always() }}
- name: Pester Test Preparation (...products.com) using Windows PowerShell 5.1
shell: powershell
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: |
$filePath = 'Source/ISHRemote/Trisoft.ISHRemote/ISHRemote.PesterSetup.Debug.ps1'
Add-Content -Path $filePath -Value '# File[$filePath] is generated through continuous-integration.yml section Windows PowerShell 5.1'
Add-Content -Path $filePath -Value '$baseUrl = $env:ISH_BASE_URL'
Add-Content -Path $filePath -Value 'if ($baseUrl -like "*.sdlproducts.com*")'
Add-Content -Path $filePath -Value '{'
Add-Content -Path $filePath -Value ' $ishEventTypeToPurge = ''TESTBACKGROUNDTASK''' # before 14SP4 use ''PUSHTRANSLATIONS'''
Add-Content -Path $filePath -Value ' $ishLngLabel = ''en-us'''
Add-Content -Path $filePath -Value ' $ishLngTarget1 = ''VLANGUAGEESES'''
Add-Content -Path $filePath -Value ' $ishLngTarget1Label = ''es-es'''
Add-Content -Path $filePath -Value ' $ishLngTarget2 = ''VLANGUAGEDEDE'''
Add-Content -Path $filePath -Value ' $ishLngTarget2Label = ''de-de'''
Add-Content -Path $filePath -Value ' $ishLngCombination = ''en-us'''
Add-Content -Path $filePath -Value '}'
- name: Pester Test Prerequisites using Windows PowerShell 5.1
shell: powershell
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: Invoke-Pester -Path Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/_TestEnvironment/TestPrerequisite.Tests.ps1 -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: ISHRemote-MainCI-PesterPrerequisiteOnWindowsPowerShell
path: Cmdlets.Pester.Tests.xml
- name: Pester Test Cmdlets using Windows PowerShell 5.1
shell: powershell
env:
ISH_BASE_URL: ${{ secrets.ISH_BASE_URL }}
ISH_USER_NAME: ${{ secrets.ISH_USER_NAME }}
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
run: Invoke-Pester -Path Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/ -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: ISHRemote-MainCI-PesterOnWindowsPowerShell
path: Cmdlets.Pester.Tests.xml
if: ${{ always() }}
- name: "Publish to PowerShellGallery if commit holds [PublishToPSGalleryAsPreview]"
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
if: ${{ success() && contains(github.event.head_commit.message, '[PublishToPSGalleryAsPreview]') }}
shell: pwsh
run: |
$packageRootFolderPath = "Source/ISHRemote/Trisoft.ISHRemote/bin/Release/ISHRemote/"
$manifestFilePath = Join-Path -Path $packageRootFolderPath -ChildPath "ISHRemote.psd1"
$manifestFileInfo = Get-ChildItem $manifestFilePath
if ($manifestFileInfo -eq $null) { echo "File[$manifestFilePath] not found" }
$moduleManifest = Test-ModuleManifest -Path $manifestFileInfo.FullName
$moduleManifestFileVersion = $moduleManifest.Version
$moduleManifestFileUpdateVersion = $moduleManifest.PrivateData.PSData['Prerelease']
$fullVersion = "$moduleManifestFileVersion-$moduleManifestFileUpdateVersion"
$remoteModule = Find-Module -Name ISHRemote -Repository PSGallery -AllowPrerelease
if($remoteModule.Version -ne $fullVersion)
{
echo ("Found earlier module[ISHRemote] of version["+($remoteModule.Version)+"]. Publishing module with version[$fullVersion]!")
Publish-Module -Path $packageRootFolderPath -Repository PSGallery -NuGetApiKey $env:NUGET_API_KEY -Verbose -Force #-WhatIf -ErrorAction:Continue
}
else
{
echo ("Found recent module[ISHRemote] of version["+($remoteModule.Version)+"]. Skipping publish of module with version[$fullVersion]!")
}
- name: "Publish to PowerShellGallery if commit holds [PublishToPSGalleryAsRelease]"
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
if: ${{ success() && contains(github.event.head_commit.message, '[PublishToPSGalleryAsRelease]') }}
shell: pwsh
run: |
$packageRootFolderPath = "Source/ISHRemote/Trisoft.ISHRemote/bin/Release/ISHRemote/"
$manifestFilePath = Join-Path -Path $packageRootFolderPath -ChildPath "ISHRemote.psd1"
$manifestFileInfo = Get-ChildItem $manifestFilePath
if ($manifestFileInfo -eq $null) { echo "File[$manifestFilePath] not found" }
(Get-Content -Raw -Path $ManifestFilePath).Replace('Prerelease = ','# Prerelease = ') | Set-Content -Path $ManifestFilePath
$moduleManifest = Test-ModuleManifest -Path $manifestFileInfo.FullName
$moduleManifestFileVersion = $moduleManifest.Version
$fullVersion = "$moduleManifestFileVersion"
$remoteModule = Find-Module -Name ISHRemote -Repository PSGallery
if($remoteModule.Version -ne $fullVersion)
{
echo ("Found earlier module[ISHRemote] of version["+($remoteModule.Version)+"]. Publishing module with version[$fullVersion]!")
Publish-Module -Path $packageRootFolderPath -Repository PSGallery -NuGetApiKey $env:NUGET_API_KEY -Verbose -Force -WhatIf #-ErrorAction:Continue
}
else
{
echo ("Found recent module[ISHRemote] of version["+($remoteModule.Version)+"]. Skipping publish of module with version[$fullVersion]!")
}
- name: "Info: How to publish to Internal/Nexus Repositories"
shell: pwsh
run: |
echo "Either the steps below or in-house https://jenkins-docs.web.sdldev.net/job/Publish-ISHRemote/ job that downloads and publishes to Nexus"
echo "1. Login to Github, navigate to $env:ISHGITHUB_SERVER_URL/$env:ISHGITHUB_REPOSITORY/actions/runs/$env:ISHGITHUB_RUN_ID"
echo "2. Download ISHRemote-MainCI-Module artefact to C:\TEMP\ISHRemote\ISHRemote-MainCI-Module.zip"
echo "3. In a PowerShell Session..."
echo "3a. Remove-Item -Path C:\TEMP\ISHRemote\ToPublish -Recurse -Force"
echo "3b. Expand-Archive -Path C:\TEMP\ISHRemote\ISHRemote-MainCI-Module.zip -DestinationPath C:\TEMP\ISHRemote\ToPublish\ -Force"
echo "3c. Publish-Module -Path C:\TEMP\ISHRemote\ToPublish\ISHRemote.psd1 -Repository $psRepository -NuGetApiKey $nuGetApiKey -Force"
echo "3d. Find-Module -Name ISHRemote -Repository $psRepository -AllowPrerelease"