68 lines
1.7 KiB
YAML
68 lines
1.7 KiB
YAML
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 --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults
|
|
|
|
- name: Generate test report
|
|
if: always()
|
|
run: |
|
|
echo "Test results:"
|
|
find ./TestResults -name "*.trx" -exec echo "Found test result file: {}" \;
|
|
echo "File sizes:"
|
|
find ./TestResults -name "*.trx" -exec ls -lh {} \;
|
|
|
|
- name: Compress test results
|
|
if: always()
|
|
run: |
|
|
if [ -d "./TestResults" ] && [ "$(ls -A ./TestResults)" ]; then
|
|
echo "Compressing test results..."
|
|
tar -czf test-results.tar.gz -C ./TestResults .
|
|
echo "Compressed file size:"
|
|
ls -lh test-results.tar.gz
|
|
else
|
|
echo "No test results to compress"
|
|
fi
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
timeout-minutes: 10
|
|
with:
|
|
name: test-results
|
|
path: |
|
|
./TestResults/
|
|
./test-results.tar.gz
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
compression-level: 6
|
|
|