-
-
Notifications
You must be signed in to change notification settings - Fork 234
137 lines (121 loc) · 5.08 KB
/
build_and_deploy.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
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
128
129
130
131
132
133
134
135
136
137
name: Mac and Windows Builds
on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:
branches:
- '*'
# Cancel older runs of the same workflow on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
strategy:
matrix:
python3-minor-version: [9, 10, 11, 12]
# TODO: Figure out macos-14/macos-latest
os: [macos-13, ubuntu-latest, windows-latest]
defaults:
run:
shell: bash
env:
PYTHON_VERSION: ${{ format('3.{0}', matrix.python3-minor-version) }}
PYTHON_EXECUTABLE: ${{ format('cp3{0}', matrix.python3-minor-version) }}
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.python3-minor-version == 12 && 'local' || 'stdlib' }}
runs-on: ${{ matrix.os }}
name: Build and Deploy (${{ matrix.os }}, 3.${{ matrix.python3-minor-version }})
steps:
- name: Checkout
uses: actions/checkout@v3
# Python interpreter used by cibuildwheel, but it uses a different one internally
- name: Setting up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
# We build the source archive separately because of this: https://github.com/alkaline-ml/pmdarima/pull/136#discussion_r279781731
# We build it first because of this: https://github.com/alkaline-ml/pmdarima/issues/448
- name: Building source distribution
run: make version sdist
- name: Install cibuildwheel
run: python -m pip install 'cibuildwheel<2.20.0'
- name: Building and testing wheels
run: python -m cibuildwheel --output-dir dist
env:
# TODO: Move Linux x86_64 builds to GHA?
CIBW_ARCHS_LINUX: "aarch64"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_BEFORE_ALL: make version
CIBW_BEFORE_BUILD: >
pip install -r build_tools/build_requirements.txt &&
pip install -r requirements.txt
# Tests are run in a separate virtual env, so we need to re-install deps
CIBW_BEFORE_TEST: >
pip install -r build_tools/build_requirements.txt &&
pip install -r requirements.txt
CIBW_BUILD: "${{ env.PYTHON_EXECUTABLE }}-*"
CIBW_ENVIRONMENT: CC=gcc SETUPTOOLS_USE_DISTUTILS=${{ env.SETUPTOOLS_USE_DISTUTILS }}
CIBW_ENVIRONMENT_MACOS: PMD_MPL_BACKEND=TkAgg PYTHON_CROSSENV=true SETUPTOOLS_USE_DISTUTILS=${{ env.SETUPTOOLS_USE_DISTUTILS }}
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_REF
# No support for pypy or musl
CIBW_SKIP: "pp* *-musllinux_*"
# Runs tests and checks for a numpy regression by upgrading numpy and running tests again
CIBW_TEST_COMMAND: >
pytest --showlocals --durations=20 --pyargs pmdarima
# TODO: Add these back
# pip install --upgrade scipy numpy &&
# pytest --showlocals --durations=20 --pyargs pmdarima
# Avoid testing on emulated architectures
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} *-macosx_arm64"
- name: Checking README compatibility
run: |
python -m pip install "twine>=1.13.0" readme_renderer
if python -c "from twine.commands.check import check; check(['dist/*'])" | grep "warning"; then
echo "README will not render properly on PyPI"
exit 1
else
echo "README rendered appropriately"
fi
# See https://github.com/alkaline-ml/pmdarima/issues/448
- name: Ensuring sdist SOURCES.txt has no absolute paths
run: |
cd dist
tar xzf $(find . -name "*.tar.gz")
OUTPUT_DIRECTORY=$(find . -type d -name "pmdarima-*")
if grep -q "^/" ${OUTPUT_DIRECTORY}/pmdarima.egg-info/SOURCES.txt; then
echo "SOURCES.txt contains absolute paths in sdist"
exit 1
else
echo "SOURCES.txt looks good"
rm -rf "$OUTPUT_DIRECTORY"
fi
- name: Ensuring sdist can be installed
run: pip install dist/$(ls dist | grep tar)
- name: Ensuring VERSION file exists
id: version_check # Need this to refer to output below
run: |
if [ -f "${GITHUB_WORKSPACE}/pmdarima/VERSION" ]; then
echo "VERSION file exists"
echo "version_exists=true" >> $GITHUB_OUTPUT
else
echo "VERSION file does not exist"
echo "version_exists=false" >> $GITHUB_OUTPUT
fi
- name: Deploying to PyPI
# Only deploy on tags and when VERSION file created
if: startsWith(github.ref, 'refs/tags') && success() && steps.version_check.outputs.version_exists == 'true'
run: |
chmod +x build_tools/github/deploy.sh
./build_tools/github/deploy.sh
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}