Skip to content

Commit 17f9e93

Browse files
committed
try better zulip provisioning
1 parent f504f12 commit 17f9e93

File tree

2 files changed

+183
-70
lines changed

2 files changed

+183
-70
lines changed

.github/workflows/integration-tests.yml

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
integration:
1212
name: Go tests against Zulip ${{ matrix.zulip-branch }}
1313
runs-on: arc-runner-set
14+
container: zulip/ci:jammy
1415
strategy:
1516
matrix:
1617
zulip-branch:
@@ -31,11 +32,6 @@ jobs:
3132
uses: actions/setup-go@v5
3233
with:
3334
go-version: "1.25.2"
34-
# On self-hosted runners, GOMODCACHE and GOCACHE persist across jobs.
35-
# Disable setup-go's dependency cache restore to avoid slow tar extraction
36-
# and "Cannot open: File exists" messages when files already exist.
37-
cache: false
38-
3935
- name: Install Go tools (goimports, staticcheck)
4036
run: |
4137
set -euo pipefail
@@ -70,52 +66,21 @@ jobs:
7066
exit 1
7167
fi
7268
73-
- name: Run go vet
74-
run: go vet ./...
75-
76-
- name: Run staticcheck
69+
- name: Lint & build
7770
run: |
78-
"$(go env GOPATH)"/bin/staticcheck ./...
71+
go build ./...
72+
go vet ./...
73+
go run golang.org/x/tools/cmd/goimports@latest -w ./...
74+
go run honnef.co/go/tools/cmd/staticcheck@2025.1.1 ./...
7975
8076
- name: Run fast model/unit tests
8177
run: ./scripts/run-model-tests.sh
8278

83-
- name: Build go-zulip
84-
run: go build ./...
85-
86-
- name: Check Python version
87-
run: |
88-
python3_version=$(python3 --version | awk '{print $2}')
89-
major_minor=$(echo $python3_version | cut -d. -f1-2)
90-
required_version="3.10"
91-
92-
if [ "$(printf '%s\n' "$required_version" "$major_minor" | sort -V | head -n1)" = "$required_version" ]; then
93-
echo "✓ Python version $python3_version is >= 3.10"
94-
else
95-
echo "✗ Python version $python3_version is < 3.10 (required: >= 3.10)"
96-
exit 1
97-
fi
98-
99-
- name: Start Zulip dev server via script
100-
run: |
101-
# Start the dev server using the helper script and capture logs/PID
102-
mkdir tmp
103-
nohup bash -lc "TMPDIR=$(pwd)/tmp ./scripts/run-dev-zerver.sh --ref '${{ matrix.zulip-branch }}'" >"${ZULIP_DEV_LOG}" 2>&1 &
104-
echo $! > /tmp/zulip-dev-${{ github.run_id }}.pid
105-
106-
- name: Wait for Zulip dev server to become ready
107-
run: |
108-
echo "Waiting for Zulip server at ${ZULIP_TEST_SITE}"
109-
for attempt in {1..60}; do
110-
if curl --get --silent --show-error --fail "${ZULIP_TEST_SITE}/api/v1/server_settings" >/dev/null; then
111-
echo "Zulip is up"
112-
exit 0
113-
fi
114-
echo "Attempt ${attempt}: Zulip not ready yet"
115-
sleep 25
116-
done
117-
echo "Zulip server failed to start" >&2
118-
exit 1
79+
- name: Start Zulip
80+
uses: tum-zulip/go-zulip/.github/workflows/zulip-provision.yml@main
81+
with:
82+
zulip_ref: ${{ matrix.zulip_ref }}
83+
wait_timeout_seconds: "900"
11984

12085
- name: Run go test suite with coverage
12186
env:
@@ -134,29 +99,6 @@ jobs:
13499
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
135100
ZULIP_BRANCH: ${{ matrix.zulip-branch }}
136101

