Copilot instructions
.github/instructions/publishing-pester-result.instructions.mdCopilot instructions
Quality
69/100
Scores the file, not the repository.Length
1,100 words
27 headings · 4 code blocksRepository
55k
— · pushed 2 days agoLast changed
3 days ago
First indexed 3 days ago.12345# Publishing Pester Test Results Instructions67This document describes how the PowerShell repository uses GitHub Actions to publish Pester test results.89## Overview1011The PowerShell repository uses a custom composite GitHub Action located at `.github/actions/test/process-pester-results` to process and publish Pester test results in CI/CD workflows.12This action aggregates test results from NUnitXml formatted files, creates a summary in the GitHub Actions job summary, and uploads the results as artifacts.1314## How It Works1516### Action Location and Structure1718**Path**: `.github/actions/test/process-pester-results/`1920The action consists of two main files:21221. **action.yml** - The composite action definition231. **process-pester-results.ps1** - PowerShell script that processes test results2425### Action Inputs2627The action accepts the following inputs:2829- **name** (required): A descriptive name for the test run (e.g., "UnelevatedPesterTests-CI")30 - Used for naming the uploaded artifact and in the summary31 - Format: `junit-pester-{name}`3233- **testResultsFolder** (optional): Path to the folder containing test result XML files34 - Default: `${{ runner.workspace }}/testResults`35 - The script searches for all `*.xml` files in this folder recursively3637### Action Workflow3839The action performs the following steps:40411. **Process Test Results**42 - Runs `process-pester-results.ps1` with the provided name and test results folder43 - Parses all NUnitXml formatted test result files (`*.xml`)44 - Aggregates test statistics across all files:45 - Total test cases46 - Errors47 - Failures48 - Not run tests49 - Inconclusive tests50 - Ignored tests51 - Skipped tests52 - Invalid tests53541. **Generate Summary**55 - Creates a markdown summary using the `$GITHUB_STEP_SUMMARY` environment variable56 - Uses `Write-Log` and `Write-LogGroupStart`/`Write-LogGroupEnd` functions from `build.psm1`57 - Outputs a formatted summary with all test statistics58 - Example format:5960```markdown61 # Summary of {Name}6263 - Total Tests: X64 - Total Errors: X65 - Total Failures: X66 - Total Not Run: X67 - Total Inconclusive: X68 - Total Ignored: X69 - Total Skipped: X70 - Total Invalid: X71```72731. **Upload Artifacts**74 - Uses `actions/upload-artifact@v4` to upload test results75 - Artifact name: `junit-pester-{name}`76 - Always runs (even if previous steps fail) via `if: always()`77 - Uploads the entire test results folder78791. **Exit Status**80 - Fails the job (exit 1) if:81 - Any test errors occurred (`$testErrorCount -gt 0`)82 - Any test failures occurred (`$testFailureCount -gt 0`)83 - No test cases were run (`$testCaseCount -eq 0`)8485## Usage in Test Actions8687The `process-pester-results` action is called by two platform-specific composite test actions:8889### Linux/macOS Tests: `.github/actions/test/nix`9091Used in:9293- `.github/workflows/linux-ci.yml`94- `.github/workflows/macos-ci.yml`9596Example usage (lines 99-104 in `nix/action.yml`):9798```yaml99- name: Convert, Publish, and Upload Pester Test Results100 uses: "./.github/actions/test/process-pester-results"101 with:102 name: "${{ inputs.purpose }}-${{ inputs.tagSet }}"103 testResultsFolder: "${{ runner.workspace }}/testResults"104```105106### Windows Tests: `.github/actions/test/windows`107108Used in:109110- `.github/workflows/windows-ci.yml`111112Example usage (line 78-83 in `windows/action.yml`):113114```yaml115- name: Convert, Publish, and Upload Pester Test Results116 uses: "./.github/actions/test/process-pester-results"117 with:118 name: "${{ inputs.purpose }}-${{ inputs.tagSet }}"119 testResultsFolder: ${{ runner.workspace }}\testResults120```121122## Workflow Integration123124The process-pester-results action is integrated into the CI workflows through a multi-level hierarchy:125126### Level 1: Main CI Workflows127128- `linux-ci.yml`129- `macos-ci.yml`130- `windows-ci.yml`131132### Level 2: Test Jobs133134Each workflow contains multiple test jobs with different purposes and tag sets:135136- `UnelevatedPesterTests` with tagSet `CI`137- `ElevatedPesterTests` with tagSet `CI`138- `UnelevatedPesterTests` with tagSet `Others`139- `ElevatedPesterTests` with tagSet `Others`140141### Level 3: Platform Test Actions142143Test jobs use platform-specific actions:144145- `nix` for Linux and macOS146- `windows` for Windows147148### Level 4: Process Results Action149150Platform actions call `process-pester-results` to publish results151152## Test Execution Flow1531541. **Build Phase**: Source code is built (e.g., in `ci_build` job)1551. **Test Preparation**:156 - Build artifacts are downloaded157 - PowerShell is bootstrapped158 - Test binaries are extracted1591. **Test Execution**:160 - `Invoke-CITest` is called with:161 - `-Purpose`: Test purpose (e.g., "UnelevatedPesterTests")162 - `-TagSet`: Test category (e.g., "CI", "Others")163 - `-OutputFormat NUnitXml`: Results format164 - Results are written to `${{ runner.workspace }}/testResults`1651. **Results Processing**:166 - `process-pester-results` action runs167 - Results are aggregated and summarized168 - Artifacts are uploaded169 - Job fails if any tests failed or errored170171## Key Dependencies172173### PowerShell Modules174175- **build.psm1**: Provides utility functions176 - `Write-Log`: Logging function with GitHub Actions support177 - `Write-LogGroupStart`: Creates collapsible log groups178 - `Write-LogGroupEnd`: Closes collapsible log groups179180### GitHub Actions Features181182- **GITHUB_STEP_SUMMARY**: Environment variable for job summary183- **actions/upload-artifact@v4**: For uploading test results184- **Composite Actions**: For reusable workflow steps185186### Test Result Format187188- **NUnitXml**: XML format for test results189- Expected XML structure with `test-results` root element containing:190 - `total`: Total number of tests191 - `errors`: Number of errors192 - `failures`: Number of failures193 - `not-run`: Number of tests not run194 - `inconclusive`: Number of inconclusive tests195 - `ignored`: Number of ignored tests196 - `skipped`: Number of skipped tests197 - `invalid`: Number of invalid tests198199## Best Practices2002011. **Naming Convention**: Use descriptive names that include both purpose and tagSet:202 - Format: `{purpose}-{tagSet}`203 - Example: `UnelevatedPesterTests-CI`2042051. **Test Results Location**:206 - Default location: `${{ runner.workspace }}/testResults`207 - Use platform-appropriate path separators (Windows: `\`, Unix: `/`)2082091. **Always Upload**: The artifact upload step uses `if: always()` to ensure results are uploaded even when tests fail2102111. **Error Handling**: The action will fail the job if:212 - Tests have errors or failures (intentional fail-fast behavior)213 - No tests were executed (potential configuration issue)214 - `GITHUB_STEP_SUMMARY` is not set (environment issue)215216## Customizing for Your Repository217218To use this pattern in another repository:2192201. **Copy the Action Files**:221 - Copy `.github/actions/test/process-pester-results/` directory222 - Ensure the PowerShell script has proper permissions2232241. **Adjust Dependencies**:225 - Modify or remove the `Import-Module "$PSScriptRoot/../../../../build.psm1"` line226 - Implement equivalent `Write-Log` and `Write-LogGroup*` functions if needed2272281. **Customize Summary Format**:229 - Modify the here-string in `process-pester-results.ps1` to change summary format230 - Add additional metrics or formatting as needed2312321. **Call from Your Workflows**:233234```yaml235 - name: Process Test Results236 uses: "./.github/actions/test/process-pester-results"237 with:238 name: "my-test-run"239 testResultsFolder: "path/to/results"240```241242## Related Documentation243244- [GitHub Actions: Creating composite actions](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action)245- [GitHub Actions: Job summaries](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)246- [GitHub Actions: Uploading artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts)247- [Pester: PowerShell testing framework](https://pester.dev/)248- [NUnit XML Format](https://docs.nunit.org/articles/nunit/technical-notes/usage/Test-Result-XML-Format.html)249250## Troubleshooting251252### No Test Results Found253254- Verify `testResultsFolder` path is correct255- Ensure tests are generating NUnitXml formatted output256- Check that `*.xml` files exist in the specified folder257258### Action Fails with "GITHUB_STEP_SUMMARY is not set"259260- Ensure the action runs within a GitHub Actions environment261- Cannot be run locally without mocking this environment variable262263### All Tests Pass but Job Fails264265- Check if any tests are marked as errors (different from failures)266- Verify that at least some tests executed (`$testCaseCount -eq 0`)267268### Artifact Upload Fails269270- Check artifact name for invalid characters271- Ensure the test results folder exists272- Verify actions/upload-artifact version compatibility273
Also in PowerShell/PowerShell
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| PowerShell/PowerShell.github/instructions/build-and-packaging-steps.instructions.md · 55k | Copilot instructions | buildagent-behaviour | 58/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/build-checkout-prerequisites.instructions.md · 55k | Copilot instructions | setupbuildstylearch+1 | 81/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/build-configuration-guide.instructions.md · 55k | Copilot instructions | buildteststyletesting-strategy+2 | 74/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/code-review-branch-strategy.instructions.md · 55k | Copilot instructions | lint-formatstyletypesgit+1 | 62/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/instruction-file-format.instructions.md · 55k | Copilot instructions | buildlint-formatstylearch+3 | 76/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/log-grouping-guidelines.instructions.md · 55k | Copilot instructions | buildtestdo-not | 77/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-condition-syntax.instructions.md · 55k | Copilot instructions | buildstylearchdeployment+1 | 73/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-restore-phase-pattern.instructions.md · 55k | Copilot instructions | arch | 54/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/onebranch-signing-configuration.instructions.md · 55k | Copilot instructions | buildstyledeployment | 62/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/pester-set-itresult-pattern.instructions.md · 55k | Copilot instructions | setupstylearch | 62/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/pester-test-status-and-working-meaning.instructions.md · 55k | Copilot instructions | teststyle | 54/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-automatic-variables.instructions.md · 55k | Copilot instructions | stylearchgitdeployment+1 | 69/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-module-organization.instructions.md · 55k | Copilot instructions | buildteststylearch+2 | 69/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/powershell-parameter-naming.instructions.md · 55k | Copilot instructions | styledo-not | 65/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/script-module-file-format.instructions.md · 55k | Copilot instructions | lint-format | 54/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/start-native-execution.instructions.md · 55k | Copilot instructions | buildstylearchgit+1 | 86/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/start-psbuild-basics.instructions.md · 55k | Copilot instructions | buildtesting-strategydeploymentagent-behaviour | 54/100 | 3 days ago | |
| PowerShell/PowerShell.github/instructions/troubleshooting-builds.instructions.md · 55k | Copilot instructions | buildgitdeployment | 54/100 | 3 days ago |
Diff against .github/instructions/build-and-packaging-steps.instructions.md Diff against .github/instructions/build-checkout-prerequisites.instructions.md Diff against .github/instructions/build-configuration-guide.instructions.md Diff against .github/instructions/code-review-branch-strategy.instructions.md Diff against .github/instructions/instruction-file-format.instructions.md Diff against .github/instructions/log-grouping-guidelines.instructions.md Diff against .github/instructions/onebranch-condition-syntax.instructions.md Diff against .github/instructions/onebranch-restore-phase-pattern.instructions.md Diff against .github/instructions/onebranch-signing-configuration.instructions.md Diff against .github/instructions/pester-set-itresult-pattern.instructions.md Diff against .github/instructions/pester-test-status-and-working-meaning.instructions.md Diff against .github/instructions/powershell-automatic-variables.instructions.md Diff against .github/instructions/powershell-module-organization.instructions.md Diff against .github/instructions/powershell-parameter-naming.instructions.md Diff against .github/instructions/script-module-file-format.instructions.md Diff against .github/instructions/start-native-execution.instructions.md Diff against .github/instructions/start-psbuild-basics.instructions.md Diff against .github/instructions/troubleshooting-builds.instructions.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | 3 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 2 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| rtk-ai/rtk.github/copilot-instructions.md · 74k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 3 days ago | |
| dotnet/roslyn.github/copilot-instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 97/100 | 3 days ago |
