Skip to content

Unittest

Unittest #229

Workflow file for this run

name: Unittest
on:
push:
branches: [ master ]
schedule:
- cron: '00 23 * * *'
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: testrootpass
DB_HOST: 127.0.0.1
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create env file
run: |
cat << EOF > .env
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
SALT=${{ secrets.SALT }}
EOF
- name: Set up DB
run: |
mysql -h 127.0.0.1 --port 3306 -u root -ptestrootpass < test/test_init.sql
- name: Running test cases for util
run: python test/test_util.py
- name: Running test cases for predicting
run: python test/test_predict.py
- name: Running test cases for searching
run: python test/test_search.py