Add backend snapshot source providers #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| DOTNET_VERSION: 10.0.x | |
| SOLUTION: ManagedCode.FeatureChecker.slnx | |
| COVERAGE_THRESHOLD: 85 | |
| COVERAGE_FILE: ManagedCode.FeatureChecker.Tests/bin/Release/net10.0/TestResults/coverage.cobertura.xml | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore ${{ env.SOLUTION }} | |
| - name: Verify formatting | |
| run: dotnet format ${{ env.SOLUTION }} --verify-no-changes | |
| - name: Build | |
| run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore | |
| - name: Analyze | |
| run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore -p:RunAnalyzers=true | |
| - name: Test | |
| run: dotnet test --solution ${{ env.SOLUTION }} --configuration Release --no-restore --verbosity normal | |
| - name: Integration tests | |
| run: dotnet test --solution ${{ env.SOLUTION }} --configuration Release --no-build --verbosity normal -- --treenode-filter "/*/*/*/*[Category=Integration]" | |
| - name: Coverage | |
| run: dotnet test --solution ${{ env.SOLUTION }} --configuration Release --no-build --verbosity normal -- --coverage --coverage-output coverage.cobertura.xml --coverage-output-format cobertura | |
| - name: Enforce coverage threshold | |
| shell: bash | |
| run: | | |
| if [[ ! -f "${COVERAGE_FILE}" ]]; then | |
| echo "::error::Coverage file not found: ${COVERAGE_FILE}" | |
| exit 1 | |
| fi | |
| line_rate="$(sed -n 's/.*line-rate="\([^"]*\)".*/\1/p' "${COVERAGE_FILE}" | head -n 1)" | |
| if [[ -z "${line_rate}" ]]; then | |
| echo "::error::Could not read line-rate from ${COVERAGE_FILE}" | |
| exit 1 | |
| fi | |
| awk -v rate="${line_rate}" -v threshold="${COVERAGE_THRESHOLD}" 'BEGIN { | |
| coverage = rate * 100 | |
| printf("Line coverage: %.2f%%\n", coverage) | |
| if (coverage + 0.000001 < threshold) { | |
| printf("Line coverage %.2f%% is below required %.2f%%\n", coverage, threshold) | |
| exit 1 | |
| } | |
| }' | |
| - name: Upload test artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: | | |
| **/TestResults/** | |
| if-no-files-found: ignore |