-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (48 loc) · 1.64 KB
/
test_python_script.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
54
55
56
57
# This action executes the Python test 'test_update_index.py' and outputs the test results whenever a change to the file 'update_index.py' in the 'scripts' folder is pushed to the repository.
name: Test Python Script for index update
on:
push:
paths:
- 'scripts/update_index.py'
pull_request:
paths:
- 'scripts/update_index.py'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
id: run_tests
run: |
python -m unittest discover -s tests -p '*.py'
continue-on-error: true
- name: Generate coverage report
run: |
pip install coverage
coverage run -m unittest discover -s tests -p '*.py'
coverage xml
coverage report
- name: Post test results as comment
if: always()
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('coverage.xml', 'utf8');
const comment = `## Test Results\n\n\`\`\`xml\n${results}\n\`\`\``;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});