-
Notifications
You must be signed in to change notification settings - Fork 175
193 lines (166 loc) · 6.41 KB
/
ci.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
name: Build package on different Os and Python versions
on :
pull_request:
workflow_dispatch:
inputs:
testNotebooks:
description: 'Enable notebook verification step'
type: boolean
required: false
default: false
# currently WIP
jobs:
build_package:
name: Build ${{ github.event.repository.name }} on ${{ matrix.os }} for Python-${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
include:
- os: ubuntu-latest
path: ~/.cache/pip
papermill_timeout: 120
# ccache requires absolute path
path_ccache: /home/runner/cache/ccache
- os: macos-latest
path: ~/Library/Caches/pip
papermill_timeout: 240
# ccache requires absolute path
path_ccache: /Users/runner/Library/Caches/ccache
- os: windows-latest
path: ~\AppData\Local\pip\Cache
papermill_timeout: 300
# FIXME: ccache is currently not available on Windows
# path_ccache: ~\AppData\Local\ccache\Cache
env:
BOOST_VERSION: 1.76.0
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python-${{ matrix.python-version }}
with:
python-version: ${{ matrix.python-version }}
###################
# Caching stuff #
###################
- name: Activating Python cache
uses: actions/cache@v2
id: cache_python
continue-on-error: true
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
- name: Cache boost ${{env.BOOST_VERSION}}
# FIXME For an unknow reason on windows runner, when the cache is hit
# The compilation fails because it doesn't find some headers
# I don't know if the cache is corrupted, for the moment hard to debug
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
uses: actions/cache@v2
id: cache-boost
with:
# Set the default path as the path to cache
path: ${{ github.workspace }}/boost/boost
# Use the version as the key to only cache the correct version
key: boost-${{env.BOOST_VERSION}}
# FIXME: This is quite costly but at the moment I don't have an alternative
- name: Install ccache for Linux and Mac
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt -y install ccache
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install ccache
fi
shell: bash
# Windows does not support ccache with visual studio compiler
- name: ccache cache files
if: ${{ runner.os != 'Windows' }}
uses: actions/cache@v2
id: cache_ccache
continue-on-error: true
with:
path: ${{ matrix.path_ccache }}
# TODO: When updating c++ backend, use new date (yy-mm-dd)
key: ${{ runner.os }}-ccache-${{ matrix.python-version }}-22-01-11
- name: Upgrade pip and setuptools
run: |
python -m pip install --upgrade pip setuptools
- name: Install boost ${{env.BOOST_VERSION}}
uses: MarkusJx/install-boost@v2.1.0
id: install-boost
if: steps.cache-boost.outputs.cache-hit != 'true'
with:
boost_version: ${{env.BOOST_VERSION}}
######################
# Building package #
######################
- name: Build ${{ github.event.repository.name }} on Linux and MacOs
if: ${{ runner.os != 'Windows' }}
run: |
echo $BOOST_ROOT
python -m pip install -e ".[dev]"
env:
CC: "ccache gcc"
CXX: "ccache g++"
CCACHE_DIR: ${{ matrix.path_ccache }}
CCACHE_COMPRESS: 1
CCACHE_MAXSIZE: 4G
BOOST_ROOT: ${{ github.workspace }}/boost/boost
# Windows does not support ccache with visual studio compiler
- name: Build ${{ github.event.repository.name }} on Windows
if: ${{ runner.os == 'Windows' }}
run: |
python -m pip install -e ".[dev]"
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
- name: Install test tools
run: |
python -m pip install pandas pytest pytest-cov pytest-benchmark hypothesis
#############
# Testing #
#############
- name: Test package with pytest on Linux and Windows
if: ${{ runner.os == 'Linux' || runner.os == 'Windows' }}
run: |
pytest --pyargs gtda --no-cov
- name: Test package with pytest Mac with coverage
if: ${{ runner.os == 'macOS' }}
run: |
pytest gtda --cov --cov-report xml:coverage.xml
# FIXME: It does not use config.cfg, I don't know why ...
- name: flake8 Lint on MacOS
if: ${{ runner.os == 'macOS' }}
uses: py-actions/flake8@v2
with:
exclude: "boost,gtda/externals,doc,examples"
- name: Test jupyter notebooks with papermill
if: ${{ github.event.inputs.testNotebooks == true }}
run: |
python -m pip install openml matplotlib
python -m pip install papermill
cd examples
# Get all .ipynb notebook but discard the MNIST_classification
# Because it is too long
# This command also removes the .pynb extension
FILES_WITHOUT_EXT=`find . ! -name '*MNIST_classification*' -iname '*.ipynb' -exec bash -c 'printf "%s\n" "${@%.*}"' _ {} +`
PAPERMILL_DIR=papermill_results
mkdir -p $PAPERMILL_DIR
for FILENAME in $FILES_WITHOUT_EXT
do
SAVE_FILE=$PAPERMILL_DIR/$FILENAME.txt
papermill --execution-timeout ${{ matrix.papermill_timeout }} $FILENAME.ipynb $SAVE_FILE
done
shell: bash
######################
# Upload Artifacts #
######################
- name: Upload coverage for Mac
if: ${{ runner.os == 'macOS' }}
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-coverage
path: coverage.xml
if-no-files-found: warn