Skip to content

Commit

Permalink
feat(workflows): add setup-docker-and-run-tests.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
basarbyz committed Jul 26, 2024
1 parent eb05f14 commit 188f101
Showing 1 changed file with 12 additions and 33 deletions.
45 changes: 12 additions & 33 deletions .github/workflows/setup-docker-and-run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: setup-docker-and-run-tests.yml

on: [push]
on:
push:
branches:
- 14-integrate-docker-services-and-unitest-in-github-actions
pull_request:
branches:
- main

jobs:
setup-and-start-services:
Expand Down Expand Up @@ -49,37 +55,10 @@ jobs:
name: container-ip
path: container_ip.txt

- name: Persist Containers
run: |
RUNNER_TRACKING_ID="" && sleep infinity &
background: true

run-tests:
name: Run Tests
runs-on: ubuntu-latest
needs: setup-and-start-services

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: container-ip
path: .

- name: Read IP address
id: read-ip
run: |
CONTAINER_IP=$(cat container_ip.txt)
echo "CONTAINER_IP=$CONTAINER_IP" >> $GITHUB_ENV
- name: Create .env File
- name: Create .env file for tests
run: |
cd tests
cp .env.test.example .env
sed -i "s/localhost/$CONTAINER_IP/g" .env
cp .env.tests.example .env
- name: Set up Python 3.8
uses: actions/setup-python@v4
Expand All @@ -96,6 +75,8 @@ jobs:
run: |
source venv/bin/activate
pip install -r tests/requirements.txt
pip install -r backend/api/requirements.txt
pip install -r backend/gateway/requirements.txt
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$(pwd)" >> $GITHUB_ENV
Expand All @@ -104,6 +85,4 @@ jobs:
run: |
source venv/bin/activate
cd tests
python -m unittest test_crud.py
python -m unittest test_crud.py

0 comments on commit 188f101

Please sign in to comment.