-
Notifications
You must be signed in to change notification settings - Fork 62
56 lines (54 loc) · 2.2 KB
/
docker_pr_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# This will keep the tag:latest up-to-date with all commits and pull requests
name: Test PR for Docker build and run
# Controls when the workflow will run
on:
# Triggers the workflow on pull request events but only for the "master" branch
pull_request:
branches: [ "master" ]
jobs:
test_docker_build:
name: Test docker-compose up with build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run docker compose up
run: docker compose -f docker-compose_build.yml up -d
- name: Check backend container is running
run: |
sleep 30
if [ "$(docker ps | grep 4cat_backend)" ]; then
echo "Docker 4cat_backend container is running..."
else
echo -e "Docker 4cat_backend container is not running...\nPrinting 4cat_backend logs:\n\n$(docker container logs 4cat_backend)"
exit 1
fi
- name: Check frontend container is running
run: |
sleep 10
if [ "$(docker ps | grep 4cat_frontend)" ]; then
echo "Docker 4cat_frontend container is running..."
else
echo -e "Docker 4cat_frontend container is not running...\nPrinting 4cat_frontend logs:\n\n$(docker container logs 4cat_frontend)"
exit 1
fi
- name: Check 4CAT backend log for expected INFO message
run: |
test_case=" INFO at api.py:65: Local API listening for requests at backend:4444"
var=$(docker exec 4cat_backend tail -n 1 logs/backend_4cat.log)
echo "::group::Backend test"
if [ "$(echo "$var" | tr "|" "\n" | sed -n '2p')" = "$test_case" ]; then
echo "4CAT backend running as expected"
else
echo "::error::Backend failed to start"
echo "Test:$test_case"
echo "Log :$(echo "$var" | tr "|" "\n" | sed -n '2p')"
exit 1
fi
echo "::endgroup::"
- name: Print log on failure
if: failure()
run: |
docker cp 4cat_backend:/usr/src/app/logs/backend_4cat.log ./backend_4cat.log
echo "::group::Backend logs"
cat backend_4cat.log
echo "::endgroup::"