Skip to content

Commit 90f6cd6

Browse files
authored
Merge pull request #176 from nanotaboada/feature/dotnet-ci
chore(ci): improve .NET CI workflow
2 parents db4bfdf + a8a7e6f commit 90f6cd6

File tree

1 file changed

+53
-55
lines changed

1 file changed

+53
-55
lines changed

.github/workflows/dotnet.yml

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,91 +10,89 @@ on:
1010
branches: [ "master" ]
1111

1212
jobs:
13-
1413
build:
1514
runs-on: ubuntu-latest
1615
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
1718

18-
- name: Checkout repository
19-
uses: actions/checkout@v4
19+
- name: Set up .NET 8
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: 8.0.x
2023

21-
- name: Set up .NET 8
22-
uses: actions/setup-dotnet@v4
23-
with:
24-
dotnet-version: 8.0.x
24+
- name: Cache NuGet packages
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.nuget/packages
28+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
29+
restore-keys: |
30+
${{ runner.os }}-nuget-
2531
26-
- name: Restore dependencies
27-
run: dotnet restore
32+
- name: Restore dependencies
33+
run: dotnet restore
2834

29-
- name: Build projects
30-
run: dotnet build --no-restore
35+
- name: Build projects
36+
run: dotnet build --no-restore
3137

3238
test:
3339
needs: build
3440
runs-on: ubuntu-latest
3541
steps:
3642
- name: Checkout repository
3743
uses: actions/checkout@v4
44+
3845
- name: Run tests and collect code coverage (Cobertura)
3946
run: dotnet test --results-directory "coverage" --collect:"Code Coverage;Format=cobertura"
40-
- name: Install dotnet-coverage
41-
run: dotnet tool update --global dotnet-coverage
47+
48+
- name: Install dotnet-coverage tool
49+
run: dotnet tool install --global dotnet-coverage
50+
4251
- name: Merge coverage reports
4352
run: dotnet-coverage merge coverage/**/*.cobertura.xml --output coverage/cobertura.xml --output-format cobertura
44-
- name: Install ReportGenerator
53+
54+
- name: Install ReportGenerator tool
4555
run: dotnet tool install --global dotnet-reportgenerator-globaltool
46-
- name: Run ReportGenerator to generate Markdown summary
56+
57+
- name: Generate Markdown summary
4758
run: reportgenerator -reports:coverage/cobertura.xml -targetdir:coverage -reporttypes:"MarkdownSummaryGithub"
59+
4860
- name: Display Markdown summary
4961
run: cat coverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
62+
5063
- name: Upload coverage report artifact
5164
uses: actions/upload-artifact@v4
5265
with:
5366
name: cobertura.xml
5467
path: coverage/cobertura.xml
5568

56-
coverage-codecov:
57-
needs: test
58-
runs-on: ubuntu-latest
59-
steps:
60-
61-
- name: Checkout repository
62-
uses: actions/checkout@v4
63-
64-
- name: Download coverage report artifact
65-
uses: actions/download-artifact@v4
66-
with:
67-
name: cobertura.xml
68-
69-
- name: Display structure of downloaded files
70-
run: ls -R cobertura.xml
71-
72-
- name: Upload coverage report to Codecov
73-
uses: codecov/codecov-action@v5.4.0
74-
with:
75-
token: ${{ secrets.CODECOV_TOKEN }}
76-
files: cobertura.xml
77-
use_oidc: false
78-
verbose: true
79-
80-
coverage-codacy:
69+
coverage:
8170
needs: test
8271
runs-on: ubuntu-latest
72+
strategy:
73+
matrix:
74+
service: [codecov, codacy] # Parallel jobs for Codecov and Codacy
8375
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
8478

85-
- name: Checkout repository
86-
uses: actions/checkout@v4
87-
88-
- name: Download coverage report artifact
89-
uses: actions/download-artifact@v4
90-
with:
91-
name: cobertura.xml
92-
93-
- name: Display coverage report file
94-
run: ls -lah cobertura.xml
79+
- name: Download coverage report artifact
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: cobertura.xml
9583

96-
- name: Upload coverage report to Codacy
97-
uses: codacy/codacy-coverage-reporter-action@v1.3.0
98-
with:
99-
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
100-
coverage-reports: cobertura.xml
84+
- name: Upload coverage report to ${{ matrix.service }}
85+
if: ${{ matrix.service == 'codecov' }}
86+
uses: codecov/codecov-action@v5.4.0
87+
with:
88+
token: ${{ secrets.CODECOV_TOKEN }}
89+
files: cobertura.xml
90+
use_oidc: false
91+
verbose: true
92+
93+
- name: Upload coverage report to ${{ matrix.service }}
94+
if: ${{ matrix.service == 'codacy' }}
95+
uses: codacy/codacy-coverage-reporter-action@v1.3.0
96+
with:
97+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
98+
coverage-reports: cobertura.xml

0 commit comments

Comments
 (0)