Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions .github/workflows/coverage-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Tests, Coverage and GitHub Pages

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: write # Needed for badge commit
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
test-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install genbadge[coverage]

- name: Install PyTorch (CPU-only) for tests
run: |
pip install torch --index-url https://download.pytorch.org/whl/cpu

- name: Run tests with coverage
continue-on-error: true # Continue workflow even if tests fail
run: |
mkdir -p site
python -m pytest --cov=arraybridge \
--cov-report=xml \
--cov-report=html:site/coverage \
tests/

- name: Generate coverage badge
run: |
mkdir -p .github/badges
genbadge coverage -i coverage.xml -o .github/badges/coverage.svg -n "coverage"

- name: Create index.html and README
run: |
# Create index.html for redirection
cat > site/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=./coverage/">
<title>Redirecting to coverage report...</title>
</head>
<body>
<p>Redirecting to coverage report... <a href="./coverage/">Click here if not redirected</a></p>
</body>
</html>
EOF

# Create README.md in the site directory
echo "# arraybridge Code Coverage Reports" > site/README.md
echo "" >> site/README.md
echo "This site contains the code coverage reports for the [arraybridge](https://github.com/trissim/arraybridge) project." >> site/README.md
echo "" >> site/README.md
echo "## Navigation" >> site/README.md
echo "" >> site/README.md
echo "- [Coverage Report](./coverage/): View the HTML coverage report" >> site/README.md
echo "" >> site/README.md
echo "## About" >> site/README.md
echo "" >> site/README.md
echo "These reports are automatically generated by GitHub Actions whenever changes are pushed to the main branch." >> site/README.md
echo "They show the percentage of code that is covered by automated tests." >> site/README.md
echo "" >> site/README.md
echo "Last updated: $(date)" >> site/README.md

- name: Commit and push if coverage badge changed
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .github/badges/coverage.svg -f
git commit -m "chore: update coverage badge" || exit 0
git push

- name: Check GitHub Pages status
run: |
echo "⚠️ IMPORTANT: Make sure GitHub Pages is enabled in your repository settings!"
echo "Go to https://github.com/trissim/arraybridge/settings/pages"
echo "Set 'Source' to 'GitHub Actions' to enable GitHub Pages deployment."

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'site'
retention-days: 1

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
timeout-minutes: 10
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
**Unified API for NumPy, CuPy, PyTorch, TensorFlow, JAX, and pyclesperanto**

[![PyPI version](https://badge.fury.io/py/arraybridge.svg)](https://badge.fury.io/py/arraybridge)
[![Documentation Status](https://readthedocs.org/projects/arraybridge/badge/?version=latest)](https://arraybridge.readthedocs.io/en/latest/?badge=latest)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Coverage](https://raw.githubusercontent.com/trissim/arraybridge/main/.github/badges/coverage.svg)](https://trissim.github.io/arraybridge/coverage/)

## Features

Expand Down
64 changes: 64 additions & 0 deletions SETUP_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Setup Instructions for Badges and Documentation

This document contains the manual steps needed to complete the badge and documentation setup for arraybridge.

## 1. Enable GitHub Pages

To display the coverage reports hosted on GitHub Pages:

1. Go to: https://github.com/trissim/arraybridge/settings/pages
2. Under "Build and deployment" > "Source", select **"GitHub Actions"**
3. Save the changes

Once enabled, the coverage-pages.yml workflow will deploy coverage reports to https://trissim.github.io/arraybridge/coverage/

## 2. Update Repository Description

To add the ReadTheDocs link to the repository description:

1. Go to: https://github.com/trissim/arraybridge
2. Click the gear icon (⚙️) next to "About" on the right side
3. In the "Website" field, enter: `https://arraybridge.readthedocs.io`
4. Optionally add topics/tags to improve discoverability
5. Click "Save changes"

## 3. Verify ReadTheDocs Integration

Ensure ReadTheDocs is properly configured:

1. Go to: https://readthedocs.org/projects/arraybridge/
2. Verify that the project is active and building successfully
3. Check that the webhook is configured (Settings > Integrations)
4. The `.readthedocs.yml` file is already configured in the repository

## 4. Verify Codecov Integration

The existing CI workflow (`.github/workflows/ci.yml`) already uploads coverage to Codecov:

- Coverage is uploaded after tests run on ubuntu-latest with Python 3.12 and torch framework
- The coverage data is sent to Codecov using the `codecov/codecov-action@v3`
- No additional Codecov configuration is needed

## 5. Test the New Workflow

After merging this PR to main:

1. The `coverage-pages.yml` workflow will run automatically
2. It will:
- Run tests with coverage
- Generate a coverage badge and commit it to `.github/badges/coverage.svg`
- Deploy the HTML coverage report to GitHub Pages
3. The badges in README.md will then display live data

## Badge URLs

The following badges have been added to README.md:

- **ReadTheDocs**: `[![Documentation Status](https://readthedocs.org/projects/arraybridge/badge/?version=latest)](https://arraybridge.readthedocs.io/en/latest/?badge=latest)`
- **Coverage**: `[![Coverage](https://raw.githubusercontent.com/trissim/arraybridge/main/.github/badges/coverage.svg)](https://trissim.github.io/arraybridge/coverage/)`

## Notes

- The coverage badge will show 0% until the first successful run of the coverage-pages.yml workflow on the main branch
- The ReadTheDocs badge will show the build status (passing/failing) based on the latest documentation build
- Both workflows are set up similarly to the ezstitcher repository for consistency
Loading