Skip to content

Commit

Permalink
Merge pull request #72 from nanotaboada/feature/dotnet-test
Browse files Browse the repository at this point in the history
feat(ci): updated workflow jobs
  • Loading branch information
nanotaboada authored Apr 19, 2024
2 parents 1344477 + cfb45e8 commit 8627ab8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 7 deletions.
68 changes: 65 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
Expand All @@ -28,11 +29,72 @@ jobs:
- name: Build projects
run: dotnet build --no-restore

- name: Run tests and collect coverage
run: dotnet test --no-build --collect:"XPlat Code Coverage"
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests and collect code coverage (Cobertura)
run: dotnet test --results-directory "coverage" --collect:"Code Coverage;Format=cobertura"
- name: Install dotnet-coverage
run: dotnet tool update --global dotnet-coverage
- name: Merge coverage reports
run: dotnet-coverage merge coverage/**/*.cobertura.xml --output coverage/cobertura.xml --output-format cobertura
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Run ReportGenerator to generate Markdown summary
run: reportgenerator -reports:coverage/cobertura.xml -targetdir:coverage -reporttypes:"MarkdownSummaryGithub"
- name: Display Markdown summary
run: cat coverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: cobertura.xml
path: coverage/cobertura.xml

coverage-codecov:
needs: test
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: cobertura.xml

- name: Display structure of downloaded files
run: ls -R cobertura.xml

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4.3.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cobertura.xml
use_oidc: false
verbose: true

coverage-codacy:
needs: test
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: cobertura.xml

- name: Display coverage report file
run: ls -lah cobertura.xml

- name: Upload coverage report to Codacy
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: cobertura.xml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ coverage*.info
*.coverage
*.coveragexml

# dotnet test code coverage results
coverage

# NCrunch
_NCrunch_*
.*crunch*.local.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8627ab8

Please sign in to comment.