-
Notifications
You must be signed in to change notification settings - Fork 12
53 lines (43 loc) · 1.39 KB
/
python-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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,
});