Skip to content

Fix tests

Fix tests #1659

Workflow file for this run

name: Tests
on:
push:
pull_request:
workflow_call:
release:
types: [created]
permissions:
contents: read
jobs:
run_tests:
name: Test the code
strategy:
fail-fast: false
matrix:
backend: [tensorflow, jax, torch]
version: [keras-stable]
include:
- backend: jax
version: keras-3.1
- backend: jax
version: keras-nightly
runs-on: ubuntu-latest
env:
KERAS_BACKEND: ${{ matrix.backend }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements.txt --progress-bar off
pip install --no-deps -e "." --progress-bar off
- name: Pin Keras 3.1
if: ${{ matrix.version == 'keras-3.1'}}
run: |
pip uninstall -y keras
pip install keras==3.1.0 --progress-bar off
- name: Pin Keras Nightly
if: ${{ matrix.version == 'keras-nightly'}}
run: |
pip uninstall -y keras
pip install keras-nightly --progress-bar off
- name: Test with pytest
run: |
pytest keras_hub/
- name: Run integration tests
run: |
python pip_build.py --install
cd integration_tests && pytest . -k "not NoTensorflow"
- name: Run no tensorflow integration test
if: ${{ matrix.backend != 'tensorflow'}}
run: |
pip uninstall -y tensorflow-text tensorflow
cd integration_tests && pytest . -k "NoTensorflow"
check_format:
name: Check the code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements.txt --progress-bar off
pip install --no-deps -e "." --progress-bar off
- name: Lint
run: bash shell/lint.sh
- name: Check for API changes
run: |
bash shell/api_gen.sh
git status
clean=$(git status | grep "nothing to commit")
if [ -z "$clean" ]; then
echo "Please run shell/api_gen.sh to generate API."
exit 1
fi