test(no-ticket): add tests for user #31
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: Run Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Delete Existing SQLite Test DB | |
run: | | |
if [ -f db.sqlite3 ]; then rm db.sqlite3; fi | |
- name: Run migrations | |
run: | | |
python manage.py makemigrations | |
python manage.py migrate | |
- name: Insert fixture data | |
run: | | |
chmod +x scripts/create_fixture_data.sh | |
./scripts/create_fixture_data.sh | |
- name: Insert dummy data if DB is empty | |
run: | | |
chmod +x scripts/create_dummy_data.sh | |
./scripts/create_dummy_data.sh | |
- name: Start Django server in the background | |
run: | | |
python manage.py runserver 0.0.0.0:8000 & | |
env: | |
MYSQL_ACTIVE: false | |
- name: Run tests | |
run: | | |
python manage.py test | |
- name: Stop Django server | |
run: | | |
kill $(lsof -t -i:8000) || echo "Server stopped" |