Repository navigation
57 lines (57 loc) · 1.63 KB
/
Copy pathpython-test.yml
File metadata and controls
57 lines (57 loc) · 1.63 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
name: Python test (reusable)
on:
workflow_call:
inputs:
python-versions:
description: 'JSON array of Python versions to test against'
required: false
type: string
default: '["3.10", "3.11", "3.12"]'
working-directory:
description: 'Path to the package'
required: false
type: string
default: '.'
run-mypy:
description: 'Run mypy after pytest'
required: false
type: boolean
default: true
run-ruff:
description: 'Run ruff before tests'
required: false
type: boolean
default: true
jobs:
test:
runs-on: ubuntu-latest
# Reusable workflows inherit the caller's GITHUB_TOKEN permissions when
# `permissions:` is omitted, which can be `write-all` on legacy repos.
# A test job only needs to read code — narrow per-job to prevent a
# malicious dependency from abusing the token at install/test time.
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python: ${{ fromJson(inputs.python-versions) }}
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install
run: pip install -e ".[dev]"
- name: Ruff
if: inputs.run-ruff
run: ruff check .
- name: Mypy
if: inputs.run-mypy
run: mypy src
- name: Pytest
run: pytest -q