CI • 74 • Merge pull request #17 from Cabazure/net9.0 Update to net9.0 #74
This file contains 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 and Test | |
run-name: CI • ${{ github.run_number }} • ${{ github.event.head_commit.message }} | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/coveragereport/**' | |
- 'docs/**' | |
- '*.md' | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: write | |
actions: read | |
checks: write | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: 🛒 Checkout repository | |
uses: actions/checkout@v4 | |
- name: ⚙️ Setup dotnet 9.0.x | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
- name: 🧹 Clean | |
run: dotnet clean -c Release && dotnet nuget locals all --clear | |
- name: 🏗️ Restore dependencies | |
run: dotnet restore | |
- name: 🛠️ Build solution | |
run: dotnet build --no-restore -c:Release | |
- name: 🧪 Run tests | |
run: dotnet test --no-build -c:Release --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" || true | |
- name: 📋 Test Report | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: Test Report | |
path: "**/test-results.trx" | |
reporter: dotnet-trx | |
fail-on-error: true | |
- name: 📭 Restore coverage history | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
name: CoverageHistory | |
path: CoverageHistory | |
continue-on-error: true | |
- name: 📝 Generate Coverage report | |
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.0 | |
with: | |
reports: "**/coverage.cobertura.xml" | |
targetdir: .github/coveragereport | |
historydir: CoverageHistory | |
reporttypes: MarkdownSummaryGithub;MarkdownDeltaSummary;HtmlInline;Badges | |
filefilters: -*.g.cs | |
tag: '${{ github.run_number }}_${{ github.run_id }}' | |
- name: 📨 Post code coverage results | |
run: | | |
cat .github/coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
- name: 📬 Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CoverageReports | |
path: .github/coveragereport | |
- name: 📬 Upload coverage history | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CoverageHistory | |
path: CoverageHistory | |
- name: 🪧 Commit and push Badges | |
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
run: | | |
cd .github/coveragereport | |
git add badge_*coverage.svg | |
if [[ `git status --porcelain badge_*coverage.svg` ]]; then | |
git config --global user.email "${{github.actor}}@users.noreply.github.com" | |
git config --global user.name "${{github.actor}}" | |
git commit -m "Autogenerated coverage badge" badge_*coverage.svg | |
git push | |
fi | |