-
Notifications
You must be signed in to change notification settings - Fork 5
119 lines (107 loc) · 3.37 KB
/
Copy pathpython-build.yml
File metadata and controls
119 lines (107 loc) · 3.37 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
name: Python Build Workflow
on:
workflow_call:
inputs:
install:
description: 'Install dependencies'
type: string
default: 'true'
build:
description: 'Build the project'
type: string
default: 'false'
test:
description: 'Run tests'
type: string
default: 'false'
lint:
description: 'Run linters'
type: string
default: 'false'
cooldown-days:
description: 'Number of days to use as the dependency cooldown window (excludes packages newer than N days)'
type: number
default: 3
jobs:
build:
# This workflow runs on the latest version of Ubuntu
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.python-version }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
# Python versions to test against
# These are all the main versions of Python that are currently supported
# excluding 3.8
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: ${{ github.event.inputs.install == 'true' }}
env:
COOLDOWN_DAYS: ${{ inputs.cooldown-days }}
run: |
set -e
if [[ -f Pipfile ]]; then
python -m pip install --upgrade pip pipenv
pipenv sync -d
elif [[ -f requirements.txt ]]; then
python -m pip install "uv==0.11.16"
uv pip sync requirements.txt --require-hashes --exclude-newer "$(date -u -d "$COOLDOWN_DAYS days ago" +%Y-%m-%dT%H:%M:%SZ)"
elif [[ -f Makefile ]]; then
make install
else
echo "No requirements or Pipfile found"
exit 1
fi
- name: Run Build / Compile
if: ${{ github.event.inputs.build == 'true' }}
run: |
set -e
if [[ -f Pipfile ]]; then
pipenv run build
elif [[ -f setup.py ]]; then
python setup.py build
elif [[ -f Makefile ]]; then
make build
else
echo "No build script found"
echo "Skipping build step"
fi
- name: Run Linters
if: ${{ github.event.inputs.lint == 'true' }}
run: |
set -e
export PYTHONPATH=$PWD/src
if [[ -f Pipfile ]]; then
pipenv run lint
elif [[ -f setup.py ]]; then
python setup.py lint
elif [[ -f Makefile ]]; then
make lint
else
echo "No lint script found"
echo "Skipping lint step"
fi
- name: Run Tests
if: ${{ github.event.inputs.test == 'true' }}
run: |
set -e
export PYTHONPATH=$PWD/src
if [[ -f Pipfile ]]; then
pipenv run tests
elif [[ -f setup.py ]]; then
python setup.py tests
elif [[ -f Makefile ]]; then
make tests
else
echo "No test script found"
echo "Skipping test step"
fi