chore: [SourceGenerators] Gate optimization on partial types; emit up… #236
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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: # Allow manual trigger for benchmarks | |
| env: | |
| DOTNET_NOLOGO: true | |
| INCLUDE_SYMBOLS: true | |
| jobs: | |
| pr-checks: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| cache: true | |
| cache-dependency-path: | | |
| **/packages.lock.json | |
| global.json | |
| - name: Restore | |
| run: | | |
| dotnet tool restore | |
| dotnet restore --use-lock-file | |
| - name: Drift check (generated files) | |
| shell: bash | |
| run: | | |
| echo "$HOME/.dotnet/tools" >> $GITHUB_PATH | |
| set -euo pipefail | |
| git config --global core.autocrlf false | |
| # Re-generate | |
| dotnet script src/TinyBDD/build/GenerateOverloads.csx --no-cache | |
| # Fail if anything under Generated/ changed | |
| if ! git diff --quiet --exit-code -- src/TinyBDD/Generated; then | |
| echo "::group::Generated diff" | |
| git --no-pager diff -- src/TinyBDD/Generated | |
| echo "::endgroup::" | |
| echo "::error title=Generated files out of date::Run 'dotnet script src/TinyBDD/build/GenerateOverloads.csx --no-cache' and commit the results." | |
| exit 1 | |
| fi | |
| - name: Build (Release) | |
| run: dotnet build TinyBDD.sln --configuration Release --no-restore /p:ContinuousIntegrationBuild=true | |
| - name: Test with coverage | |
| run: | | |
| dotnet test TinyBDD.sln \ | |
| --configuration Release \ | |
| --collect:"XPlat Code Coverage" \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Include="[TinyBDD*]*" \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude="[*Tests]*" | |
| - name: Install ReportGenerator | |
| run: dotnet tool update -g dotnet-reportgenerator-globaltool | |
| - name: Combine coverage and create reports | |
| shell: bash | |
| run: | | |
| REPORTS=$(find . -type f -path "*/TestResults/*/coverage.cobertura.xml" | tr '\n' ';') | |
| reportgenerator \ | |
| -reports:"$REPORTS" \ | |
| -targetdir:"coverage-report" \ | |
| -reporttypes:"HtmlInline;Cobertura;TextSummary;lcov;Badges" \ | |
| -assemblyfilters:"+TinyBDD*;-*Tests*" \ | |
| -filefilters:"-**/*.Tests/*;-**/*Tests*/**" | |
| echo "COVERAGE_SUMMARY<<EOF" >> $GITHUB_ENV | |
| cat coverage-report/Summary.txt >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Upload coverage HTML report | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage-report | |
| path: coverage-report | |
| - name: Add coverage summary to PR | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| recreate: true | |
| message: | | |
| ## Code Coverage | |
| ``` | |
| ${{ env.COVERAGE_SUMMARY }} | |
| ``` | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: | | |
| **/TestResults/*/coverage.cobertura.xml | |
| flags: unittests | |
| fail_ci_if_error: true | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Run benchmarks (smoke test) | |
| run: | | |
| cd benchmarks/TinyBDD.Benchmarks | |
| dotnet run -c Release -- --filter "TinyBDD.Benchmarks.SingleAssertionBenchmark.*" --job short --exporters json markdown | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: benchmark-results | |
| path: | | |
| benchmarks/TinyBDD.Benchmarks/BenchmarkDotNet.Artifacts/results/*.md | |
| benchmarks/TinyBDD.Benchmarks/BenchmarkDotNet.Artifacts/results/*.json | |
| release: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| cache: true | |
| cache-dependency-path: | | |
| **/packages.lock.json | |
| global.json | |
| - name: Restore | |
| run: | | |
| dotnet restore --use-lock-file | |
| dotnet tool restore | |
| - name: Drift check (generated files) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git config --global core.autocrlf false | |
| dotnet script src/TinyBDD/build/GenerateOverloads.csx --no-cache | |
| if ! git diff --quiet --exit-code -- src/TinyBDD/Generated; then | |
| echo "::group::Generated diff" | |
| git --no-pager diff -- src/TinyBDD/Generated | |
| echo "::endgroup::" | |
| echo "::error title=Generated files out of date::Run 'dotnet script src/TinyBDD/build/GenerateOverloads.csx --no-cache' and commit the results." | |
| exit 1 | |
| fi | |
| - name: Fetch tags | |
| run: git fetch --prune --tags | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4 | |
| with: | |
| versionSpec: '6.x' | |
| - name: Run GitVersion | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v4 | |
| - name: Set version env vars | |
| run: | | |
| echo "PACKAGE_VERSION=${{ steps.gitversion.outputs.majorMinorPatch }}" >> $GITHUB_ENV | |
| echo "ASSEMBLY_VERSION=${{ steps.gitversion.outputs.assemblySemVer }}" >> $GITHUB_ENV | |
| echo "FILE_VERSION=${{ steps.gitversion.outputs.assemblySemFileVer }}" >> $GITHUB_ENV | |
| - name: Build (Release) | |
| run: > | |
| dotnet build TinyBDD.sln | |
| --configuration Release | |
| --no-restore | |
| /p:ContinuousIntegrationBuild=true | |
| /p:Version=${{ env.PACKAGE_VERSION }} | |
| /p:AssemblyVersion=${{ env.ASSEMBLY_VERSION }} | |
| /p:FileVersion=${{ env.FILE_VERSION }} | |
| /p:PackageVersion=${{ env.PACKAGE_VERSION }} | |
| - name: Test (Release) | |
| run: dotnet test TinyBDD.sln --configuration Release --no-build --verbosity normal | |
| - name: Pack (all packable projects) | |
| run: > | |
| dotnet pack TinyBDD.sln | |
| --configuration Release | |
| --no-build | |
| --output ./artifacts | |
| /p:ContinuousIntegrationBuild=true | |
| /p:IncludeSymbols=${{ env.INCLUDE_SYMBOLS }} | |
| /p:SymbolPackageFormat=snupkg | |
| /p:Version=${{ env.PACKAGE_VERSION }} | |
| /p:AssemblyVersion=${{ env.ASSEMBLY_VERSION }} | |
| /p:FileVersion=${{ env.FILE_VERSION }} | |
| /p:PackageVersion=${{ env.PACKAGE_VERSION }} | |
| - name: Upload packages as artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: nuget-packages | |
| path: | | |
| ./artifacts/*.nupkg | |
| ./artifacts/*.snupkg | |
| - name: Create and push git tag | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions" | |
| git config user.email "[email protected]" | |
| if git rev-parse "v${PACKAGE_VERSION}" >/dev/null 2>&1; then | |
| echo "Tag v${PACKAGE_VERSION} already exists. Skipping tag push." | |
| else | |
| git tag "v${PACKAGE_VERSION}" | |
| git push origin "v${PACKAGE_VERSION}" | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ env.PACKAGE_VERSION }} | |
| name: Release v${{ env.PACKAGE_VERSION }} | |
| files: | | |
| ./artifacts/*.nupkg | |
| ./artifacts/*.snupkg | |
| generate_release_notes: true | |
| - name: Push to NuGet.org | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| if [ -n "$NUGET_API_KEY" ]; then | |
| dotnet nuget push ./artifacts/*.nupkg \ | |
| --api-key "$NUGET_API_KEY" \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| else | |
| echo "Skipping NuGet.org push: API key not set." | |
| fi | |
| - name: Push to GitHub Packages (optional) | |
| run: | | |
| dotnet nuget push "./artifacts/*.nupkg" \ | |
| --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ | |
| --api-key "${{ secrets.GITHUB_TOKEN }}" \ | |
| --skip-duplicate | |
| dotnet nuget push "./artifacts/*.snupkg" \ | |
| --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ | |
| --api-key "${{ secrets.GITHUB_TOKEN }}" \ | |
| --skip-duplicate | |
| benchmarks: | |
| # Only run on manual trigger to avoid wasting CI time | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 9.0.x | |
| cache: true | |
| cache-dependency-path: | | |
| **/packages.lock.json | |
| global.json | |
| - name: Restore | |
| run: dotnet restore --use-lock-file | |
| - name: Build benchmarks | |
| run: dotnet build benchmarks/TinyBDD.Benchmarks/TinyBDD.Benchmarks.csproj -c Release --no-restore | |
| - name: Run full benchmark suite | |
| run: | | |
| cd benchmarks/TinyBDD.Benchmarks | |
| dotnet run -c Release --no-build -- --exporters json markdown html | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: benchmark-results-full | |
| path: | | |
| benchmarks/TinyBDD.Benchmarks/BenchmarkDotNet.Artifacts/results/* | |