feat: add folder metadata builder #14
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: Run tests | |
| on: | |
| push: | |
| branches: | |
| - "**" # All branches, including those with / | |
| pull_request: | |
| branches: [master] | |
| # Add permissions needed for GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Environment for GitHub Pages | |
| env: | |
| COVERAGE_REPORT_PATH: htmlcov | |
| jobs: | |
| CheckCoverage: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv sync --all-extras | |
| - name: Run tests with coverage | |
| run: | | |
| uv run pytest --cov=aldrovandi_provenance --cov-report=xml --cov-report=term | |
| echo "=== Coverage Report ===" | |
| uv run coverage report | |
| echo "COVERAGE=$(uv run coverage report | grep TOTAL | awk '{print $4}')" >> $GITHUB_ENV | |
| - name: Generate HTML coverage report | |
| run: uv run coverage html -d htmlcov | |
| # Configure GitHub Pages | |
| - name: Setup Pages | |
| if: matrix.python-version == '3.10' | |
| uses: actions/configure-pages@v5 | |
| # Upload coverage report as Pages artifact | |
| - name: Upload Pages artifact | |
| if: matrix.python-version == '3.10' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ${{ env.COVERAGE_REPORT_PATH }} | |
| - name: Generate coverage badge | |
| if: matrix.python-version == '3.10' | |
| run: | | |
| # Extract coverage percentage as a number | |
| COVERAGE_NUM=$(echo ${{ env.COVERAGE }} | sed 's/%//') | |
| # Determine color based on coverage | |
| if (( $(echo "$COVERAGE_NUM >= 90" | bc -l) )); then | |
| COLOR="green" | |
| elif (( $(echo "$COVERAGE_NUM >= 75" | bc -l) )); then | |
| COLOR="yellow" | |
| elif (( $(echo "$COVERAGE_NUM >= 60" | bc -l) )); then | |
| COLOR="orange" | |
| else | |
| COLOR="red" | |
| fi | |
| echo "BADGE_COLOR=$COLOR" >> $GITHUB_ENV | |
| - name: Create badge | |
| if: matrix.python-version == '3.10' | |
| uses: RubbaBoy/[email protected] | |
| with: | |
| name: dharc-org-aldrovandi-provenance-coverage-${{ github.ref_name }} | |
| label: "Coverage" | |
| status: "${{ env.COVERAGE }}" | |
| color: ${{ env.BADGE_COLOR }} | |
| github_token: ${{ secrets.GIST_PAT }} | |
| repository: arcangelo7/badges | |
| actor: arcangelo7 | |
| deploy-coverage: | |
| needs: CheckCoverage | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.repository }}/pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |