-
Notifications
You must be signed in to change notification settings - Fork 782
101 lines (86 loc) · 3.05 KB
/
test-pr-e2e-build-and-run.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build and up (E2E)
on:
workflow_dispatch:
pull_request:
paths:
- 'keep/**'
- 'keep-ui/**'
- 'tests/**'
env:
PYTHON_VERSION: 3.11
STORAGE_MANAGER_DIRECTORY: /tmp/storage-manager
# MySQL server environment variables
MYSQL_ROOT_PASSWORD: keep
MYSQL_DATABASE: keep
# Postgres environment variables
POSTGRES_USER: keepuser
POSTGRES_PASSWORD: keeppassword
POSTGRES_DB: keepdb
# To test if imports are working properly
EE_ENABLED: true
jobs:
tests-e2e:
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
with:
src: "./keep"
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Bake Docker images
uses: depot/bake-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
project: ${{ secrets.DEPOT_PROJECT }}
workdir: .
files: |
tests/e2e_tests/docker-compose-e2e-mysql.yml
load: true
- name: Set up Keep environment
run: |
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose \
--project-directory . \
-f tests/e2e_tests/docker-compose-e2e-mysql.yml up -d
- name: Wait for services to be ready
run: |
# Add commands to wait for the database to be ready
until docker exec $(docker ps -qf "name=keep-database") mysqladmin ping -h "localhost" --silent; do
echo "Waiting for MySQL to be ready..."
sleep 2
done
# wait to keep backend on port 8080
echo "Waiting for Keep backend to be ready..."
attempt=0
max_attempts=10
until $(curl --output /dev/null --silent --fail http://localhost:8080/healthcheck); do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting... Sometimes Keep can't start because of double-headed migrations, use: 'alembic -c keep/alembic.ini history' to investigate, or check artifacts."
exit 1
fi
echo "Waiting for Keep backend to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 2
done
echo "Keep backend is ready!"
# wait to the backend
echo "Waiting for Keep frontend to be ready..."
attempt=0
max_attempts=10
until $(curl --output /dev/null --silent --fail http://localhost:3000/); do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting..."
exit 1
fi
echo "Waiting for Keep frontend to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 2
done
# create the state directory
# mkdir -p ./state && chown -R root:root ./state && chmod -R 777 ./state