|
| 1 | +name: Test |
| 2 | +description: Setup .NET, install PowerShell modules and run all tests. |
| 3 | + |
| 4 | +inputs: |
| 5 | + codecov_token: |
| 6 | + description: "Codecov token" |
| 7 | + required: false |
| 8 | + default: "" |
| 9 | + sarif_main_file: |
| 10 | + description: "SARIF file path for main project (empty = skip upload)" |
| 11 | + required: false |
| 12 | + default: "" |
| 13 | + sarif_test_file: |
| 14 | + description: "SARIF file path for test project (empty = skip upload)" |
| 15 | + required: false |
| 16 | + default: "" |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + - name: Setup .NET |
| 22 | + uses: actions/setup-dotnet@v5 |
| 23 | + with: |
| 24 | + global-json-file: ./global.json |
| 25 | + - name: Install modules from PSGallery |
| 26 | + shell: pwsh |
| 27 | + run: | |
| 28 | + Set-PSResourceRepository PSGallery -Trusted |
| 29 | + Install-PSResource InvokeBuild, Pester, PSScriptAnalyzer -Quiet -Reinstall -Scope CurrentUser |
| 30 | + Install-PSResource Microsoft.PowerShell.PlatyPS -Prerelease -Quiet -Reinstall -Scope CurrentUser |
| 31 | + - name: Test release build |
| 32 | + shell: pwsh |
| 33 | + run: | |
| 34 | + ./build.ps1 -Tasks Build -Configuration Release |
| 35 | + - name: Execute All Tests |
| 36 | + shell: pwsh |
| 37 | + run: | |
| 38 | + ./build.ps1 -Tasks TestAll |
| 39 | + - name: Upload coverage reports to Codecov |
| 40 | + uses: codecov/codecov-action@v5 |
| 41 | + if: runner.os == 'Linux' && inputs.codecov_token != '' |
| 42 | + with: |
| 43 | + files: ./coverage.cobertura.xml |
| 44 | + env: |
| 45 | + CODECOV_TOKEN: ${{ inputs.codecov_token }} |
| 46 | + # separate multiple SARIF uploads to add categories. see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload/ |
| 47 | + - name: Upload SARIF file for main project |
| 48 | + uses: github/codeql-action/upload-sarif@v4 |
| 49 | + if: runner.os == 'Linux' && inputs.sarif_main_file != '' |
| 50 | + with: |
| 51 | + sarif_file: ${{ inputs.sarif_main_file }} |
| 52 | + category: Main |
| 53 | + - name: Upload SARIF file for test project |
| 54 | + uses: github/codeql-action/upload-sarif@v4 |
| 55 | + if: runner.os == 'Linux' && inputs.sarif_test_file != '' |
| 56 | + with: |
| 57 | + sarif_file: ${{ inputs.sarif_test_file }} |
| 58 | + category: Test |
0 commit comments