Merge pull request #170 from RWS/169-Align-the-pester-tests-according… #142
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 - 7.2.13/lts has issues, updating to latest stable (like 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]" | |
- uses: actions/checkout@v3 | |
- name: Setup .NET 6.0.x | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore project and dependencies | |
run: dotnet restore Source/ISHRemote/ISHRemote.sln | |
- name: Build Solution | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
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@v3 | |
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@v3 | |
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@v3 | |
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@v3 | |
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@v3 | |
with: | |
name: ISHRemote-MainCI-PesterOnWindowsPowerShell | |
path: Cmdlets.Pester.Tests.xml | |
if: ${{ always() }} | |
- 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" |