Bump the minor-and-patch group with 2 updates (#29) #67
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] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore -c Release | |
| - name: Test with Coverage | |
| run: | | |
| dotnet tool install -g dotnet-coverage | |
| dotnet-coverage collect -s coverage.runsettings -f cobertura -o ./coverage/coverage.cobertura.xml "dotnet test --no-build -c Release --verbosity normal" | |
| - name: Generate Coverage Report | |
| run: | | |
| dotnet tool install -g dotnet-reportgenerator-globaltool | |
| reportgenerator -reports:./coverage/coverage.cobertura.xml -targetdir:./coverage/report -reporttypes:"MarkdownSummaryGithub;Badges" -assemblyfilters:"+SimpleBranchVersioning" | |
| - name: Check Coverage Thresholds | |
| run: | | |
| LINE_THRESHOLD=85 | |
| BRANCH_THRESHOLD=75 | |
| LINE_RATE=$(grep -oP 'line-rate="\K[^"]+' ./coverage/coverage.cobertura.xml | head -1) | |
| BRANCH_RATE=$(grep -oP 'branch-rate="\K[^"]+' ./coverage/coverage.cobertura.xml | head -1) | |
| LINE_PCT=$(echo "$LINE_RATE * 100" | bc -l | xargs printf "%.1f") | |
| BRANCH_PCT=$(echo "$BRANCH_RATE * 100" | bc -l | xargs printf "%.1f") | |
| echo "Line coverage: $LINE_PCT% (threshold: $LINE_THRESHOLD%)" | |
| echo "Branch coverage: $BRANCH_PCT% (threshold: $BRANCH_THRESHOLD%)" | |
| FAILED=0 | |
| if (( $(echo "$LINE_PCT < $LINE_THRESHOLD" | bc -l) )); then | |
| echo "::error::Line coverage $LINE_PCT% is below threshold of $LINE_THRESHOLD%" | |
| FAILED=1 | |
| fi | |
| if (( $(echo "$BRANCH_PCT < $BRANCH_THRESHOLD" | bc -l) )); then | |
| echo "::error::Branch coverage $BRANCH_PCT% is below threshold of $BRANCH_THRESHOLD%" | |
| FAILED=1 | |
| fi | |
| if [ $FAILED -eq 1 ]; then | |
| exit 1 | |
| fi | |
| echo "::notice::Coverage thresholds met!" | |
| - name: Add Coverage to Job Summary | |
| if: always() | |
| run: cat ./coverage/report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
| - name: Publish Coverage Badge | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| mkdir -p /tmp/badges | |
| cp ./coverage/report/badge_linecoverage.svg /tmp/badges/ | |
| cp ./coverage/report/badge_branchcoverage.svg /tmp/badges/ | |
| if git ls-remote --exit-code --heads origin coverage; then | |
| git fetch origin coverage:coverage | |
| git switch coverage | |
| else | |
| git switch --orphan coverage | |
| fi | |
| cp /tmp/badges/*.svg . | |
| git add badge_linecoverage.svg badge_branchcoverage.svg | |
| if git diff --staged --quiet; then | |
| echo "No changes to coverage badges" | |
| else | |
| git commit -m "Update coverage badges" | |
| git push origin coverage | |
| fi | |
| verify-frameworks: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| dotnet-version: ['8.0', '9.0', '10.0'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET SDKs | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Build Example Apps | |
| run: | | |
| dotnet build tests/SimpleBranchVersioning.ExampleApp -c Release | |
| dotnet build tests/SimpleBranchVersioning.ConfiguredApp -c Release | |
| - name: Run ExampleApp | |
| run: dotnet run --project tests/SimpleBranchVersioning.ExampleApp -f net${{ matrix.dotnet-version }} -c Release --no-build | |
| - name: Run ConfiguredApp | |
| run: dotnet run --project tests/SimpleBranchVersioning.ConfiguredApp -f net${{ matrix.dotnet-version }} -c Release --no-build | |
| - name: Verify version.json | |
| run: | | |
| # ConfiguredApp should have version.json (GenerateVersionFile=true) | |
| if [ ! -f "tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then | |
| echo "::error::ConfiguredApp is missing version.json for net${{ matrix.dotnet-version }}" | |
| exit 1 | |
| fi | |
| echo "ConfiguredApp version.json exists for net${{ matrix.dotnet-version }}" | |
| cat tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json | |
| # ExampleApp should NOT have version.json (GenerateVersionFile=false by default) | |
| if [ -f "tests/SimpleBranchVersioning.ExampleApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then | |
| echo "::error::ExampleApp should not have version.json for net${{ matrix.dotnet-version }}" | |
| exit 1 | |
| fi | |
| echo "ExampleApp correctly has no version.json for net${{ matrix.dotnet-version }}" |