Skip to content

Commit 37934dd

Browse files
author
Jochen
committed
split workflows again for separate badge icons and test report inside github ui
1 parent 47f5c88 commit 37934dd

2 files changed

Lines changed: 64 additions & 53 deletions

File tree

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
name: CI/CD Pipeline
1+
name: Release Builder
22

33
on:
44
push:
5-
branches:
6-
- '**'
75
tags:
86
- 'v*'
9-
pull_request:
107
workflow_dispatch:
118

129
jobs:
13-
tests:
10+
test-build-release:
1411
name: Run Unit Tests with Coverage
1512
runs-on: windows-latest
13+
env:
14+
PROJECT_NAME: OffRouteMap
1615
outputs:
1716
test_outcome: ${{ steps.tests.outcome }}
1817
steps:
@@ -35,70 +34,32 @@ jobs:
3534
run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults --collect:"XPlat Code Coverage"
3635

3736
- name: Publish Test Report to GitHub UI
38-
uses: dorny/test-reporter@v1
3937
if: always()
38+
uses: dorny/test-reporter@v1
4039
with:
4140
name: Unit Tests
4241
path: ./TestResults/test-results.trx
4342
reporter: dotnet-trx
4443

4544
- name: Generate HTML Coverage Report
45+
if: success()
4646
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.5
4747
with:
4848
reports: 'TestResults/**/coverage.cobertura.xml'
4949
targetdir: 'coveragereport'
5050
reporttypes: 'HtmlInline;Cobertura'
5151

52-
- name: Upload Coverage Report as Artifact
53-
uses: actions/upload-artifact@v4
54-
with:
55-
name: Code-Coverage-Report
56-
path: coveragereport
57-
58-
- name: Upload Test Results as Artifact
59-
uses: actions/upload-artifact@v4
60-
with:
61-
name: TestResults
62-
path: ./TestResults
63-
64-
build-and-release:
65-
name: Build and Release (only for tags)
66-
runs-on: windows-latest
67-
needs: tests
68-
if: startsWith(github.ref, 'refs/tags/v')
69-
env:
70-
PROJECT_NAME: OffRouteMap
71-
steps:
72-
- name: Checkout code
73-
uses: actions/checkout@v4
74-
75-
- name: Setup .NET
76-
uses: actions/setup-dotnet@v4
77-
with:
78-
dotnet-version: '8.0.x'
79-
80-
- name: Restore dependencies
81-
run: dotnet restore
82-
83-
- name: Build
84-
run: dotnet build --configuration Release --no-restore
52+
- name: Zip Coverage Report
53+
if: success()
54+
run: |
55+
powershell Compress-Archive -Path coveragereport\* -DestinationPath coverage-report.zip
8556
8657
- name: Publish
58+
if: success()
8759
run: dotnet publish ${env.PROJECT_NAME}.csproj -c Release --self-contained true -r win-x64 /p:PublishSingleFile=true /p:IncludeAllContentForSelfExtract=true -o publish
8860

89-
- name: Download Test Results
90-
uses: actions/download-artifact@v4
91-
with:
92-
name: TestResults
93-
path: ./TestResults
94-
95-
- name: Download Coverage Report
96-
uses: actions/download-artifact@v4
97-
with:
98-
name: Code-Coverage-Report
99-
path: coveragereport
100-
10161
- name: Create GitHub Release and Upload Files
62+
if: success()
10263
uses: softprops/action-gh-release@v2
10364
with:
10465
tag_name: ${{ github.ref }}
@@ -107,5 +68,5 @@ jobs:
10768
prerelease: false
10869
files: |
10970
publish/${{ env.PROJECT_NAME }}.exe
110-
TestResults/**
111-
coveragereport/**
71+
coverage-report.zip
72+
TestResults/test-results.trx

.github/workflows/tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Tests
3+
4+
on:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
tests:
10+
name: Run Unit Tests with Coverage
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v3
19+
with:
20+
dotnet-version: '8.0.x'
21+
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
25+
- name: Build
26+
run: dotnet build --no-restore --configuration Release
27+
28+
- name: Run Tests and collect Coverage
29+
run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults --collect:"XPlat Code Coverage"
30+
31+
- name: Publish Test Report to GitHub UI
32+
uses: dorny/test-reporter@v1
33+
if: always()
34+
with:
35+
name: Unit Tests
36+
path: ./TestResults/test-results.trx
37+
reporter: dotnet-trx
38+
39+
- name: Generate HTML Coverage Report
40+
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.5
41+
with:
42+
reports: 'TestResults/**/coverage.cobertura.xml'
43+
targetdir: 'coveragereport'
44+
reporttypes: 'HtmlInline;Cobertura'
45+
46+
- name: Upload Coverage Report as Artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: Code-Coverage-Report
50+
path: coveragereport

0 commit comments

Comments
 (0)