Skip to content

Feature/GitHub artifacts #65

Feature/GitHub artifacts

Feature/GitHub artifacts #65

Workflow file for this run

on:
push:
branches:
- main
paths:
- '.github/workflows/test-action.yml'
- 'action.yml'
- 'script/**'
workflow_dispatch:
pull_request:
branches:
- main
paths:
- '.github/workflows/test-action.yml'
- 'action.yml'
- 'script/**'
permissions:
id-token: write
contents: read
checks: write
jobs:
test-matrix:
strategy:
matrix:
maester: ["latest", "preview"]
name: "Maester ๐Ÿ”ฅ ${{ matrix.maester }}"
runs-on: ubuntu-latest
steps:
- name: Check preconditions ๐Ÿ“ƒ
id: preconditions
shell: bash
run: |
if [ "${{ secrets.AZURE_CLIENT_ID }}" == "" ]; then
echo "::error title=Missing secret::AZURE_CLIENT_ID is not set."
echo "secret_missing=true" >> "$GITHUB_OUTPUT"
fi
if [ "${{ secrets.AZURE_TENANT_ID }}" == "" ]; then
echo "::error title=Missing secret::AZURE_TENANT_ID is not set."
echo "secret_missing=true" >> "$GITHUB_OUTPUT"
fi
# It seems you need to checkout the code before you can use an action from the same repo
- name: Load action โœ…
if: ${{ steps.preconditions.outputs.secret_missing != 'true' }}
uses: actions/checkout@v7
with:
ref: ${{ github.ref }}
- name: Run Maester ๐Ÿ”ฅ
id: maester
if: ${{ steps.preconditions.outputs.secret_missing != 'true' }}
uses: ./ # meaning run the action from current repo
with:
client_id: ${{ secrets.AZURE_CLIENT_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
include_public_tests: true
include_private_tests: false
include_exchange: false
include_teams: false
step_summary: ${{ matrix.maester == 'preview'}}
artifact_upload: true
maester_version: ${{ matrix.maester }}
disable_telemetry: true
- name: Output results ๐Ÿ“ƒ
if: ${{ steps.preconditions.outputs.secret_missing != 'true' }}
run: |
echo "The result of the test run is: ${{ steps.maester.outputs.result }}"
echo "Total tests: ${{ steps.maester.outputs.tests_total }}"
echo "Passed tests: ${{ steps.maester.outputs.tests_passed }}"
echo "Failed tests: ${{ steps.maester.outputs.tests_failed }}"
echo "Skipped tests: ${{ steps.maester.outputs.tests_skipped }}"
validate-scripts:
name: "Analyze scripts ๐Ÿ‘ฎ"
runs-on: ubuntu-latest
steps:
- name: โœ… Checkout action
uses: actions/checkout@v7
- name: ๐Ÿ“ƒ Run script analyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path .\script\ -ExcludeRule PSAvoidUsingWriteHost
if ($results.Count -eq 0) {
Write-Host "โœ… No issues found."
$summary = "## ScriptAnalyzer Results โœ…`n`nNo issues found."
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $summary
Write-Host "Summary written to GITHUB_STEP_SUMMARY."
exit 0
} else {
Write-Host "๐Ÿ’ฃ Issues found"
$summary = "## ScriptAnalyzer Results โš ๏ธ`n`nNumber of issues: $($results.Count)`n`n"
$summary += "| File | Rule | Message |`n"
$summary += "| ---- | ---- | ------- |`n"
foreach ($result in $results) {
$summary += "| ``script/$($result.ScriptName)`` L$($result.Line) | $($result.RuleName) | $($result.Message) |`n"
Write-Host "::warning file=script/$($result.ScriptName),line=$($result.Line),col=$($result.Column),title=$($result.RuleName)::$($result.Message)"
}
$summary += "`n"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $summary
Write-Host "Summary written to GITHUB_STEP_SUMMARY."
exit $results.Count
}