Skip to content

Commit

Permalink
Merge pull request #239 from DFE-Digital/ci/test-reporter
Browse files Browse the repository at this point in the history
CI : Add Test Reporter
  • Loading branch information
Zac-Digital authored Nov 15, 2024
2 parents 96d0ddf + 4c65f5f commit ce5338c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/build-and-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
dotnet_version:
required: true
type: string
job_name:
required: true
type: string

jobs:
build_and_test:
Expand All @@ -29,6 +32,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:
Expand All @@ -50,8 +57,20 @@ 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
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 .;
then
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."
fi
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
dotnet_version: ${{ vars.DOTNET_VERSION_V8 }}
job_name: ${{ matrix.job_name }}

0 comments on commit ce5338c

Please sign in to comment.