Run Tests on Pull Request #4
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 Pull Request | |
on: | |
pull_request: | |
branches: | |
- '**' | |
workflow_dispatch: # Manual trigger | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Install Docker Compose (if necessary) | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
# Navigate to the directory containing the docker-compose-testing.yml | |
- name: Navigate to Docker Testing Directory | |
run: | | |
cd docker/_testing | |
# Start the Python container to build the dist file first | |
- name: Build dist file in Python container | |
run: | | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml up -d python_app | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec python_app sh -c "pyinstaller server.spec && ls /tmp/dist" | |
# Start all other containers after the dist is generated | |
- name: Start the rest of the containers | |
run: | | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml up -d ubuntu_server centos_server debian_server fedora_server arch_server | |
# Check if the dist file exists in all containers | |
- name: Verify dist file in all containers | |
run: | | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec ubuntu_server ls /tmp/dist | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec centos_server ls /tmp/dist | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec debian_server ls /tmp/dist | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec fedora_server ls /tmp/dist | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec arch_server ls /tmp/dist | |
# Run pytest in the python_app container | |
- name: Run Pytest | |
run: | | |
sudo docker-compose -f docker/_testing/docker-compose-testing.yml exec python_app pytest |