add tests
This commit is contained in:
87
.gitea/workflows/test.yml
Normal file
87
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
name: Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '9.0.x'
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore --verbosity normal
|
||||
|
||||
- name: Build solution
|
||||
run: dotnet build --no-restore --verbosity normal
|
||||
|
||||
- name: Run unit tests
|
||||
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./TestResults
|
||||
|
||||
- name: Generate test report
|
||||
if: always()
|
||||
run: |
|
||||
echo "Test results:"
|
||||
find ./TestResults -name "*.trx" -exec echo "Found test result file: {}" \;
|
||||
find ./TestResults -name "*.xml" -exec echo "Found coverage file: {}" \;
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results
|
||||
path: ./TestResults/
|
||||
retention-days: 30
|
||||
|
||||
test-windows:
|
||||
name: Run Tests (Windows)
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '9.0.x'
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore --verbosity normal
|
||||
|
||||
- name: Build solution
|
||||
run: dotnet build --no-restore --verbosity normal
|
||||
|
||||
- name: Run unit tests
|
||||
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./TestResults
|
||||
|
||||
- name: Generate test report
|
||||
if: always()
|
||||
run: |
|
||||
echo "Test results:"
|
||||
Get-ChildItem -Path ./TestResults -Recurse -Filter "*.trx" | ForEach-Object { Write-Host "Found test result file: $($_.FullName)" }
|
||||
Get-ChildItem -Path ./TestResults -Recurse -Filter "*.xml" | ForEach-Object { Write-Host "Found coverage file: $($_.FullName)" }
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results-windows
|
||||
path: ./TestResults/
|
||||
retention-days: 30
|
||||
Reference in New Issue
Block a user