125 lines
4.1 KiB
YAML
125 lines
4.1 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 minimal --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 to reduce upload size..."
|
|
echo "Original file sizes:"
|
|
find ./TestResults -type f -exec ls -lh {} \;
|
|
echo "Total directory size:"
|
|
du -sh ./TestResults
|
|
|
|
# Create compressed archive
|
|
tar -czf test-results-compressed.tar.gz -C ./TestResults .
|
|
echo "Compressed file size:"
|
|
ls -lh test-results-compressed.tar.gz
|
|
|
|
# Create a minimal summary file
|
|
echo "Test Results Summary" > test-summary.txt
|
|
echo "===================" >> test-summary.txt
|
|
echo "Generated: $(date)" >> test-summary.txt
|
|
echo "Files:" >> test-summary.txt
|
|
find ./TestResults -type f -exec basename {} \; >> test-summary.txt
|
|
echo "Summary file created:"
|
|
ls -lh test-summary.txt
|
|
else
|
|
echo "No test results found to compress"
|
|
fi
|
|
|
|
- name: Upload compressed test results (attempt 1)
|
|
id: upload1
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
continue-on-error: true
|
|
with:
|
|
name: test-results-compressed
|
|
path: |
|
|
./test-results-compressed.tar.gz
|
|
./test-summary.txt
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload original test results (attempt 2)
|
|
id: upload2
|
|
if: always() && failure()
|
|
uses: actions/upload-artifact@v4
|
|
continue-on-error: true
|
|
with:
|
|
name: test-results-original
|
|
path: ./TestResults/
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload summary only (attempt 3)
|
|
id: upload3
|
|
if: always() && failure()
|
|
uses: actions/upload-artifact@v4
|
|
continue-on-error: true
|
|
with:
|
|
name: test-results-summary
|
|
path: ./test-summary.txt
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Check upload status
|
|
if: always()
|
|
run: |
|
|
if [ "${{ steps.upload1.outcome }}" == "success" ]; then
|
|
echo "✅ Compressed test results uploaded successfully"
|
|
elif [ "${{ steps.upload2.outcome }}" == "success" ]; then
|
|
echo "✅ Original test results uploaded successfully"
|
|
elif [ "${{ steps.upload3.outcome }}" == "success" ]; then
|
|
echo "✅ Test summary uploaded successfully (full results failed)"
|
|
else
|
|
echo "❌ Failed to upload test results after 3 attempts"
|
|
echo "This may be due to persistent network issues or Gitea server problems"
|
|
echo "Consider checking:"
|
|
echo " - Gitea server status"
|
|
echo " - Network connectivity"
|
|
echo " - Artifact storage configuration"
|
|
# Don't fail the workflow - tests passed, just upload failed
|
|
echo "⚠️ Workflow will continue despite upload failure"
|
|
fi
|
|
|