Skip to content

Add unit test and update some modules #9

Add unit test and update some modules

Add unit test and update some modules #9

Workflow file for this run

name: Python Tests
on:
pull_request:
branches:
- '**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
- name: Run tests
run: |
pytest giga_cherche --cov=giga_cherche --cov-report=html
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov
- name: Post coverage comment
if: success()
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const coverage = fs.readFileSync('coverage.xml', 'utf8');
const totalCoverage = parseFloat(coverage.match(/line-rate="([\d.]+)"/)[1]) * 100;
const commentBody = `### Coverage Report\n\n- Total coverage: ${totalCoverage.toFixed(2)}%`;
const context = github.context;
const issue_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
...context.repo,
issue_number,
body: commentBody,
});