-
-
Notifications
You must be signed in to change notification settings - Fork 14
278 lines (241 loc) · 9.77 KB
/
main.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: "Build and unit tests"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
pull_request:
paths:
- "**"
# - "**.py"
# - "**.pxd"
# - "**.pyx"
push:
branches: [main]
paths:
- "**.py"
tags:
- "v*.*.*"
workflow_dispatch:
env:
INSTALLDIR: "build-install"
CCACHE_DIR: "${{ github.workspace }}/.ccache"
jobs:
build_and_test:
name: Meson build ${{ matrix.os }} - py${{ matrix.python-version }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest]
python-version: [3.9, "3.10", "3.11"]
poetry-version: [1.5.0]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
# to make sure coverage/test command builds cleanly
FORCE_SUBMODULE: True
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
cache: "pip"
cache-dependency-path: "requirements.txt"
- name: show-gcc
run: |
gcc --version
- name: Install Ccache for MacOSX
if: ${{ matrix.os == 'macos-latest'}}
run: |
brew install ccache
- name: Install packages for Ubuntu
if: ${{ matrix.os == 'ubuntu-22.04'}}
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libsuitesparse-dev ccache libmpc-dev
- name: Install Python packages
run: |
python -m pip install -r build_requirements.txt
python -m pip install spin
python -m pip install -r test_requirements.txt
- name: Prepare compiler cache
id: prep-ccache
shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: Setup compiler cache
uses: actions/cache@v3
id: cache-ccachev1
# Reference: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
# NOTE: The caching strategy is modeled in a way that it will always have a unique cache key for each workflow run
# (even if the same workflow is run multiple times). The restore keys are not unique and for a partial match, they will
# return the most recently created cache entry, according to the GitHub Action Docs.
with:
path: ${{ steps.prep-ccache.outputs.dir }}
# Restores ccache from either a previous build on this branch or on main
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-${{ steps.prep-ccache.outputs.timestamp }}
# This evaluates to `Linux Tests-3.9-ccache-linux-` which is not unique. As the CI matrix is expanded, this will
# need to be updated to be unique so that the cache is not restored from a different job altogether.
restore-keys: |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-linux-
- name: Setup build and install scikit-tree
run: |
./spin build -j 2 --forcesubmodule
- name: Ccache performance
shell: bash -l {0}
run: ccache -s
- name: build-path
run: |
echo "$PWD/build-install/"
export INSTALLED_PATH=$PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages
- name: Run unit tests and coverage
run: |
./spin --help
./spin coverage --help
./spin test --help
./spin coverage
cp $PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages/coverage.xml ./coverage.xml
- name: debug
run: |
ls $PWD/build-install/usr/lib/python${{matrix.python-version}}/site-packages/
echo "Okay..."
ls $PWD/build
ls ./
- name: Upload coverage stats to codecov
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10'}}
uses: codecov/codecov-action@v3
with:
# python spin goes into the INSTALLED path in order to run pytest
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Save build
uses: actions/upload-artifact@v3
with:
name: sktree-build
path: $PWD/build
# release is ran when a release is made on Github
release:
name: Release
runs-on: ubuntu-latest
needs: [build_and_test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: 3.9
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off build twine
- name: Prepare environment
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download package distribution files
uses: actions/download-artifact@v3
with:
name: package
path: dist
# TODO: refactor scripts to generate release notes from `whats_new.rst` file instead
# - name: Generate release notes
# run: |
# python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
- name: Publish package to PyPI
run: |
twine upload -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} dist/*
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*
# build-windows:
# name: Meson build Windows
# runs-on: windows-2019
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# submodules: recursive
# - name: Setup Python
# uses: actions/[email protected]
# with:
# python-version: "3.10"
# architecture: "x64"
# cache: "pip"
# cache-dependency-path: "requirements.txt"
# - name: install-rtools
# run: |
# choco install rtools -y --no-progress --force --version=4.0.0.20220206
# echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
# - name: show-gcc
# run: |
# gcc --version
# - name: Install system dependencies
# run: |
# # Download and install Miniconda
# Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe
# Start-Process -Wait -FilePath miniconda.exe -ArgumentList '/S', '/AddToPath=1'
# # Add Miniconda to the PATH
# $env:Path += ";C:\Users\runneradmin\Miniconda3\Scripts;C:\Users\runneradmin\Miniconda3"
# # Update conda
# conda update -y conda
# # Add conda-forge channel and install openblas
# conda config --add channels conda-forge
# conda install -y openblas
# - name: pip-packages
# run: |
# pip install -r build_requirements.txt
# pip install -r test_requirements.txt
# pip install spin
# pip install numpy==1.22.4
# # - name: Download cibw_before_build_win.sh for openblas-libs
# # shell: bash
# # run: |
# # # mkdir tools
# # # mkdir tools/wheels
# # # curl -L https://raw.githubusercontent.com/scipy/scipy/main/tools/wheels/cibw_before_build_win.sh -o cibw_before_build_win.sh
# # # curl -L https://raw.githubusercontent.com/scipy/scipy/main/tools/openblas_support.py -o tools/openblas_support.py
# # # curl -L https://raw.githubusercontent.com/scipy/scipy/main/tools/wheels/LICENSE_win32.txt -o tools/wheels/LICENSE_win32.txt
# # - name: Run cibw_before_build_win.sh for openblas-libs
# # shell: bash
# # run: |
# # set -xe
# # ls
# # bash ./tools/setup_windows.sh
# # - name: Set PKG_CONFIG_PATH for openblas-libs
# # run: echo "PKG_CONFIG_PATH=c:\opt\64\lib\pkgconfig;" >> $GITHUB_ENV
# # - name: Install system dependencies like openblas
# # run: |
# # choco install openblas -y
# - name: Build
# run: |
# echo "SCIPY_USE_PROPACK=1" >> $env:GITHUB_ENV
# echo "FORCE_SUBMODULE=True" >> $env:GITHUB_ENV
# python spin setup_submodule --forcesubmodule
# python spin build -j 2
# # Necessary because GitHub Actions checks out the repo to D:\ while OpenBLAS
# # got installed to C:\ higher up. The copying with `--win-cp-openblas` fails
# # when things are split over drives.
# # cp C:\opt\64\bin\*.dll $pwd\build-install\Lib\site-packages\scikit-tree\.libs\
# # python tools\openblas_support.py --write-init $PWD\build-install\Lib\site-packages\scikit-tree\
# - name: test
# run: |
# python spin test