Create separate test workflow for docker

This expands on the current testing suite a bit by introducing a new
workflow for testing functionality within the docker container. It runs
the same test suite as the regular "test" workflow, but also performs a
health check after running the app for 10 seconds to ensure
functionality.

The buildx workflow now waits for the docker test script to finish
successfully, rather than the regular test workflow. This will hopefully
avoid situations where new images are pushed with issues that aren't
detected in regular testing of the app.
This commit is contained in:
Ben Busby
2021-11-22 00:26:25 -07:00
parent 6f5f3d8ca7
commit 5a27d748d1
3 changed files with 28 additions and 10 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ name: buildx
on:
workflow_run:
workflows: ["tests"]
workflows: ["docker_tests"]
branches: [main]
types:
- completed
+19
View File
@@ -0,0 +1,19 @@
name: docker_tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: build and test
run: |
docker build --tag whoogle-search:test .
TEST_CONTAINER=$(docker run --entrypoint=/bin/bash --detach whoogle-search:test)
docker cp test "$TEST_CONTAINER":/whoogle/test
docker exec "$TEST_CONTAINER" ./run test
docker exec --detach "$TEST_CONTAINER" ./run
sleep 10
docker exec "$TEST_CONTAINER" curl -f http://localhost:5000/healthz || exit 1