Align model_matrix input errors and docs
#323
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: Coverage | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[dev] | |
| - name: Run tests with coverage | |
| run: | | |
| python -m pytest --cov=balance --cov-report=xml --cov-report=html --cov-report=term-missing | |
| - name: Upload coverage reports to artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| - name: Upload coverage XML | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-xml | |
| path: coverage.xml | |
| - name: Display coverage percentage | |
| run: | | |
| coverage report --precision=2 | |
| - name: Update coverage badge | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| env: | |
| GIST_TOKEN: ${{ secrets.GIST_TOKEN_COVERAGE }} | |
| run: | | |
| COVERAGE=$(coverage report --precision=2 | grep TOTAL | awk '{print $NF}' | sed 's/%//') | |
| echo "Coverage: $COVERAGE%" | |
| # Determine badge color based on coverage (finer gradient) | |
| if (( $(echo "$COVERAGE == 100" | bc -l) )); then | |
| COLOR="brightgreen" | |
| elif (( $(echo "$COVERAGE >= 97" | bc -l) )); then | |
| COLOR="green" | |
| elif (( $(echo "$COVERAGE >= 95" | bc -l) )); then | |
| COLOR="yellowgreen" | |
| elif (( $(echo "$COVERAGE >= 90" | bc -l) )); then | |
| COLOR="yellow" | |
| elif (( $(echo "$COVERAGE >= 80" | bc -l) )); then | |
| COLOR="orange" | |
| else | |
| COLOR="red" | |
| fi | |
| # Create badge JSON content as a string (escape quotes for nested JSON) | |
| BADGE_CONTENT="{\\\"schemaVersion\\\": 1, \\\"label\\\": \\\"coverage\\\", \\\"message\\\": \\\"${COVERAGE}%\\\", \\\"color\\\": \\\"${COLOR}\\\"}" | |
| # Update the Gist (content must be a JSON-escaped string) | |
| curl -s -X PATCH \ | |
| -H "Authorization: token $GIST_TOKEN" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/gists/89d05034d314ebda47c1e16607e1ee22 \ | |
| -d "{\"files\": {\"coverage-balance.json\": {\"content\": \"$BADGE_CONTENT\"}}}" | head -20 | |
| echo "" | |
| echo "Badge updated successfully!" |