Merge pull request #2813 from DavidObando/feature/if-let-expressions #3630
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: build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET SDK (main) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Restore | |
| run: dotnet restore GSharp.sln | |
| - name: Restore .NET local tools | |
| # Brings in `dotnet-ilverify`, which Compiler.Tests invokes via | |
| # `IlVerifier.Verify` to mechanically validate every assembly emitted | |
| # by gsc against ECMA-335. The manifest is at .config/dotnet-tools.json. | |
| run: dotnet tool restore | |
| - name: Show Nerdbank.GitVersioning version | |
| # Surface the version nbgv will stamp on assemblies / NuGet packages so | |
| # that, when a build from `main` is green, the printed NuGetPackageVersion | |
| # can be used directly as the `vX.Y.Z` release tag. | |
| run: | | |
| dotnet tool install --global nbgv || dotnet tool update --global nbgv | |
| export PATH="$PATH:$HOME/.dotnet/tools" | |
| nbgv get-version | |
| { | |
| echo "### Nerdbank.GitVersioning" | |
| echo '' | |
| echo '```' | |
| nbgv get-version | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| - name: Build | |
| # Build the solution explicitly with the static project graph so each | |
| # project (notably Compiler, which is referenced by Compiler.Tests) is | |
| # built exactly once. A bare `dotnet build` schedules projects in | |
| # parallel against a shared OutputPath and can race on | |
| # GenerateRuntimeConfigurationFiles writing `gsc.runtimeconfig.json`. | |
| run: dotnet build GSharp.sln --configuration Release --no-restore -graph | |
| - name: Test | |
| env: | |
| # Cs2Gs.Tests launches many nested SDK builds; reusable MSBuild | |
| # workers eventually exhaust the test host's resources (#2407). | |
| MSBUILDDISABLENODEREUSE: 1 | |
| run: dotnet test GSharp.sln --configuration Release --no-build --logger "trx" --results-directory TestResults | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: test-results | |
| path: TestResults/**/*.trx | |
| - name: Upload NuGet packages | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: nuget-packages | |
| # Include .snupkg symbol packages alongside .nupkg so they survive | |
| # to the publish job (dotnet nuget push / gh release upload need | |
| # them co-located in ./nupkgs to pick them up). | |
| path: out/bin/Release/nupkgs/* | |
| e2e: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET SDK (main) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Setup .NET 8 (for multitarget tests) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore | |
| run: dotnet restore GSharp.sln | |
| - name: Install netcoredbg | |
| run: | | |
| URL=$(curl -sSL https://api.github.com/repos/Samsung/netcoredbg/releases/latest \ | |
| | grep -oP '"browser_download_url":\s*"\K[^"]*linux-amd64\.tar\.gz') | |
| curl -sSL "$URL" -o /tmp/netcoredbg.tar.gz | |
| mkdir -p "$HOME/.tools/netcoredbg" | |
| tar -xzf /tmp/netcoredbg.tar.gz -C "$HOME/.tools/netcoredbg" --strip-components=1 | |
| echo "$HOME/.tools/netcoredbg" >> "$GITHUB_PATH" | |
| - name: Run end-to-end tests | |
| run: ./build/run-e2e-tests.sh | |
| cs2gs: | |
| # ADR-0138: the C#→G# migration quality gate. Runs the full in-repo corpus | |
| # (L1–L5 + the conformance grid) through translate → compile → ilverify → | |
| # test-parity and gates on the gap ledger: any fingerprint NOT ledgered in | |
| # tools/cs2gs/triage/gaps.json (NEW) or ledgered as resolved but | |
| # reproducing (REGRESSED) fails the job; known-open gaps do not. | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET SDK (main) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Restore | |
| run: dotnet restore GSharp.sln | |
| - name: Restore .NET local tools | |
| # dotnet-ilverify for the pipeline's stage 3. | |
| run: dotnet tool restore | |
| - name: Build | |
| run: dotnet build GSharp.sln --configuration Release --no-restore -graph | |
| - name: Migrate corpus (ledger-gated) | |
| run: | | |
| set +e | |
| dotnet out/bin/Release/Cs2Gs.Cli/cs2gs.dll migrate \ | |
| --diagnostic-run \ | |
| --corpus tools/cs2gs/corpus \ | |
| --baseline tools/cs2gs/triage/gaps.json \ | |
| --out cs2gs-ci-runs \ | |
| --config Release | tee cs2gs-migrate.log | |
| exit_code=${PIPESTATUS[0]} | |
| { | |
| echo "### cs2gs corpus migration" | |
| echo '' | |
| echo '```' | |
| cat cs2gs-migrate.log | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| exit "$exit_code" | |
| - name: Upload migration report | |
| if: always() | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: cs2gs-report | |
| path: | | |
| cs2gs-ci-runs/**/report.html | |
| cs2gs-ci-runs/**/summary.json | |
| cs2gs-ci-runs/**/run.json | |
| vscode-extension: | |
| name: vscode-extension (${{ matrix.os }}) | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| working-directory: src/vscode-gsharp | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| cache-dependency-path: src/vscode-gsharp/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Compile | |
| run: npm run compile | |
| - name: Lint | |
| run: npm run lint | |
| - name: Unit Tests | |
| run: npm run test:unit | |
| vsix: | |
| runs-on: ubuntu-latest | |
| needs: vscode-extension | |
| defaults: | |
| run: | |
| working-directory: src/vscode-gsharp | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| cache-dependency-path: src/vscode-gsharp/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Compile | |
| run: npm run compile | |
| - name: Stamp version (Nerdbank.GitVersioning) | |
| # The VS Code Marketplace requires a strict major.minor.patch version, so | |
| # use nbgv's SimpleVersion (0.1.<git-height>) which is always clean across | |
| # branches and tags. The change is workspace-only and never committed. | |
| run: | | |
| dotnet tool install --global nbgv || dotnet tool update --global nbgv | |
| export PATH="$PATH:$HOME/.dotnet/tools" | |
| VERSION=$(nbgv get-version -v SimpleVersion) | |
| echo "Extension version: $VERSION" | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Package VSIX | |
| run: npx vsce package --no-dependencies -o vscode-gsharp.vsix | |
| - name: Upload VSIX | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: vscode-gsharp-vsix | |
| path: src/vscode-gsharp/vscode-gsharp.vsix | |
| visual-studio-extension: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Verify generated assets | |
| shell: pwsh | |
| run: ./src/vs-gsharp/scripts/Sync-SharedAssets.ps1 -Check | |
| - name: Build Visual Studio VSIX | |
| run: msbuild src\vs-gsharp\VsGsharp.sln /restore /t:Build /p:Configuration=Release /m /v:minimal /nologo | |
| - name: Test Visual Studio extension | |
| run: dotnet test src\vs-gsharp\test\VsGsharp.UnitTests\VsGsharp.UnitTests.csproj --configuration Release --no-build | |
| - name: Upload Visual Studio VSIX | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: visual-studio-gsharp-vsix | |
| path: src/vs-gsharp/src/VsGsharp/bin/Release/net472/GSharp.VisualStudio.vsix | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [e2e, vsix, visual-studio-extension] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download NuGet packages | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: nuget-packages | |
| path: ./nupkgs | |
| - name: Download VSIX | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: vscode-gsharp-vsix | |
| path: ./vsix | |
| - name: Download Visual Studio VSIX | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: visual-studio-gsharp-vsix | |
| path: ./vsix | |
| - name: Create GitHub Release with all assets | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \ | |
| || gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --generate-notes --title "$GITHUB_REF_NAME" | |
| gh release upload "$GITHUB_REF_NAME" ./nupkgs/*.nupkg ./nupkgs/*.snupkg ./vsix/*.vsix --repo "$GITHUB_REPOSITORY" --clobber | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Push to NuGet | |
| run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '24' | |
| - name: Publish to VS Code Marketplace | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: npx --yes @vscode/vsce publish --packagePath ./vsix/vscode-gsharp.vsix | |
| publish-visual-studio-extension: | |
| runs-on: windows-latest | |
| needs: publish | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Download Visual Studio VSIX | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: visual-studio-gsharp-vsix | |
| path: ./vsix | |
| - name: Publish to Visual Studio Marketplace | |
| shell: pwsh | |
| env: | |
| VS_MARKETPLACE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: | | |
| $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" | |
| $installPath = & $vswhere -latest -products * ` | |
| -requires Microsoft.VisualStudio.Component.VSSDK ` | |
| -property installationPath | |
| if (-not $installPath) { | |
| throw "Visual Studio SDK installation not found." | |
| } | |
| $publisher = Join-Path $installPath ` | |
| "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" | |
| if (-not (Test-Path $publisher)) { | |
| throw "VsixPublisher.exe not found at $publisher." | |
| } | |
| & $publisher publish ` | |
| -payload "$PWD\vsix\GSharp.VisualStudio.vsix" ` | |
| -publishManifest "$PWD\src\vs-gsharp\vs-publish.json" ` | |
| -personalAccessToken $env:VS_MARKETPLACE_PAT | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "Visual Studio Marketplace publishing failed with exit code $LASTEXITCODE." | |
| } |