diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml new file mode 100644 index 00000000..e6505698 --- /dev/null +++ b/.github/workflows/build-samples.yml @@ -0,0 +1,166 @@ +name: Build Samples + +on: + pull_request: + paths: + - 'rhinocommon/**' + - 'rhino3dm/**' + - 'grasshopper/**' + - 'compute/**' + - 'rhino.inside/**' + - '.github/workflows/build-samples.yml' + workflow_dispatch: + +permissions: + contents: read + +# Cancel an in-progress run when newer commits land on the same PR/ref. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build ${{ matrix.category }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + # Keep every category running even if one fails - we want full coverage. + fail-fast: false + matrix: + include: + # net48 + net9.0-windows -> needs Windows. + - category: rhinocommon + path: rhinocommon + os: windows-latest + # net7.0 + Rhino3dm NuGet (native libs for win/mac/linux) -> build on all three. + - category: rhino3dm + path: rhino3dm + os: ubuntu-latest + - category: rhino3dm + path: rhino3dm + os: macos-latest + - category: rhino3dm + path: rhino3dm + os: windows-latest + # Grasshopper/RhinoCommon NuGet, mostly net48 -> Windows. + - category: grasshopper + path: grasshopper + os: windows-latest + # RhinoCommon/Compute NuGet, net48 -> Windows. + - category: compute + path: compute + os: windows-latest + # Rhino.Inside NuGet, mixed net48/*-windows -> Windows. + - category: rhino.inside + path: rhino.inside + os: windows-latest + + steps: + - uses: actions/checkout@v6 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: 9.0.x + + # Runners ship a newer SDK (e.g. 10.x); without this, dotnet picks the + # highest installed SDK. Pin to 9.x for the whole repo during CI only. + - name: Pin .NET SDK (CI only) + shell: pwsh + run: | + @' + { + "sdk": { + "version": "9.0.100", + "rollForward": "latestFeature" + } + } + '@ | Set-Content -Path global.json + dotnet --version + + - name: Cache NuGet packages + uses: actions/cache@v5 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles(format('{0}/**/*.csproj', matrix.path)) }} + restore-keys: ${{ runner.os }}-nuget- + + - name: Build all projects + shell: pwsh + env: + CATEGORY: ${{ matrix.category }} + SEARCH_PATH: ${{ matrix.path }} + run: | + $projects = Get-ChildItem -Path $env:SEARCH_PATH -Filter *.csproj -Recurse -File | Sort-Object FullName + $summaryHeader = "## $env:CATEGORY build results" + + if ($projects.Count -eq 0) { + Write-Host "No .csproj files found under $env:SEARCH_PATH" + "$summaryHeader`n`nNo projects found under ``$env:SEARCH_PATH``." | + Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append + exit 0 + } + + $results = @() + foreach ($proj in $projects) { + $rel = (Resolve-Path -Relative $proj.FullName) -replace '\\', '/' + + # Skip legacy non-SDK projects: they need msbuild + nuget restore + # and/or an installed Rhino, so they are not built in CI for now. + $isSdkStyle = (Get-Content $proj.FullName -Raw) -match 'Copyright © 2024, Robert McNeel & Associates .rhp NU1701 + true diff --git a/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj b/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj index 540bff92..f3522175 100644 --- a/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj +++ b/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj @@ -11,6 +11,7 @@ SampleCsWpf Sample WPF Plug-in 8.0.0 + true 1701;1702;NU1701 @@ -31,6 +32,7 @@ +