Skip to content

Do not run tests if branch is not up to date with main #1794

Do not run tests if branch is not up to date with main

Do not run tests if branch is not up to date with main #1794

name: Test package install - inference-sdk
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
id-token: write
jobs:
is_mergeable:
outputs:
mergeable_state: ${{ steps.mergeable_check.outputs.mergeable_state }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
timeout-minutes: 15
steps:
- name: 🛎️ Checkout branch with all history
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Check and store mergable state
id: mergeable_check
run: |
echo "Check if ${{ github.event.pull_request.head.sha }} (branch HEAD) is ancestor of ${{ github.event.pull_request.base.sha }} (main HEAD)";
if $(git merge-base --is-ancestor ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}); then
echo "Branch is mergeable";
echo "mergeable_state=clean" >> "$GITHUB_OUTPUT";
else
echo "Branch needs to be updated";
echo "mergeable_state=not_clean" >> "$GITHUB_OUTPUT";
fi
build:
needs: is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.is_mergeable.outputs.mergeable_state == 'clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
timeout-minutes: 10
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🐍 Set up Python 3.9 to create wheels
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: 🛞 Create Wheels
run: |
make create_wheels
- name: 🐍 Set up Python ${{ matrix.python-version }} to test package install process
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: 📦 Cache Python packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements/**') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: 📦 Installing `inference` package...
run: pip install ./dist/inference_sdk-*-py3-none-any.whl
- name: 🧪 Testing package installation
working-directory: "/"
run: |
python -c "import os; import platform; print(f'Python version: {platform.python_version()}'); print(f'CWD: {os.getcwd()}'); from inference_sdk import InferenceHTTPClient"