Skip to content

vNext

vNext #209

Workflow file for this run

name: .NET Tests
on:
pull_request:
branches:
- main
- dev
paths-ignore:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:
jobs:
tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x' # Adjust the version as needed
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Run tests with code coverage
run: dotnet test --no-build --verbosity normal --results-directory "./TestResults/Coverage/" --logger "trx;LogFileName=test_results.trx" --collect:"XPlat Code Coverage"
# - name: Publish test results
# uses: dorny/test-reporter@v1
# with:
# name: tests
# path: src/TestResults/Coverage/test_results.trx
# reporter: dotnet-trx
# fail-on-error: true
- name: Upload test results artifact
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/TestResults/**'
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: Summarize test results from .trx
run: |
TRX_FILE="TestResults/Coverage/test_results.trx"
# Register the namespace (ns) and query using that
TOTAL=$(xmllint --xpath "count(//ns:UnitTestResult)" --xmlns ns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" "$TRX_FILE")
PASSED=$(xmllint --xpath "count(//ns:UnitTestResult[@outcome='Passed'])" --xmlns ns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" "$TRX_FILE")
FAILED=$(xmllint --xpath "count(//ns:UnitTestResult[@outcome='Failed'])" --xmlns ns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" "$TRX_FILE")
SKIPPED=$(xmllint --xpath "count(//ns:UnitTestResult[@outcome='NotExecuted'])" --xmlns ns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" "$TRX_FILE")
echo "## 🧪 Test Results Summary" >> $GITHUB_STEP_SUMMARY
# Write message based on test outcome
if [ "$FAILED" -eq 0 ]; then
echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
else
echo "❌ $FAILED test(s) failed!" >> $GITHUB_STEP_SUMMARY
fi
# Append summary table
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Total | Passed | Failed | Skipped |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|--------|---------|" >> $GITHUB_STEP_SUMMARY
echo "| $TOTAL | $PASSED | $FAILED | $SKIPPED |" >> $GITHUB_STEP_SUMMARY
- name: Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Generate Markdown report
run: |
reportgenerator \
-reports:./TestResults/Coverage/**/coverage.cobertura.xml \
-targetdir:./coveragereport \
-reporttypes:MarkdownSummaryGithub
- name: Append coverage to summary
run: |
echo "## Code Coverage Summary" >> $GITHUB_STEP_SUMMARY
cat ./coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Upload code coverage report
uses: actions/upload-artifact@v4
with:
name: CodeCoverage
path: ./src/TestResults/Coverage/**/coverage.cobertura.xml
performance:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x' # Adjust the version as needed
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Performance Test
run: dotnet run --project SharpVectorPerformance --configuration Release
- name: Performance Results
run: |
echo "## Performance Results" > $GITHUB_STEP_SUMMARY
cat ./BenchmarkDotNet.Artifacts/results/SharpVectorPerformance.MemoryVectorDatabasePerformance-report-github.md >> $GITHUB_STEP_SUMMARY
- name: Upload Performance artifact
uses: actions/upload-artifact@v4
with:
name: performance-results
path: './src/BenchmarkDotNet.Artifacts/*'