-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (78 loc) · 3.27 KB
/
ci-workflow-pytest.yaml
File metadata and controls
83 lines (78 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
name: CI using tox
# A reusable github workflow to run python CI workflows, including static code
# checks, automated testing (using pytest or tox), package building,
# publishing to test.pypi.org and pypi.org, and creating a GitHub release.
#
# The workflow elements to selected are specified in the `jobs` input. The
# default is to run the `test-tox` and `build` jobs. The CI workflow is
# configured in the tox-gh config (eg. pyproject.toml). See
# https://github.com/tox-dev/tox-gh.
#
# Accepts the following inputs:
# - `jobs`: A json string containing the list of jobs to run. Default is
# `["test-tox", "build"]`. The available jobs are:
# - `code-check`: Run static code checks (using `mypy`, `ruff`, etc.).
# - `test-pytest`: Run tests using `pytest`.
# - `test-tox`: Run tests and code checks using `tox` (alias "test").
# - `build`: Build the python package.
# - `publish-test`: Publish the package to test.pypi.org.
# - `publish`: Publish the package to pypi.org.
# - `release`: Create a GitHub release.
# - `os`: A json string containing the list of operating systems on which to
# run tests. Default is `["ubuntu-latest", "windows-latest",
# "macos-latest"]`.
# - `python-version`: A json string containing the list of python versions on
# which to run tests. Default is `["3.9", "3.10", "3.11", "3.12", "3.13"]`.
#
# Assumes the configurations for all tools (`mypy`, `uv`, `ruff`, `pytest`,
# ...) are fully specified in config files (eg `pyproject.toml`).
#
# You should select either `test-tox` or `code-check`+`test-pytest`, but not
# both.
#
# It is recommended to use the `test-tox` job, as it includes the code checks,
# and can be more easily customised in yourq pyproject.toml so that the same CI
# process runs on your local computer and on github.
#
# All workflows use astral `uv` to execute actions wherever possible.
on:
workflow_call:
inputs:
jobs:
description: >-
A json string containing the list of jobs to run. Default is
`["tests", "build"]`.
default: '["test-tox", "build"]'
type: string
required: false
os:
description: >-
A json string containing the list of operating systems on which to
run the test matrix.
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
type: string
required: false
python-version:
description: >-
A json string containing the list of python versions on
which to run the test matrix.
default: '["3.9", "3.10", "3.11", "3.12", "3.13"]'
type: string
required: false
# Trusted publishing to pypi.org can not be done from a reusable workflow
# so publish workflows must be run from the main workflow file.
jobs:
check:
if: ${{ contains(fromJson(inputs.jobs), 'check') }}
name: Run static code checks
uses: ./.github/workflows/code-check.yaml
test:
if: ${{ contains(fromJson(inputs.jobs), 'test') }}
name: Run tests using pytest
uses: ./.github/workflows/test-pytest.yaml
with:
os: ${{ inputs.os }}
python-version: ${{ inputs.python-version }}
build: # Always build the package in this workflow
name: Build python package
uses: ./.github/workflows/build.yaml