[b9e282]: / .github / workflows / unit-tests.yml

Download this file

226 lines (201 with data), 8.1 kB

  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
name: "BioNemo Image Build and Unit Tests"
on:
push:
branches:
- main
- "pull-request/[0-9]+"
- "dependabot/**"
merge_group:
types: [checks_requested]
schedule:
- cron: "0 7 * * *" # Runs at 7 AM UTC daily (12 AM MST)
defaults:
run:
shell: bash -x -e -u -o pipefail {0}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- run: pip install -r requirements-dev.txt
- run: ./ci/scripts/static_checks.sh
# With copy-pr-bot, we need to get the PR labels from the PR API rather than from the event metadata.
get-pr-labels:
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.get-labels.outputs.labels }}
steps:
- name: Get PR number from branch
if: startsWith(github.ref, 'refs/heads/pull-request/')
id: get-pr-num
run: |
PR_NUM=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+$')
echo "pr_num=$PR_NUM" >> $GITHUB_OUTPUT
- name: Get PR labels
id: get-labels
if: startsWith(github.ref, 'refs/heads/pull-request/')
env:
GH_TOKEN: ${{ github.token }}
run: |
LABELS=$(gh api repos/${{ github.repository }}/pulls/${{ steps.get-pr-num.outputs.pr_num }} --jq '[.labels[].name]' || echo "[]")
echo "labels=$LABELS" >> $GITHUB_OUTPUT
- name: Set empty labels for non-PR branches
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
id: get-labels-empty
run: echo "labels=[]" >> $GITHUB_OUTPUT
build-bionemo-image:
needs:
- pre-commit
- get-pr-labels
runs-on: linux-amd64-cpu16
if: ${{ !contains(fromJSON(needs.get-pr-labels.outputs.labels || '[]'), 'SKIP_CI') }}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: svcbionemo023/bionemo-framework
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=${{ github.run_id }}
# This action sets up our cache-from and cache-to flags appropriately; see the README of this action for more
# info. It doesn't seem to cache correctly for merge_group events, so we need to add that as an extra argument in
# the step below. There's probably a slight optimization to be had here by caching from the pr- caches for
# merge_group events. See https://github.com/int128/docker-build-cache-config-action/issues/1005 for more info.
- uses: int128/docker-build-cache-config-action@v1
id: cache
with:
image: svcbionemo023/bionemo-build-cache
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: |
${{ steps.cache.outputs.cache-from }}
type=registry,ref=svcbionemo023/bionemo-build-cache:main
cache-to: ${{ steps.cache.outputs.cache-to }}
run-tests:
needs:
- build-bionemo-image
- get-pr-labels
runs-on: linux-amd64-gpu-l4-latest-1
container:
image: svcbionemo023/bionemo-framework:${{ github.run_id }}
credentials:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
# Tests in this stage generate code coverage metrics for the repository
# Coverage data is uploaded to Codecov in subsequent stages
env:
BIONEMO_DATA_SOURCE: ngc
run: ./ci/scripts/run_pytest.sh --no-nbval --skip-slow
- name: Upload coverage to Codecov
# Don't run coverage on merge queue or nightly CI to avoid duplicating reports
# to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155
if: github.event_name != 'merge_group' && github.event_name != 'schedule'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
# Don't run coverage on merge queue or nightly CI to avoid duplicating reports
# to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155
if: ${{ !cancelled() && github.event_name != 'merge_group' && github.event_name != 'schedule' }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
run-slow-tests:
needs:
- build-bionemo-image
- get-pr-labels
runs-on: linux-amd64-gpu-l4-latest-1
container:
image: svcbionemo023/bionemo-framework:${{ github.run_id }}
credentials:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: |
github.event_name == 'schedule' || github.event_name == 'merge_group' ||
contains(fromJSON(needs.get-pr-labels.outputs.labels || '[]'), 'INCLUDE_SLOW_TESTS')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run slow tests
env:
BIONEMO_DATA_SOURCE: ngc
# Not every sub-package has slow tests, and since some sub-packages have tests under the same name we need
# to run package by package like we do with the fast tests.
run: ./ci/scripts/run_pytest.sh --no-nbval --only-slow --allow-no-tests
run-notebooks-docs:
needs:
- build-bionemo-image
- get-pr-labels
runs-on: linux-amd64-gpu-l4-latest-1
if: |
github.event_name == 'schedule' || github.event_name == 'merge_group' ||
contains(fromJSON(needs.get-pr-labels.outputs.labels || '[]'), 'INCLUDE_NOTEBOOKS_TESTS')
container:
image: svcbionemo023/bionemo-framework:${{ github.run_id }}
credentials:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run notebook tests
env:
BIONEMO_DATA_SOURCE: ngc
# this variable should be used in the notebooks to run a subset of the model layers or a smaller model/dataset
FAST_CI_MODE: true
run: |
pytest -v --nbval-lax -p no:python docs/ sub-packages/
verify-tests-status:
# Base on the status of this job, the unit-tests workflow succeeds or fails
# This steps checks the status of all test jobs and fails if any of them failed or were cancelled.
# It is a workaround for the lack of a built-in feature to finalize a pipeline by checking the status of multiple jobs
needs: # List all your run-*-test jobs
- run-tests
- run-slow-tests
- run-notebooks-docs
# Add all other run-*-test jobs
runs-on: ubuntu-latest
if: always() # This ensures the job runs even if previous jobs fail
steps:
- name: Check test job statuses
run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "Some test jobs have failed or been cancelled!"
exit 1
else
echo "All test jobs have completed successfully or been skipped!"
exit 0
fi