From 12b1525353eb076cb5d0dd6835d7dd0c37b3f40d Mon Sep 17 00:00:00 2001 From: Zac-AND-Digital Date: Thu, 14 Nov 2024 10:51:34 +0000 Subject: [PATCH 1/5] ci: add test reporter --- .github/workflows/build-and-test-template.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index fa1b0faa0..307666ce2 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -29,6 +29,10 @@ jobs: with: dotnet-version: ${{ inputs.dotnet_version }} + - name: Install Report Tool + shell: bash + run: dotnet tool install --global LiquidTestReports.Cli --version 2.0.0-beta.2 + - name: Package Cache uses: actions/cache@v4 with: @@ -50,8 +54,14 @@ jobs: - name: Build Project shell: bash - run: dotnet build --no-restore + run: dotnet build --configuration Release --no-restore - name: Test Project shell: bash - run: dotnet test --no-build --no-restore --verbosity minimal \ No newline at end of file + run: dotnet test --configuration Release --logger "trx;LogFileName=test-results.trx" --verbosity minimal --no-restore --no-build + + - name: Generate Report + shell: bash + run: | + liquid --inputs "File=**/*test-results.trx" --output-file results.md + cat results.md >> $GITHUB_STEP_SUMMARY \ No newline at end of file From 438c05bd41fade278f8b232ef592a17ff6513081 Mon Sep 17 00:00:00 2001 From: Zac-AND-Digital Date: Thu, 14 Nov 2024 11:10:41 +0000 Subject: [PATCH 2/5] ci: projects with no tests are skipped from the report --- .github/workflows/build-and-test-template.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index 307666ce2..5fdc334ed 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -62,6 +62,10 @@ jobs: - name: Generate Report shell: bash - run: | - liquid --inputs "File=**/*test-results.trx" --output-file results.md - cat results.md >> $GITHUB_STEP_SUMMARY \ No newline at end of file + run: |- + if find ./tests -name "*.trx" -print -quit | grep -q .; then + liquid --inputs "File=**/*test-results.trx" --output-file results.md + cat results.md >> $GITHUB_STEP_SUMMARY + else + echo "Skipping - No tests found in this project." + fi \ No newline at end of file From 84c900fe5b7208777d7543521f4984337c4d1629 Mon Sep 17 00:00:00 2001 From: Zac-AND-Digital Date: Thu, 14 Nov 2024 11:11:07 +0000 Subject: [PATCH 3/5] ci: projects with no tests are skipped from the report --- .github/workflows/build-and-test-template.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index 5fdc334ed..a79f872c5 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -63,7 +63,8 @@ jobs: - name: Generate Report shell: bash run: |- - if find ./tests -name "*.trx" -print -quit | grep -q .; then + if find ./tests -name "*.trx" -print -quit | grep -q .; + then liquid --inputs "File=**/*test-results.trx" --output-file results.md cat results.md >> $GITHUB_STEP_SUMMARY else From ba9c975eaa6f04d185b4d8c9180883d073aa03d8 Mon Sep 17 00:00:00 2001 From: Zac-AND-Digital Date: Thu, 14 Nov 2024 11:12:46 +0000 Subject: [PATCH 4/5] ci: add always flag --- .github/workflows/build-and-test-template.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index a79f872c5..21eb27a59 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -61,6 +61,7 @@ jobs: run: dotnet test --configuration Release --logger "trx;LogFileName=test-results.trx" --verbosity minimal --no-restore --no-build - name: Generate Report + if: always() shell: bash run: |- if find ./tests -name "*.trx" -print -quit | grep -q .; From 4c65f5fd4427638ec50edad2203aae1dcafba81c Mon Sep 17 00:00:00 2001 From: Zac-AND-Digital Date: Thu, 14 Nov 2024 11:15:11 +0000 Subject: [PATCH 5/5] ci: add name to the summary --- .github/workflows/build-and-test-template.yml | 5 ++++- .github/workflows/build-and-test.yml | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-template.yml b/.github/workflows/build-and-test-template.yml index 21eb27a59..23178bda9 100644 --- a/.github/workflows/build-and-test-template.yml +++ b/.github/workflows/build-and-test-template.yml @@ -9,6 +9,9 @@ on: dotnet_version: required: true type: string + job_name: + required: true + type: string jobs: build_and_test: @@ -66,7 +69,7 @@ jobs: run: |- if find ./tests -name "*.trx" -print -quit | grep -q .; then - liquid --inputs "File=**/*test-results.trx" --output-file results.md + liquid --inputs "File=**/*test-results.trx" --output-file results.md --title "${{ inputs.job_name }}" cat results.md >> $GITHUB_STEP_SUMMARY else echo "Skipping - No tests found in this project." diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bc8bca207..8336dfb4c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -74,4 +74,5 @@ jobs: uses: ./.github/workflows/build-and-test-template.yml with: working_directory: ${{ matrix.working_directory }} - dotnet_version: ${{ vars.DOTNET_VERSION_V8 }} \ No newline at end of file + dotnet_version: ${{ vars.DOTNET_VERSION_V8 }} + job_name: ${{ matrix.job_name }} \ No newline at end of file