Ubuntu Testing #2
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: Ubuntu Workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
ubuntu-test: | |
runs-on: ubuntu-latest | |
services: | |
python_app: | |
image: python:3.9-slim | |
volumes: | |
- ./dist:/app/dist | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
# Step 1: Build Python app and create dist file | |
- name: Build Python App and Create Dist | |
run: | | |
docker build -t python-app -f docker/_testing/python_app.Dockerfile . | |
docker run --rm -v $PWD/dist:/app/dist python-app | |
# Step 2: Copy dist file to the Ubuntu container and serve it | |
- name: Build and Serve on Ubuntu | |
run: | | |
docker build -t ubuntu-server -f docker/_testing/ubuntu.Dockerfile . | |
docker run --rm -v $PWD/dist:/app/dist ubuntu-server /app/dist/server & | |
sleep 5 # wait for the server to start | |
# Step 3: Run pytest in Python container to test the server | |
- name: Run pytest | |
run: | | |
docker exec python_app pytest /app/tests |