refactor(sentry_integration): enhance error handling and telemetry ac… #880
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: Tests | |
| on: | |
| push: | |
| branches: [main, 'v[0-9]+.[0-9]+.[0-9]+*'] | |
| pull_request: | |
| branches: [main, 'v[0-9]+.[0-9]+.[0-9]+*'] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| PYTHON_VERSION: 3.13.8 | |
| COVERAGE_THRESHOLD: 80 | |
| ARTIFACT_RETENTION_DAYS: 7 | |
| jobs: | |
| changes: | |
| name: File Detection | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| python: ${{ steps.python_changes.outputs.any_changed }} | |
| tests: ${{ steps.test_changes.outputs.any_changed }} | |
| any: ${{ steps.test_changes.outputs.any_changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check Python | |
| uses: tj-actions/changed-files@v46 | |
| id: python_changes | |
| with: | |
| files: | | |
| **/*.py | |
| pyproject.toml | |
| uv.lock | |
| files_ignore: | | |
| tests/**/*.py | |
| **/tests/**/*.py | |
| **/migrations/**/*.py | |
| src/tux/database/migrations/**/*.py | |
| - name: Check Tests | |
| uses: tj-actions/changed-files@v46 | |
| id: test_changes | |
| with: | |
| files: | | |
| tests/** | |
| conftest.py | |
| - name: Set Outputs | |
| run: ./.github/scripts/tests.sh set-change-outputs \ "${{ steps.python_changes.outputs.any_changed }}" | |
| \ "${{ steps.test_changes.outputs.any_changed }}" | |
| test: | |
| name: Run All Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| needs: [changes] | |
| if: needs.changes.outputs.any == 'true' || github.event_name == 'workflow_dispatch' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| # Required for Codecov OIDC authentication | |
| # Allows the action to authenticate with Codecov using OpenID Connect | |
| # instead of requiring a CODECOV_TOKEN secret | |
| id-token: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: [3.13.8] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: ./.github/actions/setup-python | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| enable-cache: true | |
| - name: Create Test Environment | |
| uses: ./.github/actions/create-test-env | |
| with: | |
| additional-vars: | | |
| BOT_TOKEN=test_token_for_ci | |
| DEBUG=True | |
| - name: Install Coverage Tools | |
| run: | | |
| uv sync --group docs --group test --no-dev | |
| - name: Run All Tests with Coverage | |
| run: | | |
| echo "Running all tests with unified coverage..." | |
| # Run all test types with combined coverage | |
| uv run pytest \ | |
| --cov-report=xml:coverage.xml \ | |
| --cov-report=html:htmlcov \ | |
| --cov-report=term-missing:skip-covered \ | |
| --junitxml=junit.xml \ | |
| --cov-fail-under=${{ env.COVERAGE_THRESHOLD }} \ | |
| tests/unit/ tests/integration/ tests/e2e/ | tee pytest-coverage.txt | |
| echo "All tests completed with unified coverage" | |
| # Upload coverage to Codecov (requires GitHub OIDC) | |
| # Note: OIDC authentication requires GitHub Actions environment and won't work with act (local testing) | |
| # The step will fail gracefully due to fail_ci_if_error: false, allowing tests to pass in act | |
| - name: Upload Coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| # Explicitly specify the coverage XML file to upload (generated by pytest) | |
| files: coverage.xml | |
| # Custom upload name visible in Codecov UI | |
| name: tux | |
| # Don't fail CI if Codecov upload fails (coverage is optional, tests are required) | |
| fail_ci_if_error: false | |
| # Enable verbose logging for troubleshooting upload issues | |
| verbose: true | |
| # Use OIDC (OpenID Connect) for authentication instead of CODECOV_TOKEN | |
| # Requires id-token: write permission (configured in job permissions) | |
| use_oidc: true | |
| - name: Upload Coverage HTML Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html | |
| path: htmlcov | |
| retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} | |
| if-no-files-found: warn |