Skip to content

Pester-Tests

Pester-Tests #94

Workflow file for this run

name: Pester-Tests
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "PowerShell_Tests"
PowerShell_Tests:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
# If any job fails, all jobs that are in progress or queued will be cancelled
continue-on-error: false
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Print path
run: echo "The workflow path is $env:GITHUB_WORKSPACE"
shell: pwsh
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.x'
- name: Install dependencies
run: dotnet restore
- name: Build project
run: dotnet build --configuration Release --no-restore
- name: Publish project
run: dotnet publish
- name: Run Pester
shell: pwsh
run: |
Set-PSRepository psgallery -InstallationPolicy trusted
Install-Module -Name Pester -Confirm:$false -Force
Install-Module -Name PSScriptAnalyzer -Force
Import-Module -Name ([IO.Path]::Combine("$env:GITHUB_WORKSPACE", 'src', 'bin', 'Debug', 'net6.0', 'publish', 'jwtPS.dll')) -Force
Invoke-Pester -Path "Tests"
# Runs the PSScriptAnalyzer
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path . -Recurse -OutVariable issues
$err = $issues.Where( { $_.Severity -eq 'Error' })
if ($err) {
Write-Error -Message "The script analysis found at least one error." -ErrorAction Stop
}
else {
$issues | Export-Clixml -Path ScriptAnalysis.xml
}
# Uploading the XML report created by the PSScriptAnalyzer
- name: Upload Report
uses: actions/upload-artifact@v2
with:
name: Script Analysis
path: ${{ github.workspace }}/.github/workflows/
retention-days: 10