Skip to content

add option for PR label #26

add option for PR label

add option for PR label #26

name: "BioNeMo Recipes CI"
on:
push:
branches:
- "pull-request/[0-9]+"
- "dependabot/**"
merge_group:
types: [checks_requested]
schedule:
- cron: "0 9 * * *" # Runs at 9 AM UTC daily (2 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:
changed-dirs:
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
dirs: ${{ steps.set-dirs.outputs.dirs }}
steps:
- id: get-pr-info
uses: nv-gha-runners/get-pr-info@main
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: step-security/changed-files@v46
with:
json: true
matrix: true
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.ref }}
dir_names: true
dir_names_max_depth: 2
files: |
models/**
recipes/**
- id: set-dirs
run: |
# Get all recipe and model directories
ALL_DIRS=$(ls -d recipes/*/ models/*/ 2>/dev/null | jq -R -s -c 'split("\n")[:-1] | map(rtrimstr("/"))')
# Determine which directories to run: all for schedule, filtered for other events
if [[ "${{ github.event_name }}" == "schedule" ]]; then
DIRS="$ALL_DIRS"
elif [[ '${{ steps.get-pr-info.outputs.pr-info }}' != 'null' ]] && echo '${{ steps.get-pr-info.outputs.pr-info }}' | jq -e '.labels[]? | select(.name == "INCLUDE_ALL_RECIPES")' > /dev/null 2>&1; then
echo "Found INCLUDE_ALL_RECIPES label - running all directories"
DIRS="$ALL_DIRS"
else
CHANGED_FILES='${{ steps.changed-files.outputs.all_changed_files }}'
# Filter directories to only those that have changed files
DIRS=$(echo "$ALL_DIRS" | jq -c --argjson changed "$CHANGED_FILES" '
map(select(. as $dir | $changed | index($dir) != null))
')
fi
# Assign Docker images to the selected directories
# Currently, AMPLIFY is the only folder that needs a custom base image, since we have to support both TE and
# xformers-based models for golden value testing. The rest of the models use the default pytorch image.
DIRS_WITH_IMAGES=$(echo "$DIRS" | jq -c '
map({
dir: .,
image: (
if . == "models/amplify" then
"svcbionemo023/bionemo-framework:amplify-model-devcontainer-082025"
else
"nvcr.io/nvidia/pytorch:25.06-py3"
end
)
})
')
echo "dirs=$DIRS_WITH_IMAGES" >> $GITHUB_OUTPUT
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
echo '${{ toJSON(steps.set-dirs.outputs) }}'
echo '${{ toJSON(steps.get-pr-info.outputs.pr-info) }}'
shell:
bash
unit-tests:
needs: changed-dirs
runs-on: linux-amd64-gpu-l4-latest-1
if: ${{ needs.changed-dirs.outputs.any_changed == 'true' }}
container:
image: ${{ matrix.recipe.image }}
strategy:
matrix:
recipe: ${{ fromJson(needs.changed-dirs.outputs.dirs) }}
fail-fast: false
steps:
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: '${{ matrix.recipe.dir }}'
sparse-checkout-cone-mode: false
- name: Install dependencies
working-directory: ${{ matrix.recipe.dir }}
#
run: |
if [ -f pyproject.toml ] || [ -f setup.py ]; then
PIP_CONSTRAINT= pip install -e .
echo "Installed ${{ matrix.recipe.dir }} as editable package"
elif [ -f requirements.txt ]; then
PIP_CONSTRAINT= pip install -r requirements.txt
echo "Installed ${{ matrix.recipe.dir }} from requirements.txt"
else
echo "No pyproject.toml, setup.py, or requirements.txt found in ${{ matrix.recipe.dir }}"
exit 1
fi
- name: Run tests
working-directory: ${{ matrix.recipe.dir }}
run: pytest -v .