Unify asynchronous PowerShell cmdlet lifecycle #607
Workflow file for this run
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
| name: Test PowerShell | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths-ignore: | |
| - '*.md' | |
| - 'Docs/**' | |
| - 'Examples/**' | |
| - '.gitignore' | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| DOTNET_VERSION: '8.x' | |
| BUILD_CONFIGURATION: 'Debug' | |
| jobs: | |
| refresh-psd1: | |
| name: 'Refresh PSD1' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Setup PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Install-Module Pester -Force -Scope CurrentUser -AllowClobber | |
| Install-Module PSPublishModule -Force -Scope CurrentUser -AllowClobber | |
| - name: Refresh module manifest | |
| run: .\Build\Build-Module.ps1 -RunMode Manifest | |
| shell: pwsh | |
| - name: Commit refreshed PSD1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HEAD_BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add ImagePlayground.psd1 | |
| git commit -m "chore: regenerate psd1" || echo "No changes to commit" | |
| git push origin HEAD:$Env:HEAD_BRANCH | |
| - name: Upload refreshed manifest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: psd1 | |
| path: ImagePlayground.psd1 | |
| build-packaged-module: | |
| needs: refresh-psd1 | |
| name: 'Build packaged module' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download manifest | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: psd1 | |
| path: . | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Install PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| Install-Module -Name PSPublishModule -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| - name: Build module layout | |
| shell: pwsh | |
| run: .\Build\Build-Module.ps1 -RunMode Build | |
| - name: Upload packaged module | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: packaged-module | |
| path: Artefacts/Unpacked/Modules/ImagePlayground | |
| if-no-files-found: error | |
| test-windows-ps5: | |
| #if: false # Temporarily disabled | |
| needs: build-packaged-module | |
| name: 'Windows PowerShell 5.1' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download packaged module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packaged-module | |
| path: .packaged-module | |
| - name: Install PowerShell modules | |
| shell: powershell | |
| run: | | |
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" | |
| Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| Install-Module -Name PSWriteColor -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| - name: Overlay packaged module | |
| shell: powershell | |
| run: | | |
| Copy-Item -Path .\.packaged-module\* -Destination . -Recurse -Force | |
| Remove-Item -LiteralPath .\.packaged-module -Recurse -Force | |
| - name: Run PowerShell tests | |
| shell: powershell | |
| run: ./ImagePlayground.Tests.ps1 | |
| test-windows-ps7: | |
| needs: build-packaged-module | |
| name: 'Windows PowerShell 7' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download packaged module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packaged-module | |
| path: .packaged-module | |
| - name: Install PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" | |
| Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| Install-Module -Name PSWriteColor -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| - name: Overlay packaged module | |
| shell: pwsh | |
| run: | | |
| Copy-Item -Path .\.packaged-module\* -Destination . -Recurse -Force | |
| Remove-Item -LiteralPath .\.packaged-module -Recurse -Force | |
| - name: Run PowerShell tests | |
| shell: pwsh | |
| run: ./ImagePlayground.Tests.ps1 | |
| test-ubuntu: | |
| needs: build-packaged-module | |
| name: 'Ubuntu PowerShell 7' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download packaged module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packaged-module | |
| path: .packaged-module | |
| - name: Install PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" | |
| Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| Install-Module -Name PSWriteColor -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| - name: Overlay packaged module | |
| shell: pwsh | |
| run: | | |
| Copy-Item -Path ./.packaged-module/* -Destination . -Recurse -Force | |
| Remove-Item -LiteralPath ./.packaged-module -Recurse -Force | |
| - name: Run PowerShell tests | |
| shell: pwsh | |
| run: ./ImagePlayground.Tests.ps1 | |
| test-macos: | |
| needs: build-packaged-module | |
| name: 'macOS PowerShell 7' | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download packaged module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packaged-module | |
| path: .packaged-module | |
| - name: Install PowerShell modules | |
| shell: pwsh | |
| run: | | |
| Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)" | |
| Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| Install-Module -Name PSWriteColor -Repository PSGallery -Force -SkipPublisherCheck -AllowClobber | |
| - name: Overlay packaged module | |
| shell: pwsh | |
| run: | | |
| Copy-Item -Path ./.packaged-module/* -Destination . -Recurse -Force | |
| Remove-Item -LiteralPath ./.packaged-module -Recurse -Force | |
| - name: Run PowerShell tests | |
| shell: pwsh | |
| run: ./ImagePlayground.Tests.ps1 |