Skip to content

Commit 7ea4591

Browse files
authored
Fix .NET quality extra vars (#13)
* Fix invalid ref on extra vars for dotnet quality * Remove useless comment * Remove mongodb start from dotnet quality * Explicit bash shell * Explicit disable git autocrlf * Add check on generate report * Update check * Update * Improve dotnet test sonar with test args * Pass arguments to dotnet sonar
1 parent d766395 commit 7ea4591

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

.github/workflows/reusable-dotnet-quality.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ on:
88
type: string
99
required: false
1010
default: ""
11+
dotnet-test-args:
12+
description: ".NET test arguments (for example \"--report-xunit-trx --coverage --coverage-output-format cobertura\")"
13+
type: string
14+
required: false
15+
default: ""
1116
dotnet-version:
1217
description: .NET version
1318
type: string
19+
required: false
1420
default: "10.0"
1521
extra-vars:
1622
description: "Additional environment variables at the start of the pipeline"
@@ -32,11 +38,6 @@ on:
3238
type: string
3339
required: false
3440
default: Quality
35-
mongodb-enabled:
36-
description: "Start MongoDB for integration tests?"
37-
type: boolean
38-
required: false
39-
default: false
4041
operating-system:
4142
description: Operating system executing the runner
4243
type: string
@@ -94,12 +95,15 @@ jobs:
9495
working-directory: ${{ inputs.working-directory }}
9596
steps:
9697
- name: Set additional variables
98+
shell: bash
9799
run: |
98-
if [[ -z "${{ secrets.extra-vars }}" ]]; then
99-
echo "No extra-vars provided - skipping"
100-
else
101-
echo "${{ secrets.extra-vars }}" >> "$GITHUB_ENV"
100+
if [[ -n "${{ inputs.extra-vars }}" ]]; then
101+
echo "${{ inputs.extra-vars }}" >> "$GITHUB_ENV"
102102
fi
103+
- name: Disable git autocrlf
104+
if: ${{ inputs.operating-system == 'windows-latest' }}
105+
run: git config --global core.autocrlf false
106+
shell: bash
103107
- name: Clone repository
104108
uses: actions/checkout@v6
105109
with:
@@ -114,20 +118,20 @@ jobs:
114118
uses: ./workflow-parts/actions/dotnet/install-lint-restore
115119
with:
116120
dotnet-version: ${{ inputs.dotnet-version }}
117-
- name: Start MongoDB
118-
if: ${{ inputs.mongodb-enabled }}
119-
uses: ./workflow-parts/actions/mongodb/start
120121
- name: Run optional custom commands
121122
if: ${{ inputs.custom-commands != '' }}
122123
run: |
123124
${{ inputs.custom-commands }}
124125
- name: Build & test
125126
if: ${{ ! inputs.sonar-enabled }}
126127
uses: ./workflow-parts/actions/dotnet/build-test
128+
with:
129+
dotnet-test-args: ${{ inputs.dotnet-test-args }}
127130
- name: Build, test & analyze
128131
if: ${{ inputs.sonar-enabled }}
129132
uses: ./workflow-parts/actions/dotnet/build-test-sonar
130133
with:
134+
dotnet-test-args: ${{ inputs.dotnet-test-args }}
131135
sonar-organization: ${{ inputs.sonar-organization }}
132136
sonar-host-url: ${{ inputs.sonar-host-url }}
133137
sonar-project-name: ${{ inputs.sonar-project-name }}

.github/workflows/reusable-terraform-deployment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ jobs:
9898
ref: ${{ inputs.workflow-parts-version }}
9999
path: workflow-parts
100100
- name: Add runner ID to MongoDB Atlas
101-
# uses: devpro/github-workflow-parts/actions/mongodb-atlas/add-runner-ip@... cannot be used with an input parameter in it (must be static) so checkout is mandatory
102101
uses: ./workflow-parts/actions/mongodb-atlas/add-runner-ip
103102
with:
104103
atlas-publickey: ${{ secrets.atlas-publickey }}

actions/dotnet/build-test-sonar/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Build, Test & Analyze
22
description: Builds, runs tests on a .NET codebase and run analysis with Sonar
33

44
inputs:
5+
dotnet-test-args:
6+
description: .NET test arguments
7+
required: false
8+
default: ""
59
java-version:
610
description: Java version that will be installed (for Sonar CLI)
711
required: false
@@ -78,12 +82,12 @@ runs:
7882
run: |
7983
dotnet test --no-build --verbosity normal --configuration Debug \
8084
--results-directory "${{ inputs.report-folder }}/TestResults" \
81-
--report-xunit-trx \
82-
--coverage --coverage-output-format cobertura
85+
${{ inputs.dotnet-test-args }}
8386
shell: bash
8487
env:
8588
ASPNETCORE_ENVIRONMENT: Development
8689
- name: Generate test report
90+
if: ${{ always() && hashFiles(format('{0}/TestResults/*.cobertura.xml', inputs.report-folder)) != '' }}
8791
run: |
8892
reportgenerator "-reports:${{ inputs.report-folder }}/TestResults/*.cobertura.xml" \
8993
"-targetdir:${{ inputs.report-folder }}" \

actions/dotnet/build-test/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Build & Test
22
description: Builds and runs tests on a .NET codebase
33

44
inputs:
5+
dotnet-test-args:
6+
description: .NET test arguments
7+
required: false
8+
default: ""
59
report-folder:
610
description: Folder where report files will be generated
711
required: false
@@ -13,17 +17,18 @@ runs:
1317
- name: Build .NET code
1418
run: dotnet build --no-restore --configuration Debug
1519
shell: bash
16-
- name: Run .NET tests
20+
- name: Run tests
1721
run: |
1822
dotnet test --no-build --verbosity normal --configuration Debug \
19-
--logger:"junit;LogFilePath=..\..\artifacts\{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \
20-
--collect:"XPlat Code Coverage"
23+
--results-directory "${{ inputs.report-folder }}/TestResults" \
24+
${{ inputs.dotnet-test-args }}
2125
shell: bash
2226
env:
2327
ASPNETCORE_ENVIRONMENT: Development
2428
- name: Generate test report
29+
if: ${{ always() && hashFiles(format('{0}/TestResults/*.cobertura.xml', inputs.report-folder)) != '' }}
2530
run: |
26-
reportgenerator "-reports:./test/*/TestResults/*/coverage.cobertura.xml" \
31+
reportgenerator "-reports:${{ inputs.report-folder }}/TestResults/*.cobertura.xml" \
2732
"-targetdir:${{ inputs.report-folder }}" \
2833
"-reporttypes:Cobertura;Html;TextSummary"
2934
shell: bash

0 commit comments

Comments
 (0)