-
Notifications
You must be signed in to change notification settings - Fork 1
361 lines (317 loc) · 12 KB
/
Copy pathmain.yml
File metadata and controls
361 lines (317 loc) · 12 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: Java CI Combined
on:
push:
pull_request:
workflow_dispatch:
inputs:
deploy:
description: 'Deploy to Maven Central'
type: boolean
default: false
lucee-versions:
description: 'JSON array of Lucee versions to test'
default: '["7.0/snapshot/light","7.0/stable/light","6.2/snapshot/light","6.2/stable/light"]'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.VERSION }}
lucee-matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Extract version number
id: extract-version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Set Lucee test matrix
id: set-matrix
run: |
DEFAULT='["7.0/snapshot/light","7.0/stable/light","6.2/snapshot/light","6.2/stable/light"]'
MATRIX="${{ inputs.lucee-versions || '' }}"
if [ -z "$MATRIX" ]; then
MATRIX="$DEFAULT"
fi
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
- name: Cache Lucee files
uses: actions/cache@v5
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads
- name: Import GPG key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Install with Maven
run: |
echo "------- Maven Install -------";
mvn -B -e -f pom.xml clean install
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: websocketclient-lex
path: target/*.lex
test:
runs-on: ubuntu-latest
needs: [setup, build]
strategy:
fail-fast: false
matrix:
lucee: ${{ fromJSON(needs.setup.outputs.lucee-matrix) }}
java: [ 11, 21 ]
steps:
- uses: actions/checkout@v6
- name: Download Artifact
uses: actions/download-artifact@v8
with:
name: websocketclient-lex
path: target
- name: Checkout Lucee
uses: actions/checkout@v6
with:
repository: lucee/lucee
path: lucee
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Run Lucee Test Suite
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/lucee/test
execute: /bootstrap-tests.cfm
luceeVersion: ${{ matrix.lucee }}
extensionDir: ${{ github.workspace }}/target
env:
testLabels: websocketclient
testAdditional: ${{ github.workspace }}/tests
test-integration:
# Runs the integration test suite that lives in the server repo's tests/integration/
# folder against this branch's freshly-built client .lex. Sparse-checkouts only the
# integration subtree so we don't pull the whole server repo.
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
lucee: [ "6.2/stable/jar", "7.0/stable/jar" ]
steps:
- uses: actions/checkout@v6
- name: Determine Tomcat and Java version
id: config
run: |
MAJOR_MINOR=$(echo "${{ matrix.lucee }}" | grep -oE '^[0-9]+\.[0-9]+')
case "$MAJOR_MINOR" in
6.2)
echo "tomcat=tomcat-9" >> $GITHUB_OUTPUT
echo "java=11" >> $GITHUB_OUTPUT
;;
7.0|7.1)
echo "tomcat=tomcat-11" >> $GITHUB_OUTPUT
echo "java=21" >> $GITHUB_OUTPUT
;;
*)
echo "ERROR: Unknown Lucee major version: $MAJOR_MINOR"; exit 1 ;;
esac
- name: Set up JDK ${{ steps.config.outputs.java }}
uses: actions/setup-java@v5
with:
java-version: '${{ steps.config.outputs.java }}'
distribution: 'temurin'
- name: Download this branch's client .lex
uses: actions/download-artifact@v8
with:
name: websocketclient-lex
path: client-lex
- name: Sparse-checkout server tests
uses: actions/checkout@v6
with:
repository: lucee/extension-websocket
path: server-repo
sparse-checkout: |
tests
sparse-checkout-cone-mode: false
- name: Download latest server extension
run: |
# Pull the latest snapshot — follows the same naming convention the server repo uses
curl -L -o server.lex "https://ext.lucee.org/websocket-extension-3.0.0.20-SNAPSHOT.lex"
ls -la server.lex
- name: Download Lucee Express template
run: |
EXPRESS_URL=$(curl -s https://update.lucee.org/rest/update/provider/expressTemplates | jq -r '.["${{ steps.config.outputs.tomcat }}"]')
curl -L -o express-template.zip "$EXPRESS_URL"
unzip -q express-template.zip -d lucee-express
- name: Download Lucee JAR
id: lucee-jar
run: |
LUCEE_URL=$(curl -s "https://update.lucee.org/rest/update/provider/latest/${{ matrix.lucee }}/url" | tr -d '"')
LUCEE_VERSION=$(basename "$LUCEE_URL" | sed 's/lucee-//;s/\.jar//')
echo "LUCEE_VERSION=$LUCEE_VERSION" >> $GITHUB_OUTPUT
curl -L -f -o lucee.jar "$LUCEE_URL"
rm -f lucee-express/lib/lucee-*.jar
cp lucee.jar lucee-express/lib/
- name: Install both extensions into Express
run: |
mkdir -p lucee-express/lucee-server/deploy
cp client-lex/*.lex lucee-express/lucee-server/deploy/
cp server.lex lucee-express/lucee-server/deploy/
ls -la lucee-express/lucee-server/deploy/
- name: Copy listeners and tests from server repo
run: |
mkdir -p lucee-express/lucee-server/context/websockets
find server-repo/tests -path '*/websockets/*.cfc' -exec cp {} lucee-express/lucee-server/context/websockets/ \;
cp -r server-repo/tests lucee-express/webapps/ROOT/
ls -la lucee-express/lucee-server/context/websockets/
- name: Configure Tomcat port
run: sed -i 's/port="8080"/port="8888"/g' lucee-express/conf/server.xml
- name: Start Lucee Express
run: |
cd lucee-express && ./bin/catalina.sh start
- name: Wait for server
run: |
for i in {1..60}; do
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8888/ | grep -q "200\|302\|404"; then
echo "HTTP ready after $i seconds"; break
fi
sleep 1
done
- name: Warm up — wait for websocket extension to finish registering endpoints
run: |
# The extension's Registrar runs on a background thread after Lucee starts —
# if we fire integration tests before it's registered /ws/* endpoints, we get
# 404 during the WebSocket upgrade. Poll test-websocket-info.cfm which returns
# SUCCESS once the extension is loaded and endpoints are registered.
for i in {1..30}; do
RESPONSE=$(curl -s http://localhost:8888/tests/test-websocket-info.cfm)
if echo "$RESPONSE" | grep -q "SUCCESS"; then
echo "Extension ready after $i attempts"
break
fi
sleep 1
done
- name: Run integration tests
id: integration-tests
continue-on-error: true
run: |
FAILED=false
for test in test-websocket-client test-lifecycle-callbacks test-return-value-send test-wsclient-broadcast test-wsclients-plural test-binary-send; do
echo ""
echo "=== Running ${test} ==="
RESPONSE=$(curl -s -w "\n%{http_code}" http://localhost:8888/tests/integration/${test}.cfm)
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')
echo "$BODY"
echo "$BODY" > /tmp/${test}.txt
if [ "$HTTP_CODE" != "200" ] || echo "$BODY" | grep -q "FAILED"; then
echo "${test}: ❌ FAILED"
FAILED=true
else
echo "${test}: ✅ PASSED"
fi
done
if [ "$FAILED" = "true" ]; then
echo "INTEGRATION_FAILED=true" >> $GITHUB_OUTPUT
fi
- name: Dump WebSocket event logs
if: always()
run: |
echo "=== WebSocket Test Event Logs ==="
found=false
for f in /tmp/ws-*-events.log; do
[ -f "$f" ] || continue
found=true
echo ""
echo "--- $f ---"
cat "$f"
done
if [ "$found" = "false" ]; then
echo "(no event logs found)"
fi
- name: Stop Lucee Express
if: always()
run: cd lucee-express && ./bin/shutdown.sh || true
- name: Show catalina.out
if: always()
run: cat lucee-express/logs/catalina.out || echo "No catalina.out found"
- name: Upload logs
if: always()
uses: actions/upload-artifact@v7
with:
name: lucee-logs-${{ steps.lucee-jar.outputs.LUCEE_VERSION }}
path: |
lucee-express/logs/
lucee-express/lucee-server/context/logs/
- name: Fail if integration tests failed
if: steps.integration-tests.outputs.INTEGRATION_FAILED == 'true'
run: exit 1
deploy:
runs-on: ubuntu-latest
needs: [setup, test, test-integration]
if: always() && needs.test.result == 'success' && needs.test-integration.result == 'success' && github.event_name == 'workflow_dispatch' && inputs.deploy
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Import GPG key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Build and Deploy with Maven
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then
echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------";
mvn -B -e -f pom.xml clean deploy --settings maven-settings.xml
else
echo "------- Maven Deploy release on ${{ github.event_name }} -------";
mvn -B -e -f pom.xml clean deploy -DperformRelease=true --settings maven-settings.xml
fi