Skip to content

Bump qs and express in /WebSample/ClientApp (#123) #114

Bump qs and express in /WebSample/ClientApp (#123)

Bump qs and express in /WebSample/ClientApp (#123) #114

Workflow file for this run

name: .NET Test & Coverage
permissions:
checks: write
contents: read
issues: write
on:
push:
branches: [master, next, add-unit-tests]
pull_request:
branches: [master, next, add-unit-tests]
jobs:
build-test-coverage:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["8.0.x", "9.0.x", "10.0.x"]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Verify Docker is available
run: |
docker --version
docker info
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Pull PostgreSQL Docker image
run: docker pull postgres:latest
- name: Test with coverage
env:
# Testcontainers configuration for CI
TESTCONTAINERS_RYUK_DISABLED: false
TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED: true
DOCKER_HOST: unix:///var/run/docker.sock
TESTCONTAINERS_HOST_OVERRIDE: localhost
run: >
dotnet test CachingTest/CachingTest.csproj \
--no-build --configuration Release \
--logger "trx;LogFileName=test-results.trx" \
--results-directory ./TestResults \
--collect:"XPlat Code Coverage" \
--collect:"Code Coverage"
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.dotnet-version }}
path: ./TestResults/*.trx
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: ./TestResults/*.trx
comment_mode: off
- name: Check if coverage file exists
run: |
COVERAGE_FILE=$(find ./TestResults -name "coverage.cobertura.xml" -type f | head -1)
if [ -n "$COVERAGE_FILE" ]; then
echo "Coverage file found at: $COVERAGE_FILE"
echo "COVERAGE_FILE_PATH=$COVERAGE_FILE" >> $GITHUB_ENV
else
echo "Coverage file not found, skipping report generation"
exit 0
fi
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
if: env.COVERAGE_FILE_PATH != ''
with:
name: coverage-report-${{ matrix.dotnet-version }}
path: ${{ env.COVERAGE_FILE_PATH }}
- name: Generate Coverage Report
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.5
if: env.COVERAGE_FILE_PATH != ''
with:
reports: "${{ env.COVERAGE_FILE_PATH }}"
targetdir: "./TestResults/coverage/report"
reporttypes: "MarkdownSummary;Html"
verbosity: "Info"
- name: Upload HTML Coverage Report as Artifact
uses: actions/upload-artifact@v4
if: env.COVERAGE_FILE_PATH != ''
with:
name: html-coverage-report-${{ matrix.dotnet-version }}
path: ./TestResults/coverage/report
- name: Display Coverage Summary
if: env.COVERAGE_FILE_PATH != ''
run: |
cat ./TestResults/coverage/report/Summary.md || echo 'No coverage summary found.'