-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (135 loc) · 4.91 KB
/
ci_test.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
name: Python package CI/CD
on:
push:
branches: [ main, anaconda, arm ]
pull_request:
branches: [ main ]
release:
types: [published]
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel cython
pip install "numpy>=1.16.3" --only-binary=numpy "scipy>=1.11.3" --only-binary=scipy
pip install black pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Build Cython extensions
run: python setup.py build_ext --inplace
- name: Lint with black
run: |
black . --check
- name: Install package in editable mode
run: pip install -e .
shell: bash
- name: Run tests with pytest
run: |
pytest --cov=fastshermanmorrison --cov-report xml:coverage.xml tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
build:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip setuptools wheel cython cibuildwheel==2.3.1 setuptools_scm
- name: Install project dependencies
run: |
pip install "numpy>=1.16.3" --only-binary=numpy "scipy>=1.2.0" --only-binary=scipy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build wheels using cibuildwheel
run: cibuildwheel --output-dir dist
env:
CIBW_BEFORE_BUILD: "pip install numpy>=1.16.3 --only-binary=numpy scipy>=1.2.0 --only-binary=scipy"
CIBW_BUILD_VERBOSITY: 1
CIBW_SKIP: "pp* cp27-* cp35-* cp36-* cp37-* cp38-* *-win32 *-manylinux_i686 *-musllinux_i686 *-macosx_10_6_intel *-macosx_10_9_intel *-macosx_10_10_intel *-macosx_10_11_intel *-macosx_10_12_intel *-macosx_10_13_intel *-macosx_10_14_intel *-macosx_10_15_intel"
CIBW_ARCHS: "x86_64 aarch64"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux2014_aarch64"
- name: Build source distribution
run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
name: dist
path: |
./dist/*.whl
./dist/*.tar.gz
deploy:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Download built distributions
uses: actions/download-artifact@v3
with:
name: dist
path: ./dist/
- name: Publish to PyPI
run: |
python -m pip install --upgrade twine
python -m twine upload ./dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
#TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
#TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
conda-package:
runs-on: ubuntu-latest
needs: [tests, build]
steps:
- name: Set CONDA_GIT_BRANCH environment variable
run: echo "CONDA_GIT_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
conda-channels: anaconda, conda-forge
- name: Install conda-build and anaconda-client
run: |
conda install conda-build anaconda-client
- name: Build conda package
run: |
conda config --set anaconda_upload no
conda build recipe/
- name: Upload conda package to Anaconda Cloud
if: github.event_name == 'release'
run: |
echo "Uploading to Anaconda Cloud..."
source activate base
anaconda -t ${{ secrets.ANACONDA_API_TOKEN }} upload $(conda build recipe/ --output)
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}