-
Notifications
You must be signed in to change notification settings - Fork 13
56 lines (47 loc) · 1.65 KB
/
pythonpackage.yaml
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
name: Python package
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.12.5]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: |
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
pip install -r requirements.test.txt
- name: Run pytest and generate coverage report
run: |
source venv/bin/activate
pytest --asyncio-mode=auto --cov=custom_components/catlink --cov-report=term > coverage.txt
- name: Upload coverage as an artifact (optional)
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: coverage.txt
- name: Comment on PR with coverage report
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const coverageReport = fs.readFileSync('coverage.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### Coverage Report\n\`\`\`\n${coverageReport}\n\`\`\``
});