Skip to content

Pester-Tests

Pester-Tests #105

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:
permissions:
contents: read
# 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:
permissions:
contents: read
security-events: write
actions: read
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: Test project
run: dotnet test
- 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 ${{ github.workspace }}/.github/workflows/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/ScriptAnalysis.xml
# retention-days: 10
- name: Run PSScriptAnalyzer
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f
with:
# Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options.
# The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules.
path: .\
recurse: true
# Include your own basic security rules. Removing this option will run all the rules
includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"'
output: results.sarif
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif