-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Convert powershell/PowerShell-CI-linux to GitHub Actions #24913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TravisEz13
merged 28 commits into
master
from
convert-powershell-powershell-ci-linux-to-actions-20250131-203900
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
82402d9
Add workflow powershell/PowerShell-CI-linux
TravisEz13 f4019c6
Add composite action tools_releaseBuild_azureDevOps_templates_insert_…
TravisEz13 7cee8e2
Add composite action pipelines_templates_insert_nuget_config_azfeed
TravisEz13 b4d985f
Add composite action vsts_ci_templates_test_nix_test_steps
TravisEz13 86ba3fc
Add reusable workflow vsts_ci_templates_ci_build
TravisEz13 046dc8d
Add reusable workflow vsts_ci_templates_nix_test
TravisEz13 348de0b
Add reusable workflow vsts_ci_templates_verify_xunit
TravisEz13 ff6cdb4
Add reusable workflow vsts_ci_templates_test_nix_container_test
TravisEz13 c2384da
Add reusable workflow vsts_ci_linux_templates_packaging
TravisEz13 ccdc1bd
convert to use composite actions
TravisEz13 fc30f67
fix trigger filters
TravisEz13 d44735b
add run-name
TravisEz13 be31bb2
disable linux packaging tests
TravisEz13 abf9318
delete unused actions
TravisEz13 05efb97
use pwsh as a shell where powershell 5.1 is not needed
TravisEz13 19d492b
switch pester to JUnit
TravisEz13 045495b
Update linux ci.psm1 to take pester output format
TravisEz13 ea09cc3
delete unused workflow
TravisEz13 ca74356
move common reporting code to a composite action
TravisEz13 3ab5ed8
skip test tool build on additional test runs on same agent
TravisEz13 a64182a
fix action path
TravisEz13 0269411
fix filters to recurse
TravisEz13 5b8a8c6
fix path creation
TravisEz13 b439c6c
Add comments about gem installation issue
TravisEz13 ed85b9c
Remove extra newlines in action.yml
TravisEz13 01ae09e
address PR comments
TravisEz13 f30f1a2
fix step name
TravisEz13 eba407c
fix triggers
TravisEz13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,95 @@ | ||
name: linux_packaging | ||
description: 'Test very basic Linux packaging' | ||
|
||
# This isn't working yet | ||
# It fails with | ||
|
||
# ERROR: While executing gem ... (Gem::FilePermissionError) | ||
# You don't have write permissions for the /var/lib/gems/2.7.0 directory. | ||
# WARNING: Installation of gem dotenv 2.8.1 failed! Must resolve manually. | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Capture Environment | ||
if: success() || failure() | ||
run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose' | ||
shell: pwsh | ||
- name: Download Build Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: "${{ github.workspace }}" | ||
- name: Capture Artifacts Directory | ||
continue-on-error: true | ||
run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse | ||
shell: pwsh | ||
|
||
- name: Bootstrap | ||
run: |- | ||
Import-Module ./build.psm1 | ||
Start-PSBootstrap -Package | ||
shell: pwsh | ||
- name: Capture Artifacts Directory | ||
continue-on-error: true | ||
run: Import-Module ./build.psm1 | ||
shell: pwsh | ||
- name: Extract Files | ||
uses: actions/[email protected] | ||
env: | ||
DESTINATION_FOLDER: "${{ github.workspace }}/bins" | ||
ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip" | ||
with: | ||
script: |- | ||
const fs = require('fs').promises | ||
const path = require('path') | ||
const target = path.resolve(process.env.DESTINATION_FOLDER) | ||
const patterns = process.env.ARCHIVE_FILE_PATTERNS | ||
const globber = await glob.create(patterns) | ||
await io.mkdirP(path.dirname(target)) | ||
for await (const file of globber.globGenerator()) { | ||
if ((await fs.lstat(file)).isDirectory()) continue | ||
await exec.exec(`7z x ${file} -o${target} -aoa`) | ||
} | ||
- name: Fix permissions | ||
continue-on-error: true | ||
run: |- | ||
find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \; | ||
find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \; | ||
shell: bash | ||
- name: Capture Extracted Build ZIP | ||
continue-on-error: true | ||
run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue | ||
shell: pwsh | ||
- name: Packaging Tests | ||
if: success() | ||
run: |- | ||
Import-Module ./tools/ci.psm1 | ||
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json' | ||
$options = (Get-PSOptions) | ||
$rootPath = '${{ github.workspace }}/bins' | ||
$originalRootPath = Split-Path -path $options.Output | ||
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath) | ||
$pwshPath = Join-Path -path $path -ChildPath 'pwsh' | ||
chmod a+x $pwshPath | ||
$options.Output = $pwshPath | ||
Set-PSOptions $options | ||
Invoke-CIFinish | ||
shell: pwsh | ||
- name: Upload packages | ||
run: |- | ||
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.deb" -Recurse | ForEach-Object { | ||
$packagePath = $_.FullName | ||
Write-Host "Uploading $packagePath" | ||
Write-Host "##vso[artifact.upload containerfolder=deb;artifactname=deb]$packagePath" | ||
} | ||
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.rpm" -Recurse | ForEach-Object { | ||
$packagePath = $_.FullName | ||
Write-Host "Uploading $packagePath" | ||
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath" | ||
} | ||
Get-ChildItem "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}/*.tar.gz" -Recurse | ForEach-Object { | ||
$packagePath = $_.FullName | ||
Write-Host "Uploading $packagePath" | ||
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath" | ||
} | ||
shell: pwsh |
This file contains hidden or 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,91 @@ | ||
name: nix_test | ||
description: 'Test PowerShell on non-Windows platforms' | ||
|
||
inputs: | ||
purpose: | ||
required: false | ||
default: '' | ||
type: string | ||
tagSet: | ||
required: false | ||
default: CI | ||
type: string | ||
ctrfFolder: | ||
required: false | ||
default: ctrf | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Capture Environment | ||
if: success() || failure() | ||
run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose' | ||
shell: pwsh | ||
- name: Download Build Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: "${{ github.workspace }}" | ||
- name: Capture Artifacts Directory | ||
continue-on-error: true | ||
run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse | ||
shell: pwsh | ||
|
||
- name: Bootstrap | ||
shell: pwsh | ||
run: |- | ||
Import-Module ./tools/ci.psm1 | ||
Invoke-CIInstall -SkipUser | ||
|
||
- name: Extract Files | ||
uses: actions/[email protected] | ||
env: | ||
DESTINATION_FOLDER: "${{ github.workspace }}/bins" | ||
ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip" | ||
with: | ||
script: |- | ||
const fs = require('fs').promises | ||
const path = require('path') | ||
const target = path.resolve(process.env.DESTINATION_FOLDER) | ||
const patterns = process.env.ARCHIVE_FILE_PATTERNS | ||
const globber = await glob.create(patterns) | ||
await io.mkdirP(path.dirname(target)) | ||
for await (const file of globber.globGenerator()) { | ||
if ((await fs.lstat(file)).isDirectory()) continue | ||
await exec.exec(`7z x ${file} -o${target} -aoa`) | ||
} | ||
|
||
- name: Fix permissions | ||
continue-on-error: true | ||
run: |- | ||
find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \; | ||
find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \; | ||
shell: bash | ||
|
||
- name: Capture Extracted Build ZIP | ||
continue-on-error: true | ||
run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue | ||
shell: pwsh | ||
|
||
- name: Test | ||
if: success() | ||
run: |- | ||
Import-Module ./tools/ci.psm1 | ||
Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json' | ||
$options = (Get-PSOptions) | ||
$rootPath = '${{ github.workspace }}/bins' | ||
$originalRootPath = Split-Path -path $options.Output | ||
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath) | ||
$pwshPath = Join-Path -path $path -ChildPath 'pwsh' | ||
chmod a+x $pwshPath | ||
$options.Output = $pwshPath | ||
Set-PSOptions $options | ||
Invoke-CITest -Purpose '${{ inputs.purpose }}' -TagSet '${{ inputs.tagSet }}' -TitlePrefix '${{ inputs.buildName }}' -OutputFormat JUnitXml | ||
shell: pwsh | ||
|
||
- name: Convert, Publish, and Upload Pester Test Results | ||
uses: "./.github/actions/test/process-pester-results" | ||
with: | ||
name: "${{ inputs.purpose }}-${{ inputs.tagSet }}" | ||
testResultsFolder: "${{ runner.workspace }}/testResults" | ||
ctrfFolder: "${{ inputs.ctrfFolder }}" |
This file contains hidden or 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,64 @@ | ||
name: process-pester-test-results | ||
description: 'Process Pester test results' | ||
|
||
inputs: | ||
name: | ||
required: true | ||
default: '' | ||
type: string | ||
testResultsFolder: | ||
required: false | ||
default: "${{ runner.workspace }}/testResults" | ||
type: string | ||
ctrfFolder: | ||
required: false | ||
default: ctrf | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Convert JUnit to CTRF | ||
run: |- | ||
Get-ChildItem -Path "${{ inputs.testResultsFolder }}/*.xml" -Recurse | ForEach-Object { | ||
npx --yes junit-to-ctrf $_.FullName --output ./${{ inputs.ctrfFolder }}/$($_.BaseName).json --tool Pester | ||
} | ||
shell: pwsh | ||
|
||
# this task only takes / as directory separators | ||
- name: Publish Test Report | ||
uses: ctrf-io/github-test-reporter@v1 | ||
with: | ||
report-path: './${{ inputs.ctrfFolder }}/*.json' | ||
exit-on-fail: true | ||
summary-report: true | ||
test-report: false | ||
test-list-report: false | ||
failed-report: false | ||
fail-rate-report: false | ||
flaky-report: false | ||
flaky-rate-report: false | ||
failed-folded-report: true | ||
previous-results-report: false | ||
ai-report: true | ||
skipped-report: false | ||
suite-folded-report: false | ||
suite-list-report: false | ||
pull-request-report: false | ||
commit-report: false | ||
custom-report: false | ||
if: always() | ||
|
||
- name: Upload testResults artifact | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: junit-pester-${{ inputs.name }} | ||
path: ${{ runner.workspace }}/testResults | ||
|
||
- name: Upload ctrf artifact | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ctrf-pester-${{ inputs.name }} | ||
path: ${{ inputs.ctrfFolder }} |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.