Skip to content

Commit c59c1d9

Browse files
author
Ljzd-PRO
committed
ci: add coverage test
1 parent 07bd67c commit c59c1d9

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Setup Python
2+
description: Setup Python
3+
4+
inputs:
5+
python-version:
6+
description: Python version
7+
required: false
8+
default: "3.10"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Install poetry
14+
run: pipx install poetry
15+
shell: bash
16+
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
architecture: "x64"
21+
cache: "poetry"
22+
23+
- run: poetry install --with test
24+
shell: bash

.github/workflows/codecov.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Code Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
paths:
9+
- "ktoolbox/**"
10+
- "tests/**"
11+
- ".github/actions/setup-python/**"
12+
- ".github/workflows/codecov.yml"
13+
- "pyproject.toml"
14+
- "prod.env"
15+
16+
jobs:
17+
test:
18+
name: Test Coverage
19+
runs-on: ${{ matrix.os }}
20+
concurrency:
21+
group: test-coverage-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}
22+
cancel-in-progress: true
23+
strategy:
24+
matrix:
25+
python-version: ["3.8", "3.9", "3.10", "3.11"]
26+
os: [ubuntu-latest, windows-latest, macos-latest]
27+
fail-fast: false
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Setup Python environment
33+
uses: ./.github/actions/setup-python
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Run Pytest
38+
run: |
39+
cd tests/
40+
pytest -v --capture=sys --cov --cov-report=xml --html=report-${{ matrix.python-version }}.html --self-contained-html
41+
42+
- name: Upload coverage report
43+
uses: codecov/codecov-action@v3
44+
env:
45+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
46+
with:
47+
files: ./tests/coverage.xml

tests/.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
branch = True
3+
source = ../ktoolbox

0 commit comments

Comments
 (0)