TestAdd check for Docker container running status in #33
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: Test Firewalld | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test-firewalld: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: | | |
docker build -t my-firewalld-image -f Dockerfile.firewalld . | |
- name: Run tests | |
run: | | |
# Run the container with systemd initialization | |
docker run -d --privileged -h test --privileged=true --name firewalld-container my-firewalld-image /usr/sbin/init | |
# Wait for the container to be fully initialized | |
sleep 10 | |
# Check if the container is running | |
if [ "$(sudo docker inspect -f '{{.State.Running}}' firewalld-container)" != "true" ]; then | |
echo "Container failed to start. Logs:" | |
sudo docker logs firewalld-container | |
sudo docker inspect firewalld-container | |
exit 1 | |
fi | |
# Run tests inside the container | |
docker exec firewalld-container /bin/bash -c "./firewalld-tests.sh" |