-
Notifications
You must be signed in to change notification settings - Fork 18
238 lines (224 loc) · 7.44 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
name: gh-ci-checks
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
pull_request:
paths:
- "**.py"
- pyproject.toml
- .github/workflows/main.yml
push:
branches: [main]
paths:
- "**.py"
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
style:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
architecture: "x64"
- name: Install packages for Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r style_requirements.txt
# check formatting of the code style
- name: Check code formatting
run: make pre-commit
build:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# upgrade to macos-latest when 3.10 is removed
os: ["ubuntu-latest", "macos-13", "windows-latest"]
python-version: ["3.10", "3.11", "3.12"]
name: build ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Install and setup package
run: |
python -m pip install --progress-bar off .[build]
- name: Test package install
run: |
python -c "import dodiscover; print(dodiscover.__version__)"
- name: Remove package install
run: |
python -m pip uninstall -yq dodiscover
- name: Build package
run: python -m build
- name: Upload package distribution files
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v3
with:
name: package
path: dist
#
# Test wheel-based Installation
#
- name: Install wheel
run: pip install ./dist/*.whl
- name: Test wheel install
run: python -c "import dodiscover; print(dodiscover.__version__)"
- name: Remove wheel install
run: python -m pip uninstall -yq dodiscover
#
# Test sdist-based Installation
#
- name: Install sdist
run: pip install ./dist/*.tar.gz
- name: Test sdist install
run: python -c "import dodiscover; print(dodiscover.__version__)"
- name: Remove sdist install
run: python -m pip uninstall -yq dodiscover
test:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
# oldest and newest supported versions
python-version: ["3.10", "3.11"] # TODO: update to 3.12 when statsmodels supports
networkx: [stable, main]
exclude:
- { python-version: "3.10", os: "macos-latest" }
include:
- { python-version: "3.10", os: "macos-13" }
name: Unit-test ${{ matrix.os }} - py${{ matrix.python-version }} - Networkx ${{ matrix.networkx }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Install packages via pip
run: |
pip install --upgrade pip
pip install numpy scipy networkx statsmodels
- name: Install package
run: |
pip install .[test]
pip install .
- name: Install Networkx (main)
if: "matrix.networkx == 'main'"
run: |
pip uninstall -yq networkx
pip install --progress-bar off git+https://github.com/networkx/networkx
- name: Run pytest
run: |
pytest --cov dodiscover ./tests/unit_tests/
- name: Upload coverage stats to codecov
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10' && matrix.networkx == 'stable' }}
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
integration_test:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
networkx: [main]
name: Integration test ${{ matrix.os }} - py${{ matrix.python-version }} - Networkx ${{ matrix.networkx }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Install packages for Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y graphviz optipng libxft2 graphviz-dev
- name: Setup torch
run: |
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
- name: Install packages via pip
run: |
pip install --upgrade pip
pip install numpy scipy networkx statsmodels
pip install .[test,doc]
- name: Run pytest # headless via Xvfb on linux
run: |
pytest tests/integration_tests
# release is ran when a release is made on Github
release:
name: Release
runs-on: ubuntu-latest
needs: [style, build, test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
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@v4
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@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*