Skip to content

Adopt and execute pre-commit #8

Adopt and execute pre-commit

Adopt and execute pre-commit #8

# This workflow runs on pull requests and nightly
name: pull_request_CPU_py3.11
on:
# Run tests for every pull request targeting main
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
jobs:
run_tests:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
python-version: "3.11"
- name: Install BIHC
run: |
pip install -e .
pip install pytest pytest-cov
- name: Print installed packages
run: conda list
- name: Run pytest (with coverage)
run: |
python -m pytest --cov=bihc --cov-report=term-missing -vv
- name: Generate coverage summary
run: |
coverage report > coverage.txt
- name: Comment coverage on PR (update if exists)
if: github.event.pull_request.head.repo.fork == false
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- bihc-coverage-comment -->';
const report = fs.readFileSync('coverage.txt', 'utf8');
const body =
`${marker}\n` +
`## 🧪 Coverage Report\n\n` +
`\`\`\`\n${report}\n\`\`\`\n` +
`*Updated: ${new Date().toISOString()}*`;
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find(c => (c.body || '').includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}