Repository navigation
127 lines (120 loc) · 3.9 KB
/
Copy pathpython-package-reusable.yml
File metadata and controls
127 lines (120 loc) · 3.9 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Python package CI
on:
workflow_call:
inputs:
subproject:
description: Repository-relative package directory
required: true
type: string
source-path:
description: Package source path relative to the subproject
required: true
type: string
conda-dependencies:
description: Space-separated additional conda package specifications
default: biomass-bps::arepyextras-runner
type: string
local-dependencies:
description: Space-separated editable dependency paths relative to the subproject
default: ""
type: string
run-tests:
description: Run the Linux unit tests
default: true
type: boolean
permissions:
contents: read
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: python -m pip install ruff==0.17.4
- name: Check formatting and lint
working-directory: ${{ inputs.subproject }}
run: |
python -m ruff format --check .
python -m ruff check .
pyrefly:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/install-subpackage
with:
subproject: ${{ inputs.subproject }}
conda-dependencies: ${{ inputs.conda-dependencies }}
local-dependencies: ${{ inputs.local-dependencies }}
package-extras: dev
- name: Check types
working-directory: ${{ inputs.subproject }}
run: python -m pyrefly check
fawlty-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: python -m pip install FawltyDeps
- name: Check dependencies
working-directory: ${{ inputs.subproject }}
run: python -m fawltydeps --code bps --detailed --config-file ../fawltydeps.toml
unittest-linux:
if: inputs.run-tests
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/install-subpackage
with:
subproject: ${{ inputs.subproject }}
conda-dependencies: ${{ inputs.conda-dependencies }}
local-dependencies: ${{ inputs.local-dependencies }}
package-extras: test
- name: Run tests with coverage
working-directory: ${{ inputs.subproject }}
env:
SOURCE_PATH: ${{ inputs.source-path }}
run: |
set -eo pipefail
mkdir -p _build
python -m coverage run "--source=$SOURCE_PATH" -m xmlrunner --output-file _build/unittest-report-linux-py3.14.xml discover
python -m coverage report -m
python -m coverage xml -o _build/unittest-coverage-linux-py3.14.xml
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.subproject }}-test-reports
path: |
${{ inputs.subproject }}/_build/unittest-report-*.xml
${{ inputs.subproject }}/_build/unittest-coverage-*.xml
if-no-files-found: ignore
retention-days: 14
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: python -m pip install build
- name: Build distributions
working-directory: ${{ inputs.subproject }}
run: python -m build
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.subproject }}-distributions
path: |
${{ inputs.subproject }}/dist/*.tar.gz
${{ inputs.subproject }}/dist/*.whl
if-no-files-found: error
retention-days: 14