Skip to content

Commit 45bd3da

Browse files
committed
CI combined workflow and pytest coverage workflow
1 parent f12bdc0 commit 45bd3da

5 files changed

Lines changed: 178 additions & 10 deletions

File tree

.github/workflows/build-check.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ on:
1111
type: string
1212
default: ${{ github.repository }}
1313

14+
python-versions:
15+
type: string
16+
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
17+
18+
fail-fast:
19+
type: boolean
20+
default: true
1421
jobs:
1522
build-check:
1623
runs-on: ubuntu-latest
1724

1825
strategy:
19-
fail-fast: false
26+
fail-fast: ${{ inputs.fail-fast }}
2027
matrix:
21-
python-version: ["3.9", "3.10", "3.11","3.12","3.13"]
28+
python-version: ${{ fromJSON(inputs.python-versions) }}
2229

23-
name: Check Build ${{ matrix.python-version }}
30+
name: Check Build (Python ${{ matrix.python-version }})
2431

2532
steps:
2633
- name: Checkout Repo
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Continuous Integration
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
src-path:
7+
type: string
8+
default: "./src"
9+
setup-path:
10+
type: string
11+
default: "."
12+
repository:
13+
type: string
14+
default: ${{ github.repository }}
15+
python-versions:
16+
type: string
17+
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
18+
fail-fast:
19+
type: boolean
20+
default: true
21+
package: # The import package name, not the pip install name
22+
type: string
23+
required: true
24+
requirements-file:
25+
type: string
26+
default: "requirements.txt"
27+
test-requirements-file:
28+
type: string
29+
default: "test-requirements.txt"
30+
runners: # If multiplatform tests aren't required, we can just do ubuntu
31+
type: string
32+
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
33+
34+
35+
36+
jobs:
37+
black:
38+
uses: ./.github/workflows/black.yml@main
39+
with:
40+
repository: ${{ inputs.repository }}
41+
path: ${{ inputs.src-path }}
42+
build-check:
43+
uses: ./.github/workflows/build-check.yml@main
44+
with:
45+
setup-path: ${{inputs.setup-path}}
46+
repository: ${{ inputs.repository }}
47+
python-versions: ${{ inputs.python-versions }}
48+
fail-fast: ${{ inputs.fail-fast }}
49+
mypy:
50+
uses: ./.github/workflows/mypy.yml@main
51+
with:
52+
setup-path: ${{inputs.setup-path}}
53+
repository: ${{ inputs.repository }}
54+
python-versions: ${{ inputs.python-versions }}
55+
fail-fast: ${{ inputs.fail-fast }}
56+
mypy-config: "pyproject.toml"
57+
package: ${{ inputs.package }}
58+
pylint:
59+
uses: ./.github/workflows/pylint.yml@main
60+
with:
61+
path: ${{inputs.src-path}}
62+
requirements-file: ${{inputs.requirements-file}}
63+
repository: ${{ github.repository }}
64+
python-versions: ${{inputs.python-versions}}
65+
fail-fast: ${{ inputs.fail-fast }}
66+
pytest-coverage:
67+
uses: ./.github/workflows/pytest-coverage.yml@main
68+
with:
69+
setup-path: ${{inputs.setup-path}}
70+
test-path: ""
71+
requirements-file: ${{inputs.test-requirements-file}}
72+
repository: ${{ github.repository }}
73+
python-versions: ${{inputs.python-versions}}
74+
fail-fast: ${{ inputs.fail-fast }}
75+
runners: ${{ inputs.runners }}

.github/workflows/mypy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ on:
1515
repository:
1616
type: string
1717
default: ${{ github.repository }}
18-
18+
python-versions:
19+
type: string
20+
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
21+
fail-fast:
22+
type: boolean
23+
default: true
1924

2025
jobs:
2126
mypy:
2227
runs-on: ubuntu-latest
2328

2429
strategy:
25-
fail-fast: false
30+
fail-fast: ${{ inputs.fail-fast }}
2631
matrix:
27-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
32+
python-version: ${{ fromJSON(inputs.python-versions) }}
2833

29-
name: MyPy ${{ matrix.python-version }}
34+
name: MyPy (Python ${{ matrix.python-version }})
3035

3136
steps:
3237
- name: Checkout Repo

.github/workflows/pylint.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@ on:
1313
repository:
1414
type: string
1515
default: ${{ github.repository }}
16+
python-versions:
17+
type: string
18+
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
19+
fail-fast:
20+
type: boolean
21+
default: true
1622

1723
jobs:
1824
pylint:
1925
runs-on: ubuntu-latest
2026

2127
strategy:
22-
fail-fast: false
28+
fail-fast: ${{ inputs.fail-fast }}
2329
matrix:
24-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
30+
python-version: ${{ fromJSON(inputs.python-versions) }}
2531

26-
name: Pylint ${{ matrix.python-version }}
32+
name: Pylint (Python ${{ matrix.python-version }})
2733

2834
steps:
2935
- name: Checkout Repo
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: PyTest with Coverage
2+
3+
on:
4+
workflow_call:
5+
6+
inputs:
7+
setup-path:
8+
type: string
9+
default: "."
10+
test-path:
11+
type: string
12+
default: ""
13+
requirements-file:
14+
type: string
15+
default: "test-requirements.txt"
16+
repository:
17+
type: string
18+
default: ${{ github.repository }}
19+
python-versions:
20+
type: string
21+
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
22+
runners:
23+
type: string
24+
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
25+
fail-fast:
26+
type: boolean
27+
default: true
28+
29+
jobs:
30+
pytest-coverage:
31+
runs-on: ${{ matrix.runner }}
32+
33+
strategy:
34+
fail-fast: ${{ inputs.fail-fast }}
35+
matrix:
36+
python-version: ${{ fromJSON(inputs.python-versions) }}
37+
runner: ${{ fromJSON(inputs.runners) }}
38+
39+
name: PyTest w/ Coverage (Python ${{ matrix.python-version }} [${{ matrix.runner }}])
40+
41+
steps:
42+
- name: Checkout Repo
43+
uses: actions/checkout@v4
44+
with:
45+
repository: ${{ inputs.repository }}
46+
47+
- name: Setup Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Upgrade Pip
53+
run: |
54+
python -m pip install --upgrade pip
55+
56+
- name: Install Tools (Wheel, Setuptools, Pytest, Coverage)
57+
run: |
58+
pip install wheel setuptools pytest coverage
59+
60+
- name: Install Testing Requirements
61+
if: ${{ hashFiles(inputs.requirements-file) != '' }}
62+
run: |
63+
pip install -r ${{ inputs.requirements-file }}
64+
65+
- name: Build & Install Repo
66+
run: |
67+
pip install ${{ inputs.setup-path }}
68+
69+
- name: Run PyTest
70+
run: |
71+
coverage run pytest -v ${{ inputs.test-path }} --color=yes
72+
73+
- name: Check Coverage
74+
run: |
75+
coverage report

0 commit comments

Comments
 (0)