-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (88 loc) · 3.56 KB
/
e2e-tests.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
102
103
104
105
106
107
name: E2E tests
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
newman-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Create env file
run: |
touch .env
echo API_NAME='github-testing-process-api' >> .env
echo STORAGE_SERVICE='minio' >> .env
echo STORAGE_BUCKET='api-storage' >> .env
echo STORAGE_METADATA_PREFIX='metadata' >> .env
echo STORAGE_RESULTS_PREFIX='results' >> .env
echo STORAGE_LOGS_PREFIX='logs' >> .env
echo PLUGINS_LOAD_DIR='plugins' >> .env
echo PLUGINS_DIR='/.data/plugins' >> .env
echo TMP_JOB_LOGS_DIR='/.data/tmp/logs' >> .env
echo MINIO_ACCESS_KEY_ID=user >> .env
echo MINIO_SECRET_ACCESS_KEY=password >> .env
echo MINIO_S3_ENDPOINT=http://minio:9000 >> .env
echo MINIO_S3_REGION='us-east-1' >> .env
echo MINIO_ROOT_USER=user >> .env
echo MINIO_ROOT_PASSWORD=password >> .env
echo DB_SERVICE='postgres' >> .env
echo POSTGRES_CONN_STRING='postgres://user:password@postgres:5432/db?sslmode=disable' >> .env
echo POSTGRES_PASSWORD='password' >> .env
echo POSTGRES_USER='user' >> .env
echo POSTGRES_DB='db' >> .env
echo PG_LOG_CHECKPOINTS='off' >> .env
echo AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} >> .env
echo AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} >> .env
echo AWS_REGION=${{ secrets.AWS_DEFAULT_REGION }} >> .env
echo BATCH_LOG_STREAM_GROUP='/aws/batch/job' >> .env
- name: Build the test images
run: |
cd plugin-examples
chmod +x build.sh
./build.sh &
- name: Build the docker-compose stack
run: docker-compose -f docker-compose.prod.yml build
- name: Create network
run: docker network create process_api_net
- name: Run the docker-compose stack
run: docker-compose -f docker-compose.prod.yml up -d
- name: Create bucket
run: >
docker run
--network process_api_net
-e MINIO_ROOT_USER=user
-e MINIO_ROOT_PASSWORD=password
-e STORAGE_BUCKET=api-storage
--entrypoint /bin/sh
minio/mc:RELEASE.2023-08-18T21-57-55Z
-c "mc alias set myminio http://minio:9000 \$MINIO_ROOT_USER \$MINIO_ROOT_PASSWORD && mc mb myminio/\${STORAGE_BUCKET}"
- name: Wait for API server to be ready
run: |
attempts=0
max_attempts=12 # This will wait for 2 minutes (10 seconds * 12)
while true; do
if curl -s http://localhost:80; then
echo "API server is ready!"
break
fi
attempts=$((attempts+1))
if [ $attempts -eq $max_attempts ]; then
echo "Max attempts reached. Exiting..."
exit 1
fi
echo "Waiting for API server to be ready. Attempt: $attempts"
sleep 10
done
- name: Run newman tests
run: >
docker run --network="host" -v /home/runner/work/process-api/process-api/tests/e2e:/etc/newman/ postman/newman:5.3.1-alpine run tests.postman_collection.json
--env-var "url=localhost:80" --reporters cli --bail --color on
# # Uncomment to print logs for debugging
# - name: Display docker-compose logs
# run: |
# docker-compose logs
# cat .data/api/logs/api.jsonl
# if: always()