Add the web service implementation #29
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" ] | |
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://$(podman inspect -f '{{.NetworkSettings.IPAddress}}' 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://$(podman inspect -f '{{.NetworkSettings.IPAddress}}' redis):6379 -e API_HOSTNAME=http://localhost:8000 tmt-web celery --app=src.api.service worker --loglevel=INFO | |
- name: Check container status | |
run: podman ps -a | |
- name: Check Celery logs | |
run: podman logs celery | |
- name: Check container IP addresses | |
run: | | |
echo "Redis IP: $(podman inspect -f '{{.NetworkSettings.IPAddress}}' redis)" | |
echo "Web IP: $(podman inspect -f '{{.NetworkSettings.IPAddress}}' web)" | |
echo "Celery IP: $(podman inspect -f '{{.NetworkSettings.IPAddress}}' celery)" | |
- name: Test inter-container communication | |
run: | | |
podman exec web ping -c 4 $(podman inspect -f '{{.NetworkSettings.IPAddress}}' redis) | |
podman exec celery ping -c 4 $(podman inspect -f '{{.NetworkSettings.IPAddress}}' redis) | |
- name: Test | |
run: | | |
pytest |