feat: improve Application Insights logging and telemetry handling #956
Workflow file for this run
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: Test Workflow with Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - demo-v4 | |
| - dev-v4 | |
| paths: | |
| - 'src/backend/**/*.py' | |
| - 'src/tests/**/*.py' | |
| - 'src/mcp_server/**/*.py' | |
| - 'src/**/pyproject.toml' | |
| - 'pytest.ini' | |
| - 'conftest.py' | |
| - 'src/backend/requirements.txt' | |
| - '.github/workflows/test.yml' | |
| pull_request: | |
| types: | |
| - opened | |
| - ready_for_review | |
| - reopened | |
| - synchronize | |
| branches: | |
| - main | |
| - demo-v4 | |
| - dev-v4 | |
| paths: | |
| - 'src/backend/**/*.py' | |
| - 'src/tests/**/*.py' | |
| - 'src/mcp_server/**/*.py' | |
| - 'pytest.ini' | |
| - 'conftest.py' | |
| - 'src/backend/requirements.txt' | |
| - 'src/**/pyproject.toml' | |
| - '.github/workflows/test.yml' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r src/backend/requirements.txt | |
| - name: Check if test files exist | |
| id: check_tests | |
| run: | | |
| if [ -z "$(find src -type f -name 'test_*.py')" ]; then | |
| echo "No test files found, skipping tests." | |
| echo "skip_tests=true" >> $GITHUB_ENV | |
| else | |
| echo "Test files found, running tests." | |
| echo "skip_tests=false" >> $GITHUB_ENV | |
| fi | |
| - name: Run tests with coverage | |
| if: env.skip_tests == 'false' | |
| run: | | |
| if python -m pytest src/tests/backend/test_app.py --cov=backend --cov-config=.coveragerc -q > /dev/null 2>&1 && \ | |
| python -m pytest src/tests/backend --cov=backend --cov-append --cov-report=term --cov-report=xml --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py; then | |
| echo "Tests completed, checking coverage." | |
| if [ -f coverage.xml ]; then | |
| COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(float(root.attrib.get('line-rate', 0)) * 100)") | |
| echo "Overall coverage: $COVERAGE%" | |
| if (( $(echo "$COVERAGE < 80" | bc -l) )); then | |
| echo "Coverage is below 80%, failing the job." | |
| exit 1 | |
| fi | |
| fi | |
| else | |
| echo "No tests found, skipping coverage check." | |
| fi | |
| - name: Skip coverage report if no tests | |
| if: env.skip_tests == 'true' | |
| run: | | |
| echo "Skipping coverage report because no tests were found." |