Skip to content

Commit 9aa664f

Browse files
committed
improve var checks and print logs on failure
1 parent a2d9499 commit 9aa664f

6 files changed

Lines changed: 86 additions & 60 deletions

File tree

.github/workflows/compose.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
lint-actions:
2020
name: Lint GitHub Actions workflows
2121
runs-on: ubuntu-latest
22+
timeout-minutes: 5
2223
steps:
2324
- name: Checkout
2425
uses: actions/checkout@v6
@@ -44,6 +45,7 @@ jobs:
4445
- docker-compose-cass-es.yml
4546
- docker-compose-postgres-opensearch.yml
4647
runs-on: ubuntu-latest
48+
timeout-minutes: 15
4749
steps:
4850
- name: Print build information
4951
env:
@@ -58,6 +60,24 @@ jobs:
5860
working-directory: compose
5961
run: docker compose -f ${{ matrix.compose-file }} up -d
6062

63+
- name: Wait for admin-tools to complete
64+
working-directory: compose
65+
run: |
66+
echo "Waiting up to 3 minutes for admin-tools to complete..."
67+
timeout 180 bash -c 'until [ "$(docker compose -f ${{ matrix.compose-file }} ps temporal-admin-tools --format json | jq -r ".[0].State")" = "exited" ]; do sleep 2; done' || {
68+
echo "Admin-tools failed to complete"
69+
docker compose -f ${{ matrix.compose-file }} logs temporal-admin-tools
70+
exit 1
71+
}
72+
# Check exit code
73+
EXIT_CODE=$(docker compose -f ${{ matrix.compose-file }} ps temporal-admin-tools --format json | jq -r ".[0].ExitCode")
74+
if [ "$EXIT_CODE" != "0" ]; then
75+
echo "Admin-tools exited with code $EXIT_CODE"
76+
docker compose -f ${{ matrix.compose-file }} logs temporal-admin-tools
77+
exit 1
78+
fi
79+
echo "Admin-tools completed successfully"
80+
6181
- name: Wait for services to be healthy
6282
working-directory: compose
6383
run: |
@@ -105,6 +125,7 @@ jobs:
105125
name: Test docker-compose-tls.yml
106126
needs: lint-actions
107127
runs-on: ubuntu-latest
128+
timeout-minutes: 20
108129
steps:
109130
- name: Print build information
110131
env:
@@ -129,6 +150,24 @@ jobs:
129150
working-directory: compose
130151
run: COMPOSE_PROJECT_NAME=tls_test docker compose -f docker-compose-tls.yml up -d
131152

153+
- name: Wait for admin-tools-setup to complete
154+
working-directory: compose
155+
run: |
156+
echo "Waiting up to 3 minutes for admin-tools-setup to complete..."
157+
timeout 180 bash -c 'until [ "$(COMPOSE_PROJECT_NAME=tls_test docker compose -f docker-compose-tls.yml ps temporal-admin-tools-setup --format json | jq -r ".[0].State")" = "exited" ]; do sleep 2; done' || {
158+
echo "Admin-tools-setup failed to complete"
159+
COMPOSE_PROJECT_NAME=tls_test docker compose -f docker-compose-tls.yml logs temporal-admin-tools-setup
160+
exit 1
161+
}
162+
# Check exit code
163+
EXIT_CODE=$(COMPOSE_PROJECT_NAME=tls_test docker compose -f docker-compose-tls.yml ps temporal-admin-tools-setup --format json | jq -r ".[0].ExitCode")
164+
if [ "$EXIT_CODE" != "0" ]; then
165+
echo "Admin-tools-setup exited with code $EXIT_CODE"
166+
COMPOSE_PROJECT_NAME=tls_test docker compose -f docker-compose-tls.yml logs temporal-admin-tools-setup
167+
exit 1
168+
fi
169+
echo "Admin-tools-setup completed successfully"
170+
132171
- name: Wait for services to be healthy
133172
working-directory: compose
134173
run: |
@@ -170,6 +209,7 @@ jobs:
170209
name: Test docker-compose-multirole.yaml
171210
needs: lint-actions
172211
runs-on: ubuntu-latest
212+
timeout-minutes: 20
173213
steps:
174214
- name: Print build information
175215
env:
@@ -186,6 +226,24 @@ jobs:
186226
working-directory: compose
187227
run: docker compose -f docker-compose-multirole.yaml up -d
188228

229+
- name: Wait for setup to complete
230+
working-directory: compose
231+
run: |
232+
echo "Waiting up to 3 minutes for setup to complete..."
233+
timeout 180 bash -c 'until [ "$(docker compose -f docker-compose-multirole.yaml ps temporal-setup --format json | jq -r ".[0].State")" = "exited" ]; do sleep 2; done' || {
234+
echo "Setup failed to complete"
235+
docker compose -f docker-compose-multirole.yaml logs temporal-setup
236+
exit 1
237+
}
238+
# Check exit code
239+
EXIT_CODE=$(docker compose -f docker-compose-multirole.yaml ps temporal-setup --format json | jq -r ".[0].ExitCode")
240+
if [ "$EXIT_CODE" != "0" ]; then
241+
echo "Setup exited with code $EXIT_CODE"
242+
docker compose -f docker-compose-multirole.yaml logs temporal-setup
243+
exit 1
244+
fi
245+
echo "Setup completed successfully"
246+
189247
- name: Wait for services to be healthy
190248
working-directory: compose
191249
run: |

