-
Notifications
You must be signed in to change notification settings - Fork 2
194 lines (181 loc) · 6.24 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
193
194
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: CI
on:
push:
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [windows-latest, macOS-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install oldest-supported-numpy==2023.10.25
# --ignore-requires-python ensures docs deps don't break install on early python versions
if [ -f requirements.txt ]; then pip install --ignore-requires-python -r requirements.txt; fi
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pytest
coverage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Setup LCOV
# uses: hrishikesh-kadam/setup-lcov@v1
- name: Install dependencies
run: |
sudo apt update -yy
sudo apt install -yy lcov
python -m pip install --upgrade pip
pip install wheel
pip install oldest-supported-numpy==2023.10.25
# --ignore-requires-python ensures docs deps don't break install on early python versions
if [ -f requirements.txt ]; then pip install --ignore-requires-python -r requirements.txt; fi
rm -rf Empirical/.git
- name: Build phylotrackpy
run: |
make coverage
- name: Test with pytest
run: |
python -m pytest --cov=. --cov-report=lcov
lcov --output-file coverage.cpp --capture --directory .
lcov --output-file coverage.cpp --extract coverage.cpp "*"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
files: "coverage.cpp, coverage.lcov, Empirical/include/emp/Evolve/Systematics.hpp"
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
build_wheels:
name: Build wheels on ${{ matrix.os }}
needs: []
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
needs: []
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
# Regression test borrowed from https://github.com/mmore500/hstrat/blob/ba7b19d0f0561303b6bf789d5024a323aa5993fc/.github/workflows/ci.yaml#L201
packaging-sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build sdist
run: |
python3 -m venv env
source env/bin/activate
python3 -m pip install -r requirements.txt
python3 setup.py sdist
tree dist
deactivate
- name: Upgrade pip
run: python3 -m pip install pip --upgrade
- name: Install from sdist
run: python3 -m pip install dist/*.tar.gz
- name: Test install
run: |
find . -type f -name '*.py' -exec rm {} \;
python3 -c "import phylotrackpy; print(phylotrackpy.__version__)"
upload_pypi:
needs: [build_wheels, build_sdist, test]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@v1.8.12
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: joss/paper.md
- name: Upload
uses: actions/upload-artifact@v4
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: joss/paper.pdf