-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (91 loc) · 3.27 KB
/
python-test-and-coverage.yml
File metadata and controls
106 lines (91 loc) · 3.27 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI # lint + test matrix
on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
workflow_dispatch: # manual runs from the Actions tab
workflow_call: # reusable workflow (used by release/publish pipeline)
inputs:
generate_badges:
description: Generate and upload badge SVGs as an artifact
type: boolean
required: false
default: false
permissions:
contents: read # checkout only
concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # one run per ref (PR branch / main)
cancel-in-progress: true
jobs:
lint: # fast failure for syntax/undefined names
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml # pip cache key
- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --max-line-length=79 --show-source --statistics
tests: # full unit/integration tests
name: Tests (Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # , macos-latest, windows-latest]
# When requested, run a single version to generate coverage+badges once.
python-version: ${{ fromJSON(inputs.generate_badges && '["3.11"]' || '["3.10","3.11","3.12","3.13"]') }}
# exclude:
# - os: windows-latest
# python-version: "3.13" # ray >= 2.6.0 not found
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml # pip cache key
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e . # install the package under test
python -m pip install pytest
- name: Install badge tooling
if: ${{ inputs.generate_badges && matrix.python-version == '3.11' }}
run: |
python -m pip install coverage==7.4.4 coverage-badge interrogate[png] cairosvg
- name: Run tests (coverage)
if: ${{ inputs.generate_badges && matrix.python-version == '3.11' }}
run: |
mkdir -p .badges
coverage run -m pytest -q
coverage report -m
coverage-badge -o .badges/coverage_badge.svg -f
- name: Interrogate badge
if: ${{ inputs.generate_badges && matrix.python-version == '3.11' }}
run: |
interrogate --generate-badge .badges mlwiz
- name: Upload badges
if: ${{ inputs.generate_badges && matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v7
with:
name: badges
path: .badges/*.svg
include-hidden-files: true
if-no-files-found: error
- name: Run tests
if: ${{ !(inputs.generate_badges && matrix.python-version == '3.11') }}
run: |
pytest -q