137-
- name: Show Zulip server logs on failure
138-
if: failure()
139-
run: |
140-
echo "===== zulip-dev.log ====="
141-
cat "${ZULIP_DEV_LOG}" || true
142-
143-
- name: Upload Zulip server log
144-
if: always()
145-
uses: actions/upload-artifact@v4
146-
with:
147-
name: zulip-dev-log-${{ matrix.zulip-branch }}
148-
path: ${{ env.ZULIP_DEV_LOG }}
149-
if-no-files-found: ignore
150-
151-
- name: Stop Zulip dev server
152-
if: always()
153-
run: |
154-
if [ -f /tmp/zulip-dev-${{ github.run_id }}.pid ]; then
155-
sudo kill "$(cat /tmp/zulip-dev-${{ github.run_id }}.pid)" || true
156-
fi
157-
# Fallback in case the PID file isn't sufficient
158-
sudo pkill -f "tools/run-dev" || true
159-
160102
godoc:
161103
name: Generate godoc HTML
162104
runs-on: arc-runner-set
@@ -169,7 +111,6 @@ jobs:
169111
uses: actions/setup-go@v5
170112
with:
171113
go-version: "1.25.2"
172-
cache: false
173114

174115
- name: Generate godoc
175116
run: |
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Provision Zulip Dev Server
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
zulip_ref:
7+
description: "Git ref (branch/tag/commit) for zulip/zulip"
8+
required: false
9+
default: "main"
10+
type: string
11+
zulip_repo:
12+
description: "Repository to checkout Zulip from"
13+
required: false
14+
default: "zulip/zulip"
15+
type: string
16+
wait_timeout_seconds:
17+
description: "How long to wait for Zulip to become ready"
18+
required: false
19+
default: "600"
20+
type: string
21+
# Cache ‘epoch’ knobs—bump these to bust cache when needed:
22+
cache_epoch_pnpm:
23+
description: "Epoch for pnpm store cache"
24+
required: false
25+
default: "v1"
26+
type: string
27+
cache_epoch_uv:
28+
description: "Epoch for uv cache"
29+
required: false
30+
default: "v1"
31+
type: string
32+
cache_epoch_emoji:
33+
description: "Epoch for emoji cache"
34+
required: false
35+
default: "v1"
36+
type: string
37+
38+
outputs:
39+
site_url:
40+
description: "URL to the running Zulip server"
41+
value: ${{ jobs.provision.outputs.site_url }}
42+
log_path:
43+
description: "Path of the Zulip log file on runner"
44+
value: ${{ jobs.provision.outputs.log_path }}
45+
46+
permissions:
47+
contents: read
48+
49+
jobs:
50+
provision:
51+
name: Provision Zulip (${{ inputs.mode }}) @ ${{ inputs.zulip_ref }}
52+
runs-on: ubuntu-latest
53+
timeout-minutes: 90
54+
55+
env:
56+
ZULIP_PORT: 9991
57+
ZULIP_URL: http://localhost:9991
58+
ZULIP_DEV_LOG: ${{ runner.temp }}/zulip-dev.log
59+
ZULIP_RUN_PID: ${{ runner.temp }}/zulip-dev.pid
60+
# Matches Zulip CI cache locations:
61+
PNPM_STORE_PATH: /__w/.pnpm-store
62+
UV_CACHE_DIR: ~/.cache/uv
63+
EMOJI_CACHE_DIR: /srv/zulip-emoji-cache
64+
65+
outputs:
66+
site_url: ${{ steps.outputs-step.outputs.site_url }}
67+
log_path: ${{ steps.outputs-step.outputs.log_path }}
68+
69+
steps:
70+
- name: Checkout Zulip (ref ${{ inputs.zulip_ref }})
71+
uses: actions/checkout@v4
72+
with:
73+
repository: ${{ inputs.zulip_repo }}
74+
ref: ${{ inputs.zulip_ref }}
75+
path: zulip
76+
77+
- name: Create cache directories
78+
run: |
79+
sudo mkdir -p "${EMOJI_CACHE_DIR}"
80+
sudo chown -R $USER "${EMOJI_CACHE_DIR}"
81+
mkdir -p "${PNPM_STORE_PATH}"
82+
83+
- name: Restore pnpm store cache
84+
uses: actions/cache@v4
85+
with:
86+
path: ${{ env.PNPM_STORE_PATH }}
87+
key: ${{ inputs.cache_epoch_pnpm }}-pnpm-${{ inputs.zulip_ref }}-${{ hashFiles('zulip/pnpm-lock.yaml') }}
88+
restore-keys: |
89+
${{ inputs.cache_epoch_pnpm }}-pnpm-${{ inputs.zulip_ref }}-
90+
${{ inputs.cache_epoch_pnpm }}-pnpm-
91+
92+
- name: Restore uv cache
93+
uses: actions/cache@v4
94+
with:
95+
path: ${{ env.UV_CACHE_DIR }}
96+
key: ${{ inputs.cache_epoch_uv }}-uv-${{ inputs.zulip_ref }}-${{ hashFiles('zulip/uv.lock') }}
97+
restore-keys: |
98+
${{ inputs.cache_epoch_uv }}-uv-${{ inputs.zulip_ref }}-
99+
${{ inputs.cache_epoch_uv }}-uv-
100+
101+
- name: Restore emoji cache
102+
uses: actions/cache@v4
103+
with:
104+
path: ${{ env.EMOJI_CACHE_DIR }}
105+
key: ${{ inputs.cache_epoch_emoji }}-emoji-${{ inputs.zulip_ref }}-${{ hashFiles('zulip/tools/setup/emoji/emoji_map.json', 'zulip/tools/setup/emoji/build_emoji', 'zulip/tools/setup/emoji/emoji_setup_utils.py', 'zulip/tools/setup/emoji/emoji_names.py', 'zulip/package.json') }}
106+
restore-keys: |
107+
${{ inputs.cache_epoch_emoji }}-emoji-${{ inputs.zulip_ref }}-
108+
${{ inputs.cache_epoch_emoji }}-emoji-
109+
110+
- name: Provision
111+
working-directory: zulip
112+
run: |
113+
set -euxo pipefail
114+
# Ensure pnpm store path the same as in Zulip CI
115+
export PNPM_HOME="${PNPM_STORE_PATH}"
116+
# Provision installs OS deps (via sudo), node, uv env, etc.
117+
./tools/provision
118+
119+
- name: Start Zulip
120+
working-directory: zulip
121+
run: |
122+
set -euxo pipefail
123+
source ./tools/ci/activate-venv
124+
# Start in background and capture PID
125+
nohup ./tools/run-dev >"${ZULIP_DEV_LOG}" 2>&1 &
126+
echo $! > "${ZULIP_RUN_PID}"
127+
128+
- name: Wait for Zulip to be ready
129+
shell: bash
130+
run: |
131+
set -euo pipefail
132+
echo "Waiting for Zulip at ${ZULIP_URL}"
133+
deadline=$(( $(date +%s) + ${{ inputs.wait_timeout_seconds }} ))
134+
until curl --get --silent --fail "${ZULIP_URL}/api/v1/server_settings" >/dev/null; do
135+
if [ "$(date +%s)" -gt "$deadline" ]; then
136+
echo "Zulip did not become ready within timeout." >&2
137+
echo "=== Tail of log ===" >&2
138+
tail -n 200 "${ZULIP_DEV_LOG}" || true
139+
exit 1
140+
fi
141+
sleep 2
142+
done
143+
echo "Zulip is up."
144+
145+
- name: Export outputs
146+
id: outputs-step
147+
run: |
148+
echo "site_url=${ZULIP_URL}" >> "$GITHUB_OUTPUT"
149+
echo "log_path=${ZULIP_DEV_LOG}" >> "$GITHUB_OUTPUT"
150+
151+
- name: Upload Zulip log
152+
if: always()
153+
uses: actions/upload-artifact@v4
154+
with:
155+
name: zulip-log-${{ inputs.mode }}-${{ inputs.zulip_ref }}
156+
path: ${{ env.ZULIP_DEV_LOG }}
157+
if-no-files-found: ignore
158+
retention-days: 7
159+
160+
- name: Show log on failure
161+
if: failure()
162+
run: |
163+
echo "===== zulip-dev.log ====="
164+
tail -n +1 "${ZULIP_DEV_LOG}" || true
165+
166+
- name: Stop Zulip
167+
if: always()
168+
run: |
169+
if [ -f "${ZULIP_RUN_PID}" ]; then
170+
kill "$(cat "${ZULIP_RUN_PID}")" || true
171+
fi
172+
pkill -f "tools/run-dev" || true

0 commit comments

Comments
 (0)