89 lines
2.5 KiB
YAML
89 lines
2.5 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: Prepare test results for upload
|
|
if: always()
|
|
run: |
|
|
if [ -d "./TestResults" ] && [ "$(ls -A ./TestResults)" ]; then
|
|
echo "Preparing test results for upload..."
|
|
echo "Original file sizes:"
|
|
find ./TestResults -type f -exec ls -lh {} \;
|
|
echo "Total directory size:"
|
|
du -sh ./TestResults
|
|
else
|
|
echo "No test results found to upload"
|
|
fi
|
|
|
|
- name: Upload test results (attempt 1)
|
|
id: upload1
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
continue-on-error: true
|
|
with:
|
|
name: test-results
|
|
path: ./TestResults/
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload test results (attempt 2)
|
|
id: upload2
|
|
if: always() && failure()
|
|
uses: actions/upload-artifact@v3
|
|
continue-on-error: true
|
|
with:
|
|
name: test-results-retry
|
|
path: ./TestResults/
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Check upload status
|
|
if: always()
|
|
run: |
|
|
if [ "${{ steps.upload1.outcome }}" == "success" ] || [ "${{ steps.upload2.outcome }}" == "success" ]; then
|
|
echo "✅ Test results uploaded successfully"
|
|
else
|
|
echo "❌ Failed to upload test results after 2 attempts"
|
|
echo "This may be due to network issues or Gitea server problems"
|
|
exit 1
|
|
fi
|
|
|