Skip to content

bump version to 0.2.3 #17

bump version to 0.2.3

bump version to 0.2.3 #17

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