fixing tests and adding github action #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: tests | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main, "*"] | ||
jobs: | ||
Runner-Preparation: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
outputs: | ||
matrix-CUDA: ${{ steps.set-matrix.outputs.matrix-CUDA }} | ||
matrix-HIP: ${{ steps.set-matrix.outputs.matrix-HIP }} | ||
matrix-MACOS: ${{ steps.set-matrix.outputs.matrix-MACOS }} | ||
steps: | ||
- name: Prepare runner matrix | ||
id: set-matrix | ||
if: env.enable_integration == 'true' | ||
run: | | ||
if [ x"${{ github.repository }}" == x"triton-lang/kernels" ]; then | ||
echo '::set-output name=matrix-CUDA::[["a100-runner-set"], ["h100-runner-set"]]' | ||
echo '::set-output name=matrix-HIP::[["self-hosted", "gfx90a"]]' | ||
echo '::set-output name=matrix-MACOS::[["macos-latest"]]' | ||
else | ||
echo '::set-output name=matrix-CUDA::["ubuntu-latest"]' | ||
echo '::set-output name=matrix-HIP::["ubuntu-latest"]' | ||
echo '::set-output name=matrix-MACOS::[["macos-latest"]]' | ||
fi | ||
pre-commit: | ||
name: pre-commit (code formatting) | ||
needs: Runner-Preparation | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt | ||
- name: Check pre-commit | ||
run: | | ||
# TODO: ignore the first yapf failure until https://github.com/google/yapf/issues/1164 is fixed | ||
python3 -m pre_commit run --all-files --verbose yapf &> /dev/null || true | ||
# If first run of yapf worked and made changes reset the tree to the original state | ||
git reset --hard | ||
python3 -m pre_commit run --all-files --verbose | ||
- name: Print diff of changes if pre-commit failed | ||
if: failure() | ||
run: | | ||
git diff | ||
tests: | ||
needs: pre-commit | ||
if: needs.Runner-Preparation.outputs.matrix-CUDA != '' | ||
strategy: | ||
matrix: | ||
runner: ${{fromJson(needs.Runner-Preparation.outputs.matrix-CUDA)}} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
- uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
- name: Run Python unit tests | ||
run: python3 -m pytest |