Merge pull request #5 from mathspace/remove-ramping #15
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: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| python-version: ["3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest pytest-cov coverage | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run tests with coverage | |
| run: | | |
| python -m pytest tests/ --cov=src/feafea --cov-report=xml --cov-report=html --cov-report=term-missing | |
| - name: Display coverage report | |
| run: | | |
| coverage report --show-missing | |
| - name: Generate coverage markdown report | |
| run: | | |
| # Generate coverage report | |
| echo "## π Test Coverage Report" > coverage_report.md | |
| echo "" >> coverage_report.md | |
| # Get coverage percentage | |
| COVERAGE=$(coverage report | grep TOTAL | grep -o '[0-9]\+\.[0-9]\+%' | sed 's/%//') | |
| # Add summary with emoji based on coverage | |
| if python3 -c "import sys; sys.exit(0 if float('$COVERAGE') >= 100 else 1)"; then | |
| echo "### β Coverage Status: **PASSED** π" >> coverage_report.md | |
| echo "**Current Coverage:** ${COVERAGE}% (Required: 100%)" >> coverage_report.md | |
| else | |
| echo "### β Coverage Status: **FAILED** π¨" >> coverage_report.md | |
| echo "**Current Coverage:** ${COVERAGE}% (Required: 100%)" >> coverage_report.md | |
| fi | |
| echo "" >> coverage_report.md | |
| echo "### π Detailed Coverage Report" >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| echo '```' >> coverage_report.md | |
| coverage report --show-missing >> coverage_report.md | |
| echo '```' >> coverage_report.md | |
| # Add missing coverage section if needed | |
| if ! python3 -c "import sys; sys.exit(0 if float('$COVERAGE') >= 100 else 1)"; then | |
| echo "" >> coverage_report.md | |
| echo "### π Lines Missing Coverage" >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| echo "The following lines need to be covered by tests:" >> coverage_report.md | |
| echo '```' >> coverage_report.md | |
| coverage report --show-missing | grep -E "^src/" | grep -v "100%" >> coverage_report.md 2>/dev/null || echo "No specific missing lines found" >> coverage_report.md | |
| echo '```' >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| echo "π‘ **Tip:** Run \`coverage html\` locally to see a detailed HTML report highlighting uncovered lines." >> coverage_report.md | |
| fi | |
| echo "" >> coverage_report.md | |
| echo "---" >> coverage_report.md | |
| echo "*Generated by GitHub Actions on $(date)*" >> coverage_report.md | |
| - name: Upload HTML coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-html | |
| path: htmlcov/ | |
| retention-days: 30 | |
| - name: Comment PR with coverage report | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-path: coverage_report.md | |
| edit-mode: replace | |
| - name: Check coverage requirement (100%) | |
| run: | | |
| coverage report --fail-under=100 | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff | |
| - name: Run Ruff | |
| run: ruff check . |