Skip to content

Add the web service implementation #31

Add the web service implementation

Add the web service implementation #31

Workflow file for this run

name: Run tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install podman -y
python -m pip install -U pip podman-compose
python -m pip install -r src/requirements.txt
- name: Build and run with Podman
run: |
podman build -t tmt-web .
podman run -d --name redis redis:latest
podman run -d --name web -p 8000:8000 -e REDIS_URL=redis://redis:6379 -e API_HOSTNAME=http://localhost:8000 tmt-web uvicorn src.api:app --reload --host 0.0.0.0 --port 8000
podman run -d --name celery -e REDIS_URL=redis://redis:6379 -e API_HOSTNAME=http://localhost:8000 tmt-web celery --app=src.api.service worker --loglevel=DEBUG
- name: Check container status
run: podman ps -a
- name: Check Celery logs
run: podman logs celery
- name: Check Redis logs
run: podman logs redis
- name: Test inter-container communication
run: |
podman exec web /bin/sh -c "nc -zv redis 6379"
podman exec celery /bin/sh -c "nc -zv redis 6379"
- name: Check environment variables in containers
run: |
echo "Web container environment:"
podman exec web env
echo "Celery container environment:"
podman exec celery env
- name: Try to connect to Redis from Celery
run: |
podman exec celery /bin/sh -c "python -c 'import redis; r = redis.Redis.from_url(\"redis://redis:6379\"); print(r.ping())'"
- name: Test
run: |
pytest