Skip to content

fix(testmdepermissions): πŸ› Added fix for handling null roles and a t… #75

fix(testmdepermissions): πŸ› Added fix for handling null roles and a t…

fix(testmdepermissions): πŸ› Added fix for handling null roles and a t… #75

Workflow file for this run

name: ci
on:
push:
branches:
- main
paths:
- 'src/**'
- '!src/PSMDE.psd1'
- 'tests/**'
workflow_dispatch:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PSMDE_REPO }}
- name: Install PowerShell dependencies
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer, platyPS -force
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path .\ -Settings PSGallery -Recurse -ReportSummary -Severity Error
- name: Generate public help
shell: pwsh
run: |
Remove-Module PSMDE -Force -ErrorAction SilentlyContinue
Import-Module .\src\PSMDE.psd1
Update-MarkdownHelpModule -Path 'wiki' -RefreshModulePage -UpdateInputOutput -Force
(Get-Content .\wiki\PSMDE.md) -replace '(.md\))', ')' | Out-File .\wiki\PSMDE.md -Force -Encoding ascii
New-ExternalHelp -Path 'wiki' -OutputPath 'en-us' -Force
- name: Run Tests
shell: pwsh
run: |
Install-Module Az.Accounts, Az.Resources -Force
$config = New-PesterConfiguration -Hashtable @{ TestResult = @{ Enabled = $true }; Run = @{ Exit = $true }; CodeCoverage = @{ Enabled = $true; Path = @('src/public', 'src/private') } }
Invoke-Pester -Configuration $config
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test-and-Coverage
path: testResults.xml
- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
name: Test-and-Coverage
path: coverage.xml
- name: Update coverage in README
shell: pwsh
continue-on-error: true
run: |
[xml]$coverage = Get-Content .\coverage.xml
[int]$covered = $coverage.report.counter | Where-Object type -eq 'METHOD' | select -ExpandProperty 'covered'
[int]$missed = $coverage.report.counter | Where-Object type -eq 'METHOD' | select -ExpandProperty 'missed'
[int]$sum = $covered + $missed
$coveredPercent = [Math]::Floor(($covered * 100 / $sum) * 100) / 100
$readme = Get-Content ./README.md
$readme = $readme | foreach-object { $_ -replace "(?<prefix>^.+https:\/\/img\.shields\.io\/badge\/coverage-)(.+)(?<suffix>%25-yellow\))$", "`${prefix}$coveredPercent`${suffix}" }
$readme | Out-File ./README.md -Force -Encoding ascii
- name: Update public functions in README
shell: pwsh
continue-on-error: true
run: |
$functions = ''
(Import-PowerShellDataFile -Path ./src/PSMDE.psd1).FunctionsToExport | % { $functions += "- $($_)`n" }
$readme = Get-Content .\README.md -Raw
$readme -replace "(?s)(?<prefix><\/summary>)(.+)(?<suffix><\/details>)", "`${prefix}`n`n$functions`n`${suffix}" | Out-File ./README.md -Force -Encoding ascii
- name: Commit updated coverage and functions
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'docs(readme): :memo: Updated coverage and functions'
commit_user_email: [email protected]
push_options: '--force'
branch: main
- name: Upload public help
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.STORAGE_CONNECTION_STRING }}
container_name: help
source_folder: en-us
delete_if_exists: true
- name: Generate new tag version
uses: mathieudutour/[email protected]
id: tag_version
with:
github_token: ${{ secrets.PSMDE_REPO }}
release_branches: main
dry_run: true
- name: Update manifest and help version
if: ${{ steps.tag_version.outputs.new_tag }}
shell: pwsh
env:
TAG_NAME: ${{ steps.tag_version.outputs.new_tag }}
run: |
$release = $env:TAG_NAME.replace('v', '')
$help = Get-Content ./wiki/PSMDE.md
$help = $help | foreach-object { $_ -replace '(?<prefix>^.?Help Version: )(.+)(?<suffix>)$', "`${prefix}$release`${suffix}" }
$help | Out-File ./wiki/PSMDE.md -Force -Encoding ascii
$manifest = Get-Content ./src/PSMDE.psd1
$manifest = $manifest | foreach-object { $_ -replace "(?<prefix>^\s+ModuleVersion = ')(.+)(?<suffix>')$", "`${prefix}$release`${suffix}" }
$manifest | Out-File ./src/PSMDE.psd1 -Force -Encoding ascii
- name: Commit updated markdown help
shell: pwsh
run: |
$commitMessage = 'docs(help): :memo: Updated markdown help'
Set-Location 'wiki'
git config --global user.name 'Jan-Henrik Damaschke'
git config --global user.email '[email protected]'
git add -A
git commit -m $commitMessage
git pull --no-ff
git push origin HEAD:master
- name: Commit updated version files
uses: stefanzweifel/git-auto-commit-action@v4
id: commit_version
with:
commit_message: "chore(release): :bookmark: Bump version to ${{ steps.tag_version.outputs.new_tag }}"
commit_user_email: [email protected]
push_options: '--force'
branch: main
- name: Bump version and create tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.PSMDE_REPO }}
release_branches: main
commit_sha: ${{ steps.commit_version.outputs.commit_hash }}