Improved sample project #37
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
| name: Main | |
| on: | |
| workflow_call: | |
| outputs: | |
| badge-color: | |
| description: 'Color for the test results badge' | |
| value: ${{ jobs.publish-results.outputs.badge-color }} | |
| badge-message: | |
| description: 'Text for the test results badge' | |
| value: ${{ jobs.publish-results.outputs.badge-message }} | |
| pull_request: | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| build: | |
| name: 🛠️ Build ${{ (matrix.unit || matrix.e2e) && '& Test ' || '' }}(${{ matrix.rid }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| rid: managed | |
| e2e: true | |
| unit: true # only run unit tests once | |
| - os: ubuntu-24.04 | |
| rid: linux-x64 | |
| e2e: true | |
| - os: ubuntu-24.04-arm | |
| rid: linux-arm64 | |
| e2e: true | |
| - os: ubuntu-24.04 | |
| rid: linux-musl-x64 | |
| e2e: false # linux-musl-x64 runners are not available on GHA | |
| - os: ubuntu-24.04-arm | |
| rid: linux-musl-arm64 | |
| e2e: false # linux-musl-arm64 runners are not available on GHA | |
| - os: windows-latest | |
| rid: win-x64 | |
| e2e: false # playwright install takes forever on windows | |
| - os: windows-latest | |
| rid: win-x86 | |
| e2e: false # win-x86 runners are not available on GHA | |
| - os: windows-latest | |
| rid: win-arm64 | |
| e2e: false # win-arm64 runners are not available on GHA | |
| - os: macos-latest | |
| rid: osx-x64 | |
| e2e: false # osx-x64 runners are not available on GHA | |
| - os: macos-latest | |
| rid: osx-arm64 | |
| e2e: true | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/run-setup | |
| - name: Build | |
| uses: ./.github/actions/run-build | |
| with: | |
| rid: ${{ matrix.rid }} | |
| - name: Run Unit Tests | |
| if: ${{ matrix.unit }} | |
| uses: ./.github/actions/run-unit-tests | |
| with: | |
| working-directory: src | |
| test-target: TypeShim.slnx | |
| configuration: Release | |
| artifact-name: test-results-unit | |
| rid: managed | |
| - name: Run E2E Tests | |
| if: ${{ !cancelled() && matrix.e2e }} | |
| uses: ./.github/actions/run-e2e-tests | |
| with: | |
| working-directory: src/TypeShim.E2E/vitest | |
| artifact-name: test-results-e2e | |
| rid: ${{ matrix.rid }} | |
| - name: Determine Artifact Path | |
| id: artifact-path | |
| shell: pwsh | |
| run: | | |
| # Note: this preserves the same root (pack dir) to enable merging artifacts later. For native only upload the native build in de rid dir. | |
| $path = if ('${{ matrix.rid }}' -eq 'managed') { 'src/TypeShim/bin/pack/**' } else { "src/TypeShim/bin/pack/**/${{ matrix.rid }}/**" } | |
| "artifact-path=$path" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| - name: Upload Build Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pack-build-${{ matrix.rid }} | |
| # Exclude .dSYM files for osx, keeps the package lean. Might upload | |
| path: | | |
| ${{ steps.artifact-path.outputs.artifact-path }} | |
| !**/*.dSYM/** | |
| if-no-files-found: error | |
| retention-days: 1 | |
| publish-results: | |
| name: 🧾 Publish Results | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ always() && !cancelled() }} | |
| outputs: | |
| badge-color: ${{ steps.badge.outputs.color }} | |
| badge-message: ${{ steps.badge.outputs.message }} | |
| steps: | |
| - name: Download test results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: test-results-* | |
| path: results | |
| - name: Publish test results | |
| id: test-results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: | | |
| results/**/*.trx | |
| results/**/e2e-report-*.xml | |
| - name: Determine badge content | |
| id: badge | |
| shell: pwsh | |
| run: | | |
| $path = if ("${{ fromJSON(steps.test-results.outputs.json).conclusion }}" -eq "success") { '#26cc23' } else { '#cc5623' } | |
| $message = if ("${{ fromJSON(steps.test-results.outputs.json).conclusion }}" -eq "success") { "${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs_succ }} passing" } else { "${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs_fail }}/${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} failing" } | |
| "color=$path" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| "message=$message" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
| benchmarks: | |
| name: 🏁 Benchmark Generator | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' && !cancelled() | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/run-setup | |
| - name: Build | |
| working-directory: src/TypeShim.Benchmarks | |
| shell: pwsh | |
| run: | | |
| dotnet build TypeShim.Benchmarks.csproj --configuration Release | |
| ./Scripts/build-generators.ps1 | |
| - name: Run | |
| working-directory: src/TypeShim.Benchmarks | |
| shell: pwsh | |
| run: dotnet run --configuration Release --project TypeShim.Benchmarks.csproj --no-build | |
| - name: Sticky PR Benchmark Comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: benchmark-results | |
| path: src/TypeShim.Benchmarks/BenchmarkDotNet.Artifacts/results/TypeShim.Benchmarks.GeneratorBenchmarks-report-github.md |