Skip to content

Commit

Permalink
Changes in workflows
Browse files Browse the repository at this point in the history
* change API testing to use docker compose
* create simple database testing
  • Loading branch information
Kabanosk committed May 8, 2024
1 parent a3b09ca commit fd36edf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/database_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and test web application

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run docker compose and wait until web server is up
run: |
docker-compose up -d
timeout 60 bash -c 'until echo > /dev/tcp/localhost/8000; do sleep 1; done'
- name: Run tests
run: pytest tests/database.py

- name: Stop and remove container
run: docker-compose down
11 changes: 3 additions & 8 deletions .github/workflows/webapp_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build Docker image
run: docker build -t app .

- name: Run Docker Container and wait until web server is up
- name: Run docker compose and wait until web server is up
run: |
docker run --name app_container -d -p 8000:8000 app
docker-compose up -d
timeout 60 bash -c 'until echo > /dev/tcp/localhost/8000; do sleep 1; done'
- name: Run tests
run: pytest tests/api.py

- name: Stop and remove container
run: |
docker stop app_container
docker rm app_container
run: docker-compose down

0 comments on commit fd36edf

Please sign in to comment.