-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (73 loc) · 2.34 KB
/
python-unit-test.yaml
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
---
name: Python Checks
'on':
workflow_call:
inputs:
additional_packages:
default: ''
description: String of additional packages that should be installed.
required: false
type: string
jobs_run_on:
default: ubuntu-latest
description: The runner group on which jobs will run.
required: false
type: string
# python_versions:
# default: ['3.7', '3.8', '3.9', '3.10', '3.11']
# description: The versions of Python on which the unit tests should run.
# required: false
# type: string
python_package_name:
default: ''
description: The name of the PyPi package the repo will create.
required: false
type: string
timeout_minutes:
description: The maximum time (in minutes) for a job to run.
default: 5
required: false
type: number
working_directory:
description: The working directory where all jobs should be executed.
default: '.'
required: false
type: string
jobs:
unit-tests:
defaults:
run:
working-directory: ${{ inputs.working_directory }}
runs-on: ${{ inputs.jobs_run_on }}
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- name: Install additional packages
if: ${{ inputs.additional_packages != '' }}
run: sudo apt-get install -y ${{ inputs.additional_packages }}
- name: Checkout repo
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
cache: poetry
python-version: "${{ matrix.python-version }}"
- name: Configure Poetry
run: poetry config virtualenvs.in-project true
- name: Check pyproject.toml
run: poetry check
- name: Install dependencies
run: poetry install
- name: Test with green
run: |
poetry run green tests
poetry run coverage xml
- name: Run a test module build and install
if: ${{ inputs.python_package_name != '' }}
run: |
poetry build
pip install dist/${{ inputs.python_package_name }}-*.tar.gz
timeout-minutes: ${{ inputs.timeout_minutes }}