forked from chemprop/chemprop
-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (190 loc) · 6.64 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
195
196
197
198
199
200
201
202
203
# ci.yml
#
# Continuous Integration for Chemprop - checks build, code formatting, and runs tests for all
# proposed changes and on a regular schedule
#
# Note: this file contains extensive inline documentation to aid with knowledge transfer.
name: Continuous Integration
on:
# run on pushes/pull requests to/against main
push:
branches: [main]
pull_request:
branches: [main]
# run this in the morning on weekdays to catch dependency issues
schedule:
- cron: "0 8 * * 1-5"
# allow manual runs
workflow_dispatch:
# cancel previously running tests if new commits are made
# https://docs.github.com/en/actions/examples/using-concurrency-expressions-and-a-test-matrix
concurrency:
group: actions-id-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Check Build
runs-on: ubuntu-latest
steps:
# clone the repo, attempt to build
- uses: actions/checkout@v4
- run: python -m pip install build
- run: python -m build .
lint:
name: Check Formatting
needs: build
runs-on: ubuntu-latest
steps:
# clone the repo, run black and flake8 on it
- uses: actions/checkout@v4
- run: python -m pip install black==23.* flake8
- run: black --check .
- run: flake8 .
test:
name: Execute Tests
needs: lint
runs-on: ${{ matrix.os }}
defaults:
run:
# run with a login shell (so that the conda environment is activated)
# and echo the commands we run as we do them (for debugging purposes)
shell: bash -el {0}
strategy:
# if one platform/python version fails, continue testing the others
fail-fast: false
matrix:
# test on all platforms with both supported versions of Python
os: [ubuntu-latest, macos-13, windows-latest]
python-version: [3.11, 3.12]
steps:
- uses: actions/checkout@v4
# use a version of the conda virtual environment manager to set up an
# isolated environment with the Python version we want
- uses: mamba-org/setup-micromamba@main
with:
environment-name: temp
condarc: |
channels:
- defaults
- conda-forge
channel_priority: flexible
create-args: |
python=${{ matrix.python-version }}
- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install nbmake
python -m pip install ".[dev,docs,test]"
- name: Install hyperopt optional dependencies (Python 3.11 only)
if: ${{ matrix.python-version == '3.11' }}
run: |
python -m pip install ".[hpopt]"
- name: Test with pytest
shell: bash -l {0}
run: |
# specifically disable running on GPU, otherwise Lightning will attempt to use the Apple GPU
# that the GitHub actions runners still have but are not allowed to actually use
pytest -v tests
- name: Test notebooks
shell: bash -l {0}
run: |
pytest --nbmake examples/training.ipynb
pytest --nbmake examples/predicting.ipynb
pytest --nbmake examples/convert_v1_to_v2.ipynb
pytest --nbmake examples/training_regression_multicomponent.ipynb
pytest --nbmake examples/predicting_regression_multicomponent.ipynb
conda-test:
name: Execute Tests with Conda-based Install
needs: lint
runs-on: ubuntu-latest
defaults:
run:
# run with a login shell (so that the conda environment is activated)
# and echo the commands we run as we do them (for debugging purposes)
shell: bash -el {0}
strategy:
# if one platform/python version fails, continue testing the others
fail-fast: false
matrix:
python-version: [3.11, 3.12]
steps:
- uses: actions/checkout@v4
# use a version of the conda virtual environment manager to set up an
# isolated environment with the Python version we want
- uses: mamba-org/setup-micromamba@main
with:
environment-file: environment.yml
condarc: |
channels:
- defaults
- conda-forge
- pytorch
channel_priority: flexible
create-args: |
python=${{ matrix.python-version }}
- name: Install Testing Dependencies
run: conda install -c conda-forge pytest>=6.2 pytest-cov
- name: Install Chemprop
run: python -m pip install . --no-deps
- name: Test with pytest
shell: bash -l {0}
run: |
pytest -v tests
pypi:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
# only run if the tests pass
needs: [test, conda-test]
# run only on pushes to main on chemprop
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'chemprop/chemprop'}}
steps:
- uses: actions/checkout@master
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
verbose: true
build-and-push-docker:
# shamelessly copied from:
# https://github.com/ReactionMechanismGenerator/RMG-Py/blob/bfaee1cad9909a17103a8e6ef9a22569c475964c/.github/workflows/CI.yml#L359C1-L386C54
# which is also shamelessly copied from somewhere
runs-on: ubuntu-latest
# only run if the tests pass
needs: [test, conda-test]
# run only on pushes to main on chemprop
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'chemprop/chemprop'}}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
# repository secretes managed by the maintainers
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
tags: chemprop/chemprop:latest