Skip to content

Add the web service implementation #42

Add the web service implementation

Add the web service implementation #42

Workflow file for this run

name: Run tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Podman and Buildah
run: |
sudo apt-get update
sudo apt-get install -y podman buildah
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12' # Matching Containerfile
- name: Install pytest
run: |
python -m pip install pytest
python -m pip install -r src/requirements.txt
- name: Build the web image
run: |
buildah bud -t tmt-web:latest .
# `--build-arg PYTHON_VERSION=${{ matrix.python-version }}` if needed
- name: Create Podman pod
run: |
podman pod create --name tmt-web-pod -p 8000:8000 || true
# I don't even know, now it threw "docker://k8s.gcr.io/pause:3.5: Requesting bear token: invalid status code from registry 404"
- name: Start Redis container
run: |
podman run -d --pod tmt-web-pod --name redis redis:latest
- name: Start Celery container
run: |
podman run -d --pod tmt-web-pod --name celery \
-e REDIS_URL=redis://redis:6379 \
-e API_HOSTNAME=http://localhost:8000 \
tmt-web:latest celery --app=src.api.service worker --loglevel=INFO
- name: Start Web container
run: |
podman run -d --pod tmt-web-pod --name web \
-e REDIS_URL=redis://redis:6379 \
-e API_HOSTNAME=http://localhost:8000 \
tmt-web:latest uvicorn src.api:app --reload --host 0.0.0.0 --port 8000
- name: Wait for services to be ready
run: |
sleep 20 # Simple wait; could be replaced with health checks
- name: Run tests
run: |
python -m pytest
- name: Cleanup
if: always()
run: |
podman pod stop tmt-web-pod
podman pod rm tmt-web-pod