Fix TinyE5 model cache file promotion on Windows #461
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: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| CONFIGURATION: Release | |
| DOTNET_NOLOGO: true | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| SOLUTION_FILE: StemCode.CrossPlatform.slnx | |
| TEST_PROJECT: StemCode.Tests/StemCode.Tests.csproj | |
| CLI_PROJECT: StemCode.CLI/StemCode.CLI.csproj | |
| COVERAGE_THRESHOLD: 60 | |
| jobs: | |
| build-and-test: | |
| name: Build and test | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| cache: true | |
| cache-dependency-path: | | |
| StemCode/packages.lock.json | |
| StemCode.CLI/packages.lock.json | |
| StemCode.Desktop/packages.lock.json | |
| StemCode.Tests/packages.lock.json | |
| - name: Restore | |
| run: > | |
| dotnet restore ${{ env.SOLUTION_FILE }} | |
| --locked-mode | |
| -p:UseCurrentRuntimeIdentifier=false | |
| - name: Build | |
| run: dotnet build ${{ env.SOLUTION_FILE }} --configuration ${{ env.CONFIGURATION }} --no-restore | |
| - name: Pack NuGet packages | |
| run: | | |
| dotnet pack StemCode/StemCode.csproj --configuration ${{ env.CONFIGURATION }} --no-build --output ./artifacts/packages/nuget | |
| dotnet pack StemCode.CLI/StemCode.CLI.csproj --configuration ${{ env.CONFIGURATION }} --no-build --output ./artifacts/packages/nuget | |
| - name: Test with coverage | |
| run: > | |
| dotnet test ${{ env.TEST_PROJECT }} | |
| --configuration ${{ env.CONFIGURATION }} | |
| --no-restore | |
| --logger "trx;LogFileName=test-results.trx" | |
| --results-directory ./artifacts/test-results | |
| /p:CollectCoverage=true | |
| /p:CoverletOutput=../artifacts/coverage/ | |
| /p:CoverletOutputFormat=cobertura | |
| /p:Threshold=${{ env.COVERAGE_THRESHOLD }} | |
| /p:ThresholdType=line | |
| /p:ThresholdStat=total | |
| - name: Add coverage summary | |
| if: always() | |
| shell: bash | |
| run: | | |
| python - <<'PY' | |
| import os | |
| import xml.etree.ElementTree as ET | |
| coverage_path = "artifacts/coverage/coverage.cobertura.xml" | |
| summary_path = os.environ["GITHUB_STEP_SUMMARY"] | |
| threshold = os.environ.get("COVERAGE_THRESHOLD", "60") | |
| with open(summary_path, "a", encoding="utf-8") as summary: | |
| summary.write("### Coverage\n\n") | |
| if not os.path.exists(coverage_path): | |
| summary.write("Coverage report was not generated.\n") | |
| raise SystemExit(0) | |
| root = ET.parse(coverage_path).getroot() | |
| line = float(root.attrib.get("line-rate", "0")) * 100 | |
| branch = float(root.attrib.get("branch-rate", "0")) * 100 | |
| summary.write("| Metric | Value |\n") | |
| summary.write("| --- | ---: |\n") | |
| summary.write(f"| Line coverage | {line:.2f}% |\n") | |
| summary.write(f"| Branch coverage | {branch:.2f}% |\n") | |
| summary.write(f"| Minimum line coverage | {threshold}% |\n") | |
| PY | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: test-results | |
| path: artifacts/test-results | |
| if-no-files-found: warn | |
| retention-days: 14 | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage-report | |
| path: artifacts/coverage | |
| if-no-files-found: warn | |
| retention-days: 14 | |
| - name: Upload NuGet packages | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/packages/nuget | |
| if-no-files-found: warn | |
| retention-days: 14 | |
| publish-cli-test-builds: | |
| name: Publish CLI test build (${{ matrix.rid }}) | |
| needs: build-and-test | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: windows-2025 | |
| rid: win-x64 | |
| - runner: ubuntu-24.04 | |
| rid: linux-x64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| cache: true | |
| cache-dependency-path: | | |
| StemCode/packages.lock.json | |
| StemCode.CLI/packages.lock.json | |
| StemCode.Desktop/packages.lock.json | |
| StemCode.Tests/packages.lock.json | |
| - name: Publish CLI test build | |
| run: > | |
| dotnet publish ${{ env.CLI_PROJECT }} | |
| --configuration ${{ env.CONFIGURATION }} | |
| --runtime ${{ matrix.rid }} | |
| --self-contained true | |
| --output ./artifacts/publish/cli/${{ matrix.rid }} | |
| - name: Upload CLI test artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: cli-${{ matrix.rid }}-test-build | |
| path: artifacts/publish/cli/${{ matrix.rid }} | |
| if-no-files-found: error | |
| retention-days: 14 |