|
| 1 | +# Reusable workflow for running specialized test suites (quarantined and outerloop tests) |
| 2 | +name: Specialized Test Runner |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + testRunnerName: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + description: 'Arcade test runner name' |
| 11 | + extraRunSheetBuilderArgs: |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + extraTestArgs: |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + # Controls whether to install Playwright browsers during project build |
| 18 | + enablePlaywrightInstall: |
| 19 | + required: true |
| 20 | + type: boolean |
| 21 | + default: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + |
| 25 | + generate_tests_matrix: |
| 26 | + name: Generate test runsheet |
| 27 | + runs-on: ubuntu-latest |
| 28 | + if: ${{ github.repository_owner == 'dotnet' }} |
| 29 | + outputs: |
| 30 | + runsheet: ${{ steps.generate_tests_matrix.outputs.runsheet }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 33 | + |
| 34 | + # We need to build the whole solution, so that we can interrogate each test project |
| 35 | + # and find out whether it contains any tests of the specified type. |
| 36 | + - name: Build the solution |
| 37 | + run: > |
| 38 | + ./build.sh |
| 39 | + --restore |
| 40 | + --build |
| 41 | + -c Release |
| 42 | + --ci |
| 43 | + /p:CI=false |
| 44 | + /p:GeneratePackageOnBuild=false |
| 45 | + /p:InstallBrowsersForPlaywright=false |
| 46 | +
|
| 47 | + - name: Generate test runsheet |
| 48 | + id: generate_tests_matrix |
| 49 | + run: | |
| 50 | + ./build.sh |
| 51 | + --test |
| 52 | + /p:TestRunnerName=${{ inputs.testRunnerName }} |
| 53 | + ${{ inputs.extraRunSheetBuilderArgs }} |
| 54 | + -c Release |
| 55 | + --ci |
| 56 | + /p:CI=false |
| 57 | + /p:Restore=false |
| 58 | + /p:Build=false |
| 59 | + /bl:${{ github.workspace }}/artifacts/log/Release/runsheet.binlog |
| 60 | +
|
| 61 | + - name: Upload logs, and test results |
| 62 | + if: ${{ always() }} |
| 63 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 64 | + with: |
| 65 | + name: logs-runsheet |
| 66 | + path: | |
| 67 | + ${{ github.workspace }}/artifacts/log/*/runsheet.binlog |
| 68 | + ${{ github.workspace }}/artifacts/log/*/TestLogs/** |
| 69 | + ${{ github.workspace }}/artifacts/tmp/*/combined_runsheet.json |
| 70 | + retention-days: 5 |
| 71 | + |
| 72 | + build_packages: |
| 73 | + name: Build packages |
| 74 | + if: ${{ github.repository_owner == 'dotnet' }} |
| 75 | + uses: ./.github/workflows/build-packages.yml |
| 76 | + |
| 77 | + run_tests: |
| 78 | + name: Test |
| 79 | + needs: [generate_tests_matrix, build_packages] |
| 80 | + strategy: |
| 81 | + fail-fast: false |
| 82 | + matrix: |
| 83 | + tests: ${{ fromJson(needs.generate_tests_matrix.outputs.runsheet) }} |
| 84 | + if: ${{ always() && !cancelled() && github.repository_owner == 'dotnet' && needs.generate_tests_matrix.outputs.runsheet != '[]' }} |
| 85 | + uses: ./.github/workflows/run-tests.yml |
| 86 | + with: |
| 87 | + testShortName: ${{ matrix.tests.project }} |
| 88 | + requiresNugets: ${{ matrix.tests.requiresNugets == true }} |
| 89 | + requiresTestSdk: ${{ matrix.tests.requiresTestSdk == true }} |
| 90 | + os: ${{ matrix.tests.os }} |
| 91 | + enablePlaywrightInstall: ${{ inputs.enablePlaywrightInstall }} |
| 92 | + extraTestArgs: ${{ inputs.extraTestArgs }} |
| 93 | + |
| 94 | + results: |
| 95 | + if: ${{ always() && github.repository_owner == 'dotnet' }} |
| 96 | + runs-on: ubuntu-latest |
| 97 | + name: Final Results |
| 98 | + needs: [generate_tests_matrix, build_packages, run_tests] |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 101 | + |
| 102 | + # Check if there were no tests to run |
| 103 | + - name: Check if tests were run |
| 104 | + id: check_tests |
| 105 | + run: | |
| 106 | + if [ "${{ needs.generate_tests_matrix.outputs.runsheet }}" = "[]" ]; then |
| 107 | + echo "No tests found for this test type" |
| 108 | + echo "tests_run=false" >> $GITHUB_OUTPUT |
| 109 | + else |
| 110 | + echo "tests_run=true" >> $GITHUB_OUTPUT |
| 111 | + fi |
| 112 | +
|
| 113 | + # get all the test logs artifacts into a single directory |
| 114 | + - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 |
| 115 | + if: steps.check_tests.outputs.tests_run == 'true' |
| 116 | + with: |
| 117 | + pattern: 'logs-*' |
| 118 | + path: ${{ github.workspace }}/artifacts/all-logs |
| 119 | + |
| 120 | + # Organize the .trx files by OS |
| 121 | + - name: Organize test results by OS |
| 122 | + if: steps.check_tests.outputs.tests_run == 'true' |
| 123 | + shell: pwsh |
| 124 | + run: | |
| 125 | + $logDirectory = "${{ github.workspace }}/artifacts/all-logs" |
| 126 | +
|
| 127 | + # Create OS-specific directories |
| 128 | + New-Item -ItemType Directory -Path "${{ github.workspace }}/testresults/ubuntu-latest" -Force |
| 129 | + New-Item -ItemType Directory -Path "${{ github.workspace }}/testresults/windows-latest" -Force |
| 130 | + New-Item -ItemType Directory -Path "${{ github.workspace }}/testresults/macos-latest" -Force |
| 131 | +
|
| 132 | + # Find all .trx files |
| 133 | + $trxFiles = Get-ChildItem -Path $logDirectory -Filter *.trx -Recurse |
| 134 | +
|
| 135 | + # Copy each .trx file to the appropriate OS folder |
| 136 | + foreach ($trxFile in $trxFiles) { |
| 137 | + if ($trxFile.FullName -match "ubuntu") { |
| 138 | + Copy-Item -Path $trxFile.FullName -Destination "${{ github.workspace }}/testresults/ubuntu-latest/" -Force |
| 139 | + } elseif ($trxFile.FullName -match "windows") { |
| 140 | + Copy-Item -Path $trxFile.FullName -Destination "${{ github.workspace }}/testresults/windows-latest/" -Force |
| 141 | + } elseif ($trxFile.FullName -match "macos") { |
| 142 | + Copy-Item -Path $trxFile.FullName -Destination "${{ github.workspace }}/testresults/macos-latest/" -Force |
| 143 | + } |
| 144 | + } |
| 145 | +
|
| 146 | + - name: Generate test results summary |
| 147 | + if: steps.check_tests.outputs.tests_run == 'true' |
| 148 | + env: |
| 149 | + CI: false |
| 150 | + run: > |
| 151 | + ${{ github.workspace }}/dotnet.sh |
| 152 | + run |
| 153 | + --project ${{ github.workspace }}/tools/GenerateTestSummary/GenerateTestSummary.csproj |
| 154 | + -- |
| 155 | + ${{ github.workspace }}/testresults |
| 156 | + --combined |
0 commit comments