Feature/GitHub artifacts #64
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
| 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@v6 | |
| 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@v6 | |
| - 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 | |
| } |