mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-11-13 12:23:42 +01:00
* SonarCloud test * xxx * WebSocketIntegrationTests * move sonar to github * SonarCloud now runs for every Linux workflow event. The begin step supplies pull-request key/branch/base metadata for PRs and branch metadata for pushes; the end step is no longer gated. Workflow YAML parsing and the solution build both pass. * SHA
181 lines
7.9 KiB
YAML
181 lines
7.9 KiB
YAML
name: Run Tests
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- '**'
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
windows-build-and-run:
|
|
name: Run Tests on Windows
|
|
runs-on: windows-2022
|
|
|
|
env:
|
|
IsRunningOnGitHubActions: 'true'
|
|
|
|
steps:
|
|
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
|
|
|
- name: Setup .NET 8 and 10
|
|
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
|
|
with:
|
|
dotnet-version: |
|
|
8.0.x
|
|
10.0.x
|
|
|
|
# - name: 'WireMock.Net.TUnitTests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.TUnitTests (net10.0)'
|
|
run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net10.0
|
|
|
|
# - name: 'WireMock.Net.Tests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.Tests (net10.0)'
|
|
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net10.0
|
|
|
|
# - name: 'WireMock.Net.Tests.UsingNuGet'
|
|
# run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release
|
|
|
|
# - name: 'WireMock.Net.Middleware.Tests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.Middleware.Tests (net10.0)'
|
|
run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net10.0
|
|
|
|
linux-build-and-run:
|
|
name: Run Tests on Linux
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
IsRunningOnGitHubActions: 'true'
|
|
|
|
steps:
|
|
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
|
|
|
- name: Setup .NET 8 and 10
|
|
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
|
|
with:
|
|
dotnet-version: |
|
|
8.0.x
|
|
10.0.x
|
|
|
|
- name: Setup Java 17
|
|
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
|
|
with:
|
|
distribution: temurin
|
|
java-version: '17'
|
|
|
|
- name: Install .NET coverage and SonarScanner tools
|
|
run: |
|
|
dotnet tool install --global dotnet-sonarscanner
|
|
dotnet tool install --global dotnet-coverage
|
|
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
|
|
|
|
- name: Begin analysis on SonarCloud
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PR_BRANCH: ${{ github.head_ref }}
|
|
PR_BASE: ${{ github.base_ref }}
|
|
run: |
|
|
sonar_args=(
|
|
/k:"wiremock_WireMock.Net"
|
|
/o:"wiremock"
|
|
/d:sonar.host.url="https://sonarcloud.io"
|
|
/d:sonar.token="$SONAR_TOKEN"
|
|
/d:sonar.cs.vscoveragexml.reportsPaths="**/wiremock-coverage-*.xml"
|
|
/d:sonar.verbose=true
|
|
)
|
|
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
|
|
sonar_args+=(
|
|
/d:sonar.pullrequest.provider=github
|
|
/d:sonar.pullrequest.key="$PR_NUMBER"
|
|
/d:sonar.pullrequest.branch="$PR_BRANCH"
|
|
/d:sonar.pullrequest.base="$PR_BASE"
|
|
)
|
|
else
|
|
sonar_args+=(/d:sonar.branch.name="$GITHUB_REF_NAME")
|
|
fi
|
|
dotnet sonarscanner begin "${sonar_args[@]}"
|
|
|
|
- name: Build test projects for coverage
|
|
run: |
|
|
dotnet build ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Release --framework net10.0
|
|
dotnet build ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Release --framework net10.0
|
|
dotnet build ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Release --framework net10.0
|
|
dotnet build ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Release --framework net10.0
|
|
|
|
# - name: 'WireMock.Net.TUnitTests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.TUnitTests (net10.0) with coverage'
|
|
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-tunit.xml"
|
|
|
|
# - name: 'WireMock.Net.Tests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.Tests (net10.0) with coverage'
|
|
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-xunit.xml"
|
|
|
|
- name: 'WireMock.Net.Tests.UsingNuGet (net8.0)'
|
|
run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release --framework net8.0
|
|
|
|
# - name: 'WireMock.Net.Tests.UsingNuGet (net10.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release --framework net10.0
|
|
|
|
# - name: 'WireMock.Net.Middleware.Tests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.Middleware.Tests (net10.0) with coverage'
|
|
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-middleware.xml"
|
|
|
|
# - name: 'WireMock.Net.Aspire.Tests (net8.0)'
|
|
# run: dotnet test --project './test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj' -c Release --framework net8.0
|
|
|
|
- name: 'WireMock.Net.Aspire.Tests (net10.0) with coverage'
|
|
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-aspire.xml"
|
|
|
|
- name: Merge coverage files
|
|
run: dotnet coverage merge **/wiremock-coverage-*.xml --output ./test/wiremock-coverage.xml --output-format xml
|
|
|
|
- name: End analysis on SonarCloud
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
|
|
|
|
- name: Upload coverage results to Codecov
|
|
uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5.5.5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./test/wiremock-coverage.xml
|
|
|
|
- name: 'dotnet-WireMock stops on CTRL-C'
|
|
run: |
|
|
set -m # job control, so the background process does not ignore SIGINT
|
|
dotnet build ./src/dotnet-WireMock.Net/dotnet-WireMock.csproj -c Release
|
|
dotnet ./src/dotnet-WireMock.Net/bin/Release/net10.0/dotnet-WireMock.dll --Urls http://localhost:0 > wiremock.log 2>&1 & # port 0 = OS assigns a free port
|
|
PID=$!
|
|
sleep 3
|
|
grep -q 'Server listening at' wiremock.log || { cat wiremock.log; kill -9 $PID; exit 1; }
|
|
kill -INT $PID
|
|
for i in $(seq 1 10); do
|
|
if ! kill -0 $PID 2>/dev/null; then
|
|
EXIT_CODE=0
|
|
wait $PID || EXIT_CODE=$?
|
|
echo "dotnet-WireMock stopped (exit code $EXIT_CODE)"
|
|
exit $EXIT_CODE
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo "dotnet-WireMock did not stop within 10 seconds after CTRL-C"
|
|
kill -9 $PID
|
|
exit 1
|