feat: Add optimized CI/CD workflows with Nano/Standard separation #23
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: PR Build | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| - 'release/**' | |
| - 'maintenance/**' | |
| paths-ignore: | |
| - '*.md' | |
| - '*.png' | |
| - '*.gitignore' | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| standard-build: | |
| name: Standard - Build & Test (Linux) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| lfs: true | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| 8.0.x | |
| - name: Generate Code | |
| run: dotnet run --project CodeGen | |
| - name: Build Projects | |
| run: | | |
| echo "::group::Building Standard projects..." | |
| dotnet build UnitsNet.slnx --configuration Release | |
| echo "::endgroup::" | |
| - name: Run Tests | |
| run: | | |
| echo "::group::Running tests..." | |
| dotnet test UnitsNet.slnx --configuration Release --no-build \ | |
| --collect:"XPlat Code Coverage" \ | |
| --logger:trx \ | |
| --results-directory "Artifacts/TestResults" | |
| echo "::endgroup::" | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: standard-test-results | |
| path: Artifacts/TestResults/*.trx | |
| retention-days: 7 | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: | | |
| Artifacts/TestResults/*.trx | |
| check_name: Standard Test Results | |
| comment_mode: off | |
| - name: Upload Coverage | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: Artifacts/TestResults/**/*.xml | |
| flags: standard | |
| name: standard-coverage | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: standard-artifacts | |
| path: Artifacts/ | |
| retention-days: 7 | |
| nano-build: | |
| name: Nano - Build (Windows) | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| lfs: true | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| 8.0.x | |
| - name: Setup .NET nanoFramework | |
| uses: nanoframework/nanobuild@v1 | |
| with: | |
| workload: 'nanoFramework' | |
| - name: Generate Code | |
| shell: pwsh | |
| run: dotnet run --project CodeGen | |
| - name: Build Nano Projects | |
| shell: pwsh | |
| run: | | |
| Write-Host "::group::Building NanoFramework projects..." | |
| # Build NanoFramework projects with MSBuild | |
| $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` | |
| -latest -requires Microsoft.Component.MSBuild ` | |
| -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1 | |
| if (-not $msbuildPath) { | |
| Write-Error "MSBuild not found. Ensure Visual Studio Build Tools are installed." | |
| exit 1 | |
| } | |
| & $msbuildPath UnitsNet.NanoFramework/UnitsNet.NanoFramework.nfproj ` | |
| /p:Configuration=Release /p:Platform="Any CPU" /restore | |
| & $msbuildPath UnitsNet.NumberExtensions.NanoFramework/UnitsNet.NumberExtensions.NanoFramework.nfproj ` | |
| /p:Configuration=Release /p:Platform="Any CPU" /restore | |
| Write-Host "::endgroup::" | |
| - name: Upload Nano Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nano-artifacts | |
| path: | | |
| UnitsNet.NanoFramework/bin/Release/** | |
| UnitsNet.NumberExtensions.NanoFramework/bin/Release/** | |
| retention-days: 7 | |
| pr-status: | |
| name: PR Build Status | |
| needs: [standard-build, nano-build] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Check Status | |
| run: | | |
| echo "## Build Results" | |
| echo "Standard Build: ${{ needs.standard-build.result }}" | |
| echo "Nano Build: ${{ needs.nano-build.result }}" | |
| if [[ "${{ needs.standard-build.result }}" != "success" ]] || [[ "${{ needs.nano-build.result }}" != "success" ]]; then | |
| echo "❌ PR builds failed" | |
| exit 1 | |
| fi | |
| echo "✅ All PR builds succeeded" |