-
Notifications
You must be signed in to change notification settings - Fork 3
86 lines (78 loc) · 2.92 KB
/
python-install-lint-test.yml
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
name: Reusable CI python install and test workflow
on:
workflow_call:
inputs:
os:
description: "Operating system to run this workflow on. Should match a valid Github runner name"
required: true
type: string
py3version:
description: "Minor version of Python version 3 to run the test on (e.g. `11` for python v3.11)"
required: true
type: string
mamba_env_name:
description: "Name of the Mamba environment. If it matches a name of a cached environment in the caller repository, that cache will be used."
required: false
default: ""
type: string
additional_mamba_args:
description: "Any additional arguments to pass to micromamba when creating the python environment"
required: false
default: ""
type: string
cache_mamba_env:
description: "If true, cache the mamba environment for speedier CI"
required: false
default: true
type: boolean
notebook_kernel:
description: "If jupyter notebooks are included in the docs, specify the kernel name they expect, e.g. the package name"
required: false
type: string
lint:
description: "If true, check code quality with the Ruff linter"
required: false
default: true
type: boolean
pytest_args:
description: "Additional arguments to pass to pytest"
required: false
type: string
default: ""
upload_to_codecov:
description: "If true, upload coverage report to codecov. This assumes your repository is public as it does not expect an API key."
required: false
default: true
type: boolean
defaults:
run:
shell: bash -l {0}
jobs:
test:
runs-on: ${{ inputs.os }}
steps:
- name: Use supplied Mamba environment name
if: inputs.mamba_env_name != ''
run: echo "MAMBAENVNAME=${{ inputs.mamba_env_name }}" >> $GITHUB_ENV
- name: Create Mamba environment name based on OS and python version
if: inputs.mamba_env_name == ''
run: echo "MAMBAENVNAME=${{ inputs.os }}-3${{ inputs.py3version }}" >> $GITHUB_ENV
- uses: arup-group/actions-city-modelling-lab/.github/actions/create-mamba-env@main
with:
py3version: ${{ inputs.py3version }}
env_name: ${{ env.MAMBAENVNAME }}
additional_mamba_args: ${{ inputs.additional_mamba_args }}
cache_mamba_env: "${{ inputs.cache_mamba_env }}"
- name: Install jupyter kernel
if: inputs.notebook_kernel != ''
run: python -m ipykernel install --user --name ${{ inputs.notebook_kernel }}
- name: Lint with Ruff
if: inputs.lint
run: ruff check .
- name: run tests
run: pytest ${{ inputs.pytest_args }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: inputs.upload_to_codecov
env:
directory: "./reports/coverage/"