-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new workflow to be able to run selected tests on a given REF, like: ![image](https://github.com/microsoft/navcontainerhelper/assets/10775043/f89a0ff8-fd5d-40fd-b74f-0eedbcc3dc6c) --------- Co-authored-by: freddydk <[email protected]>
- Loading branch information
Showing
39 changed files
with
208 additions
and
83 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
name: Run Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: ref on which to run the end-2-end tests (default is head_sha on the current branch) | ||
required: false | ||
default: '' | ||
testPatterns: | ||
description: Commaseparated list of patterns to match against test names (default is * for all tests) | ||
required: false | ||
default: '' | ||
|
||
permissions: | ||
contents: read | ||
actions: read | ||
pull-requests: write | ||
checks: write | ||
|
||
concurrency: | ||
group: 'runTests-${{ github.ref }}' | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: powershell | ||
|
||
jobs: | ||
AnalyzeTests: | ||
runs-on: [ windows-latest ] | ||
outputs: | ||
tests: ${{ steps.Analyze.outputs.tests }} | ||
linuxtests: ${{ steps.Analyze.outputs.linuxtests }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
lfs: true | ||
|
||
- name: Analyze | ||
id: Analyze | ||
env: | ||
testPatterns: ${{ github.event.inputs.testPatterns }} | ||
run: | | ||
$errorActionPreference = "stop" | ||
$testPatterns = $ENV:TESTPATTERNS | ||
if (!$testPatterns) { $testPatterns = '*' } | ||
$testPatternArr = $testPatterns.Split(',') | ||
Write-Host "Running test matching patterns:" | ||
$testPatternArr | ForEach-Object { Write-Host "- $_" } | ||
$tests = ConvertTo-Json -compress -InputObject @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\*.Tests.ps1') | Where-Object { $name = $_.Basename; $testPatternArr | Where-Object { $name -like "$($_).Tests" } } | ForEach-Object { $_.BaseName }) | ||
Add-Content -Path $env:GITHUB_OUTPUT -Value "tests=$tests" | ||
Write-Host "tests=$tests" | ||
$linuxtests = ConvertTo-Json -compress -InputObject @(Get-ChildItem -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\*.Tests.ps1') | Where-Object { $name = $_.Basename; $testPatternArr | Where-Object { $name -like "$($_).Tests" } } | ForEach-Object { $_.BaseName }) | ||
Add-Content -Path $env:GITHUB_OUTPUT -Value "linuxtests=$linuxtests" | ||
Write-Host "linuxtests=$linuxtests" | ||
PS5: | ||
runs-on: [ windows-latest ] | ||
needs: [ AnalyzeTests ] | ||
if: needs.AnalyzeTests.outputs.tests != '[]' | ||
strategy: | ||
matrix: | ||
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}} | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
lfs: true | ||
|
||
- name: Run Tests | ||
run: | | ||
try { | ||
$errorActionPreference = "stop" | ||
Set-StrictMode -version 2.0 | ||
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.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 ] | ||
needs: [ AnalyzeTests ] | ||
if: needs.AnalyzeTests.outputs.tests != '[]' | ||
strategy: | ||
matrix: | ||
test: ${{fromJson(needs.AnalyzeTests.outputs.tests)}} | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: pwsh | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
lfs: true | ||
|
||
- name: Run Tests | ||
run: | | ||
try { | ||
$errorActionPreference = "stop" | ||
Set-StrictMode -version 2.0 | ||
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'Tests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.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-latest ] | ||
needs: [ AnalyzeTests ] | ||
if: needs.AnalyzeTests.outputs.linuxtests != '[]' | ||
strategy: | ||
matrix: | ||
test: ${{fromJson(needs.AnalyzeTests.outputs.linuxtests)}} | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: pwsh | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
lfs: true | ||
|
||
- name: Run Tests | ||
run: | | ||
try { | ||
$errorActionPreference = "stop" | ||
Set-StrictMode -version 2.0 | ||
$pesterContainer = New-PesterContainer -Path (Join-Path $ENV:GITHUB_WORKSPACE 'LinuxTests\${{ matrix.test }}.ps1') -Data @{ "licenseFile" = '${{ secrets.licensefile }}'; "buildLicenseFile" = '${{ secrets.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) | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.