Add unit test and update some modules #14
Workflow file for this run
This file contains 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: 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 --cov-report=xml | |
- 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, getOctokit } = require('@actions/github'); | |
const issue_number = context.payload.pull_request.number; | |
await getOctokit(process.env.GITHUB_TOKEN).rest.issues.createComment({ | |
...context.repo, | |
issue_number, | |
body: commentBody, | |
}); |