Skip to content

New release pipeline #756

New release pipeline

New release pipeline #756

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '**.md'
- '.azuredevops/**'
- '.github/**'
- '!.github/workflows/CI.yaml'
branches: [ main ]
permissions:
contents: read
actions: read
pull-requests: write
checks: write
id-token: write
concurrency:
group: 'runTests-${{ github.ref }}'
cancel-in-progress: true
defaults:
run:
shell: powershell
jobs:
AnalyzeTests:
if: github.repository == 'Microsoft/NavContainerHelper'
runs-on: [ windows-latest ]
outputs:
tests: ${{ steps.Analyze.outputs.tests }}
linuxtests: ${{ steps.Analyze.outputs.linuxtests }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Analyze
id: Analyze
run: |
$errorActionPreference = "stop"
$tests = @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\*.Tests.ps1') | ForEach-Object { $_.BaseName }) | ConvertTo-Json -compress
Add-Content -Path $env:GITHUB_OUTPUT -Value "tests=$tests"
Write-Host "tests=$tests"
$linuxtests = @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\*.Tests.ps1') | ForEach-Object { $_.BaseName }) | ConvertTo-Json -compress
Add-Content -Path $env:GITHUB_OUTPUT -Value "linuxtests=$linuxtests"
Write-Host "linuxtests=$linuxtests"
PS5:
runs-on: [ windows-latest ]
needs: [ AnalyzeTests ]
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$licenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($licenseFile, ([Convert]::FromBase64String('${{ secrets.licensefile }}')))
$buildLicenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($buildLicenseFile, ([Convert]::FromBase64String('${{ secrets.buildLicensefile }}')))
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = $licenseFile; "buildLicenseFile" = $buildLicenseFile }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}
PS7:
runs-on: [ windows-latest ]
defaults:
run:
shell: pwsh
needs: [ AnalyzeTests ]
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$licenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($licenseFile, ([Convert]::FromBase64String('${{ secrets.licensefile }}')))
$buildLicenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($buildLicenseFile, ([Convert]::FromBase64String('${{ secrets.buildLicensefile }}')))
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = $licenseFile; "buildLicenseFile" = $buildLicenseFile }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}
Linux:
runs-on: [ ubuntu-24.04 ]
defaults:
run:
shell: pwsh
needs: [ AnalyzeTests ]
strategy:
matrix:
test: ${{fromJson(needs.AnalyzeTests.outputs.linuxtests)}}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Run Tests
run: |
try {
$errorActionPreference = "stop"
Set-StrictMode -version 2.0
$licenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($licenseFile, ([Convert]::FromBase64String('${{ secrets.licensefile }}')))
$buildLicenseFile = "$([System.IO.Path]::GetTempFileName()).flf"
[System.IO.File]::WriteAllBytes($buildLicenseFile, ([Convert]::FromBase64String('${{ secrets.buildLicensefile }}')))
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = $licenseFile; "buildLicenseFile" = $buildLicenseFile }
$result = Invoke-Pester -Container $pesterContainer -passthru
if ($result.FailedCount -gt 0) {
Write-Host "::Error::$($result.FailedCount) tests are failing"
$host.SetShouldExit(1)
}
}
catch {
Write-Host "::Error::Exception when running tests. The Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}