Skip to content

Commit 14e9833

Browse files
committed
ci: Support multiple docker-compose tests.
1 parent 1ac73c2 commit 14e9833

File tree

7 files changed

+109
-4
lines changed

7 files changed

+109
-4
lines changed

.github/workflows/dockerfile.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,30 @@ jobs:
156156
kubectl -n "$namespace" logs "$pod"
157157
kubectl -n "$namespace" exec "$pod" -c zulip -- cat /var/log/zulip/errors.log
158158
159+
docker-compose-collect:
160+
runs-on: ubuntu-latest
161+
outputs:
162+
dirs: ${{ steps.dirs.outputs.dirs }}
163+
steps:
164+
- name: Checkout code
165+
uses: actions/checkout@v5
166+
167+
- id: dirs
168+
run: |
169+
echo -n "dirs=" >> ${GITHUB_OUTPUT}
170+
ls -d ci/*/ | jq --raw-input --slurp --compact-output 'split("\n")[:-1]' >> ${GITHUB_OUTPUT}
171+
159172
docker-compose-test:
160173
runs-on: ubuntu-latest
161174
timeout-minutes: 10
162175
needs:
163176
- build
177+
- docker-compose-collect
164178
env:
165179
GITHUB_CI_IMAGE: ghcr.io/${{ github.repository }}:pr-${{ github.event.pull_request.number }}
180+
strategy:
181+
matrix:
182+
dir: ${{ fromJson(needs.docker-compose-collect.outputs.dirs) }}
166183
steps:
167184
- name: Checkout code
168185
uses: actions/checkout@v5
@@ -174,8 +191,8 @@ jobs:
174191
run: |
175192
docker compose \
176193
-f compose.yaml \
177-
-f ci/compose.override.yaml \
178-
--env-file ci/env \
194+
-f ${{ matrix.dir }}/compose.override.yaml \
195+
--env-file ${{ matrix.dir }}/env \
179196
config
180197
181198
- name: Log in to GHCR
@@ -189,8 +206,8 @@ jobs:
189206
run: |
190207
docker compose \
191208
-f compose.yaml \
192-
-f ci/compose.override.yaml \
193-
--env-file ci/env \
209+
-f ${{ matrix.dir }}/compose.override.yaml \
210+
--env-file ${{ matrix.dir }}/env \
194211
up -d --no-build
195212
196213
- name: Wait for services to be healthy
@@ -207,6 +224,10 @@ jobs:
207224
exit 1
208225
fi
209226
227+
- name: Run tests
228+
run: |
229+
${{ matrix.dir }}/test.sh localhost docker compose exec -u zulip zulip \
230+
/home/zulip/deployments/current/manage.py
210231
- name: Check service logs for critical errors
211232
if: success() || failure()
212233
continue-on-error: true
File renamed without changes.
File renamed without changes.

ci/basic/test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
set -o pipefail
5+
6+
hostname="$1"
7+
shift
8+
manage=("$@")
9+
10+
"${manage[@]}" create_realm 'Testing Realm' [email protected] 'Test Admin' --password very-secret
11+
12+
url="https://$hostname"
13+
curl --insecure -si "$url"
14+
15+
curl -si "http://$hostname" 2>&1 | grep -i "location: $url"
16+
curl --insecure -si "$url" 2>&1 | grep -i "location: /login/"
17+
curl --insecure -sL "$url" | grep "Testing Realm"
18+
19+
api_key=$(curl --insecure -sSX POST "$url/api/v1/fetch_api_key" \
20+
--data-urlencode [email protected] \
21+
--data-urlencode password=very-secret | jq -r .api_key)
22+
23+
registered=$(curl --insecure -sSX POST "$url/api/v1/register" \
24+
-u "[email protected]:$api_key" \
25+
--data-urlencode 'event_types=["message"]')
26+
27+
queue_id=$(echo "$registered" | jq -r .queue_id)
28+
last_event_id=$(echo "$registered" | jq -r .last_event_id)
29+
30+
curl --insecure -sSX POST "$url/api/v1/messages" \
31+
-u "[email protected]:$api_key" \
32+
--data-urlencode type=stream \
33+
--data-urlencode 'to="general"' \
34+
--data-urlencode topic=end-to-end \
35+
--data-urlencode 'content=This is a piping hot test message.'
36+
37+
queue=$(curl --insecure -sSX GET -G "$url/api/v1/events" \
38+
-u "[email protected]:$api_key" \
39+
--data-urlencode "queue_id=$queue_id" \
40+
--data-urlencode "last_event_id=$last_event_id")
41+
42+
echo "$queue" | jq -r '.events[] | .message.content' | grep "This is a piping hot test message."
43+
44+
exit 0

ci/http-only/compose.override.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
secrets:
3+
zulip__postgres_password:
4+
environment: "ZULIP__POSTGRES_PASSWORD"
5+
zulip__memcached_password:
6+
environment: "ZULIP__MEMCACHED_PASSWORD"
7+
zulip__rabbitmq_password:
8+
environment: "ZULIP__RABBITMQ_PASSWORD"
9+
zulip__redis_password:
10+
environment: "ZULIP__REDIS_PASSWORD"
11+
zulip__secret_key:
12+
environment: "ZULIP__SECRET_KEY"
13+
zulip__email_password:
14+
environment: "ZULIP__EMAIL_PASSWORD"
15+
16+
services:
17+
zulip:
18+
image: "${GITHUB_CI_IMAGE:?error}"
19+
environment:
20+
SETTING_EXTERNAL_HOST: "zulip.example.net"
21+
SETTING_ZULIP_ADMINISTRATOR: "[email protected]"
22+
DISABLE_HTTPS: True

ci/http-only/env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../basic/env

ci/http-only/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
set -o pipefail
5+
6+
hostname="$1"
7+
shift
8+
manage=("$@")
9+
10+
"${manage[@]}" create_realm 'Testing Realm' [email protected] 'Test Admin' --password very-secret
11+
12+
url="http://$hostname"
13+
curl -si "$url"
14+
curl -si "$url" 2>&1 | grep -i "location: /login/"
15+
curl --insecure -sL "$url" | grep "Testing Realm"
16+
17+
exit 0

0 commit comments

Comments
 (0)