Skip to content

add test

add test #182

Workflow file for this run

name: PR Tests
on:
push:
branches:
- "pull-request/[0-9]+"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
if: github.repository == 'NVIDIA/tilus'
runs-on: ubuntu-latest
outputs:
should_run_tests: ${{ steps.changed-tests.outputs.any_changed }}
should_run_examples: ${{ steps.changed-examples.outputs.any_changed }}
should_run_docs: ${{ steps.changed-docs.outputs.any_changed }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changes in test-relevant directories
id: changed-tests
uses: step-security/changed-files@v46
with:
files: |
tests/**
python/**
pyproject.toml
base_sha: 'origin/main'
- name: Check for changes in examples
id: changed-examples
uses: step-security/changed-files@v46
with:
files: |
python/**
examples/**
pyproject.toml
base_sha: 'origin/main'
- name: Check for changes in docs
id: changed-docs
uses: step-security/changed-files@v46
with:
files: |
python/**
docs/**
pyproject.toml
base_sha: 'origin/main'
test-core:
needs: check-changes
if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_tests == 'true'
continue-on-error: true
strategy:
matrix:
runner:
- linux-amd64-gpu-l4-latest-1
runs-on: ${{ matrix.runner }}
container:
image: nvidia/cuda:12.6.2-devel-ubuntu22.04
options: --gpus all
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup and Install Tilus
id: setup-and-install
uses: ./.github/actions/setup-environment
with:
python-version: '3.10'
- name: Run main tests
run: pytest ./tests --ignore=tests/examples/
docs:
needs: check-changes
if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_docs == 'true'
runs-on: linux-amd64-gpu-l4-latest-1
container:
image: nvidia/cuda:12.6.2-devel-ubuntu22.04
options: --gpus all
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup and Install Tilus
id: setup-and-install
uses: ./.github/actions/setup-environment
with:
python-version: '3.10'
- name: Build docs
run: |
cd docs
make html
test-examples:
needs: check-changes
if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_examples == 'true'
runs-on: linux-amd64-gpu-l4-latest-1
container:
image: nvidia/cuda:12.6.2-devel-ubuntu22.04
options: --gpus all
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup and Install Tilus
id: setup-and-install
uses: ./.github/actions/setup-environment
with:
python-version: '3.10'
- name: Install example dependencies
run: |
pip install wheel
pip install torch==2.8 # since flash-attn only has pre-built wheels for torch<=2.8, todo: update this when flash-attn supports torch>=2.9
pip install flash-attn --no-build-isolation
- name: Run unit tests
run: pytest tests/examples/ -v
all-functional-tests:
name: All Functional Tests
needs: [test-core, docs, test-examples]
if: always() && github.repository == 'NVIDIA/tilus'
runs-on: ubuntu-latest
steps:
- name: Check job results
run: |
echo "Core tests result: ${{ needs.test-core.result }}"
echo "Docs result: ${{ needs.docs.result }}"
echo "Example tests result: ${{ needs.test-examples.result }}"
# Check if any required job failed
if [[ "${{ needs.test-core.result }}" == "failure" ]] || [[ "${{ needs.docs.result }}" == "failure" ]] || [[ "${{ needs.test-examples.result }}" == "failure" ]]; then
echo "One or more functional tests failed"
exit 1
elif [[ "${{ needs.test-core.result }}" == "cancelled" ]] || [[ "${{ needs.docs.result }}" == "cancelled" ]] || [[ "${{ needs.test-examples.result }}" == "cancelled" ]]; then
echo "One or more functional tests were cancelled"
exit 1
else
echo "All functional tests passed or were skipped"
fi