-
Notifications
You must be signed in to change notification settings - Fork 5
186 lines (159 loc) · 5.67 KB
/
CI.yaml
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
name: CI
on:
push:
# Run CI on all pushed branches.
branches: "*"
# Run CI on all versioned tags.
tags: "[0-9]+.[0-9]+.[0-9]+"
# Run CI nightly at 03:00 PST (11:00 UTC).
schedule:
- cron: "0 11 * * *"
# Allow maintainers to manually trigger the build.
workflow_dispatch: {}
jobs:
test:
name: Test on py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, macOS-13]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
# Cache our conda packages.
# More info: https://github.com/conda-incubator/setup-miniconda#caching-packages
- name: Cache conda environment
uses: actions/cache@v3
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-py${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Set up Anaconda environment
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
channels: conda-forge,defaults
activate-environment: mdsapt
auto-update-conda: false
auto-activate-base: false
#use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
# TODO: make pyright happier someday in the future
# - name: Type-check
# shell: bash -l {0}
# run: |
# pyright mdsapt
- name: Run tests
shell: bash -l {0}
run: |
pytest -v ./mdsapt --cov=mdsapt --cov-report=xml
- name: Upload CodeCov
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
- name: Install MDSAPT package
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda list
package:
name: Packaging py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: test
if: startsWith(github.ref, 'refs/tags') # only do this on tags
strategy:
fail-fast: true
matrix:
os: [macOS-13, ubuntu-latest]
python-version: [3.9, 3.10, 3.11, 3.12]
include:
- os: macOS-latest
output-folder: osx-64
- os: ubuntu-latest
output-folder: linux-64
steps:
- uses: actions/checkout@v2
# Cache our conda packages.
# More info: https://github.com/conda-incubator/setup-miniconda#caching-packages
- name: Cache conda environment
uses: actions/cache@v2
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-py${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('devtools/deploy/environment.yml') }}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Set up Anaconda environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/deploy/environment.yml
channels: psi4,conda-forge
activate-environment: mdsapt-build
auto-update-conda: false
auto-activate-base: false
#use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Build MDSAPT conda package
# conda requires this special shell
shell: bash -l {0}
run: conda build -c psi4 -c conda-forge --output-folder . .
- name: Upload MDSAPT conda package
# conda requires this special shell
shell: bash -l {0}
if: startsWith(github.ref, 'refs/tags') # only do this on tags
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: anaconda upload --label main ${{ matrix.output-folder }}/*.tar.bz2
verify:
name: Test installing py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags') # only do this on tags
needs: package
strategy:
fail-fast: false
matrix:
os: [macOS-latest, macOS-13, ubuntu-latest]
python-version: [3.9, 3.10, 3.11, 3.12]
steps:
- uses: actions/checkout@v2
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Create Anaconda environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
activate-environment: mdsapt-test
auto-update-conda: false
auto-activate-base: false
- name: Install mdsapt from mdsapt-testing
shell: bash -l {0}
# NOTE: psi4 must be first channel
run: >
conda install -c psi4 -c defaults -c conda-forge -c mdsapt-testing mdsapt
- name: Test importing mdsapt
shell: bash -l {0}
run: >
python3 -c "import mdsapt"
lint-and-format:
# These checks are much faster and don't actually need to install any packages.
name: Run fast checks over code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install formatter and linter
run: |
pip install autopep8 pylint
- name: Lint code
run: |
pylint --fail-under=9.5 --disable=E,R mdsapt
- name: Ensure formatting
run: |
autopep8 -r mdsapt --diff --exit-code