compose/scripts/setup-cassandra-es.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
set -eu
33

44
# Validate required environment variables
5-
required_vars="ES_SCHEME ES_HOST ES_PORT ES_VISIBILITY_INDEX ES_VERSION"
6-
missing_vars=""
7-
for var in $required_vars; do
8-
eval value=\$$var
9-
if [ -z "${value:-}" ]; then
10-
missing_vars="$missing_vars $var"
11-
fi
12-
done
13-
if [ -n "$missing_vars" ]; then
14-
echo "ERROR: Missing required environment variables:$missing_vars"
15-
exit 1
16-
fi
5+
: "${ES_SCHEME:?ERROR: ES_SCHEME environment variable is required}"
6+
: "${ES_HOST:?ERROR: ES_HOST environment variable is required}"
7+
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
8+
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
9+
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
1710

1811
echo 'Starting Cassandra and Elasticsearch schema setup...'
1912
echo 'Waiting for Cassandra port to be available...'

compose/scripts/setup-mysql-es.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
set -eu
33

44
# Validate required environment variables
5-
required_vars="ES_SCHEME ES_HOST ES_PORT ES_VISIBILITY_INDEX ES_VERSION"
6-
missing_vars=""
7-
for var in $required_vars; do
8-
eval value=\$$var
9-
if [ -z "${value:-}" ]; then
10-
missing_vars="$missing_vars $var"
11-
fi
12-
done
13-
if [ -n "$missing_vars" ]; then
14-
echo "ERROR: Missing required environment variables:$missing_vars"
15-
exit 1
16-
fi
5+
: "${ES_SCHEME:?ERROR: ES_SCHEME environment variable is required}"
6+
: "${ES_HOST:?ERROR: ES_HOST environment variable is required}"
7+
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
8+
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
9+
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
1710

1811
echo 'Starting MySQL and Elasticsearch schema setup...'
1912
echo 'Waiting for MySQL port to be available...'

compose/scripts/setup-postgres-es-tls.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
set -eu
33

44
# Validate required environment variables
5-
required_vars="ES_SCHEME ES_HOST ES_PORT ES_VISIBILITY_INDEX ES_VERSION ES_USER ES_PWD POSTGRES_USER"
6-
missing_vars=""
7-
for var in $required_vars; do
8-
eval value=\$$var
9-
if [ -z "${value:-}" ]; then
10-
missing_vars="$missing_vars $var"
11-
fi
12-
done
13-
if [ -n "$missing_vars" ]; then
14-
echo "ERROR: Missing required environment variables:$missing_vars"
15-
exit 1
16-
fi
5+
: "${ES_SCHEME:?ERROR: ES_SCHEME environment variable is required}"
6+
: "${ES_HOST:?ERROR: ES_HOST environment variable is required}"
7+
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
8+
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
9+
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
10+
: "${ES_USER:?ERROR: ES_USER environment variable is required}"
11+
: "${ES_PWD:?ERROR: ES_PWD environment variable is required}"
12+
: "${POSTGRES_USER:?ERROR: POSTGRES_USER environment variable is required}"
1713

1814
echo 'Starting PostgreSQL and Elasticsearch (TLS) schema setup...'
1915
echo 'Waiting for PostgreSQL port to be available...'

compose/scripts/setup-postgres-es.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
set -eu
33

44
# Validate required environment variables
5-
required_vars="ES_SCHEME ES_HOST ES_PORT ES_VISIBILITY_INDEX ES_VERSION"
6-
missing_vars=""
7-
for var in $required_vars; do
8-
eval value=\$$var
9-
if [ -z "${value:-}" ]; then
10-
missing_vars="$missing_vars $var"
11-
fi
12-
done
13-
if [ -n "$missing_vars" ]; then
14-
echo "ERROR: Missing required environment variables:$missing_vars"
15-
exit 1
16-
fi
5+
: "${ES_SCHEME:?ERROR: ES_SCHEME environment variable is required}"
6+
: "${ES_HOST:?ERROR: ES_HOST environment variable is required}"
7+
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
8+
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
9+
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
1710

1811
echo 'Starting PostgreSQL and Elasticsearch schema setup...'
1912
echo 'Waiting for PostgreSQL port to be available...'

compose/scripts/setup-postgres-opensearch.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
set -eu
33

44
# Validate required environment variables
5-
required_vars="ES_SCHEME ES_HOST ES_PORT ES_VISIBILITY_INDEX ES_VERSION"
6-
missing_vars=""
7-
for var in $required_vars; do
8-
eval value=\$$var
9-
if [ -z "${value:-}" ]; then
10-
missing_vars="$missing_vars $var"
11-
fi
12-
done
13-
if [ -n "$missing_vars" ]; then
14-
echo "ERROR: Missing required environment variables:$missing_vars"
15-
exit 1
16-
fi
5+
: "${ES_SCHEME:?ERROR: ES_SCHEME environment variable is required}"
6+
: "${ES_HOST:?ERROR: ES_HOST environment variable is required}"
7+
: "${ES_PORT:?ERROR: ES_PORT environment variable is required}"
8+
: "${ES_VISIBILITY_INDEX:?ERROR: ES_VISIBILITY_INDEX environment variable is required}"
9+
: "${ES_VERSION:?ERROR: ES_VERSION environment variable is required}"
1710

1811
echo 'Starting PostgreSQL and OpenSearch schema setup...'
1912
echo 'Waiting for PostgreSQL port to be available...'

0 commit comments

Comments
 (0)