Skip to content

Commit 1990e36

Browse files
committed
refactor: rename java-spring -> java-server
1 parent 015ac8c commit 1990e36

36 files changed

+307
-348
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/dotnet-tui/ @busec0 @kristopherjohnson
1616
/dotnet-winforms/ @busec0 @kristopherjohnson
1717
/flutter_app/ @pvditto @teodorciuraru
18-
/java-spring/ @phatblat @busec0
18+
/java-server/ @phatblat @busec0
1919
/javascript-tui/ @konstantinbe @pvditto @teodorciuraru
2020
/javascript-web/ @konstantinbe @pvditto @teodorciuraru
2121
/kotlin-multiplatform/ @busec0 @phatblat
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
#
2+
# .github/workflows/java-server-ci.yml
3+
# Workflow for building and testing java-server with BrowserStack integration
4+
#
5+
---
6+
name: Java Server CI
7+
8+
on:
9+
push:
10+
branches: [main]
11+
paths:
12+
- "java-server/**"
13+
- ".github/workflows/java-server-ci.yml"
14+
pull_request:
15+
branches: [main]
16+
paths:
17+
- "java-server/**"
18+
- ".github/workflows/java-server-ci.yml"
19+
workflow_dispatch:
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
lint:
27+
name: Lint (ubuntu-latest)
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Setup Java
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: "temurin"
38+
java-version: "17"
39+
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@v3
42+
43+
- name: Create .env file (root)
44+
run: |
45+
echo "DITTO_APP_ID=${{ secrets.DITTO_APP_ID }}" > .env
46+
echo "DITTO_PLAYGROUND_TOKEN=${{ secrets.DITTO_PLAYGROUND_TOKEN }}" >> .env
47+
echo "DITTO_AUTH_URL=${{ secrets.DITTO_AUTH_URL }}" >> .env
48+
echo "DITTO_WEBSOCKET_URL=${{ secrets.DITTO_WEBSOCKET_URL }}" >> .env
49+
50+
- name: Run linter (PMD + SpotBugs)
51+
working-directory: java-server
52+
run: ./gradlew pmdMain pmdTest spotbugsMain
53+
54+
build:
55+
name: Build (ubuntu-latest)
56+
runs-on: ubuntu-latest
57+
needs: lint
58+
timeout-minutes: 20
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Setup Java
64+
uses: actions/setup-java@v4
65+
with:
66+
distribution: "temurin"
67+
java-version: "17"
68+
69+
- name: Setup Gradle
70+
uses: gradle/actions/setup-gradle@v3
71+
72+
- name: Create .env file (root)
73+
run: |
74+
echo "DITTO_APP_ID=${{ secrets.DITTO_APP_ID }}" > .env
75+
echo "DITTO_PLAYGROUND_TOKEN=${{ secrets.DITTO_PLAYGROUND_TOKEN }}" >> .env
76+
echo "DITTO_AUTH_URL=${{ secrets.DITTO_AUTH_URL }}" >> .env
77+
echo "DITTO_WEBSOCKET_URL=${{ secrets.DITTO_WEBSOCKET_URL }}" >> .env
78+
79+
- name: Build Spring Boot JAR
80+
working-directory: java-server
81+
env:
82+
DITTO_APP_ID: ${{ secrets.DITTO_APP_ID }}
83+
DITTO_PLAYGROUND_TOKEN: ${{ secrets.DITTO_PLAYGROUND_TOKEN }}
84+
DITTO_AUTH_URL: ${{ secrets.DITTO_AUTH_URL }}
85+
DITTO_WEBSOCKET_URL: ${{ secrets.DITTO_WEBSOCKET_URL }}
86+
DITTO_ENABLE_CLOUD_SYNC: true
87+
run: ./gradlew bootJar
88+
89+
- name: Upload JAR artifacts
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: java-server-jar-${{ github.run_number }}
93+
path: java-server/build/libs/*.jar
94+
retention-days: 1
95+
96+
browserstack-test:
97+
name: BrowserStack Device Testing (macos-latest)
98+
runs-on: macos-latest
99+
needs: [build]
100+
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
101+
timeout-minutes: 45
102+
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Seed test task to Ditto Cloud
107+
id: seed_task
108+
uses: ./.github/actions/seed-ditto-document
109+
with:
110+
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
111+
ditto-api-url: ${{ secrets.DITTO_API_URL }}
112+
app-name: "java-server"
113+
114+
- name: Download JAR artifacts
115+
uses: actions/download-artifact@v4
116+
with:
117+
name: java-server-jar-${{ github.run_number }}
118+
path: java-server/build/libs/
119+
120+
- name: Setup Java
121+
uses: actions/setup-java@v4
122+
with:
123+
distribution: "temurin"
124+
java-version: "17"
125+
126+
- name: Setup Gradle
127+
uses: gradle/actions/setup-gradle@v3
128+
129+
- name: Create .env file (root)
130+
run: |
131+
echo "DITTO_APP_ID=${{ secrets.DITTO_APP_ID }}" > .env
132+
echo "DITTO_PLAYGROUND_TOKEN=${{ secrets.DITTO_PLAYGROUND_TOKEN }}" >> .env
133+
echo "DITTO_AUTH_URL=${{ secrets.DITTO_AUTH_URL }}" >> .env
134+
echo "DITTO_WEBSOCKET_URL=${{ secrets.DITTO_WEBSOCKET_URL }}" >> .env
135+
136+
- name: Install BrowserStack Local binary
137+
run: |
138+
curl -O "https://www.browserstack.com/browserstack-local/BrowserStackLocal-darwin-x64.zip"
139+
unzip BrowserStackLocal-darwin-x64.zip
140+
chmod +x BrowserStackLocal
141+
142+
- name: Start BrowserStack Local tunnel
143+
run: |
144+
echo "Starting BrowserStack Local tunnel..."
145+
nohup ./BrowserStackLocal --key "${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
146+
--daemon-mode > browserstack-local.log 2>&1 &
147+
148+
# Wait for tunnel to establish
149+
TIMEOUT=60
150+
ELAPSED=0
151+
152+
while [ $ELAPSED -lt $TIMEOUT ]; do
153+
if [ -f browserstack-local.log ] && grep -q "You can now access your local server(s) in our remote browser" browserstack-local.log; then
154+
echo "BrowserStack Local tunnel established"
155+
exit 0
156+
fi
157+
if [ -f browserstack-local.log ] && grep -q -i "error\|failed\|unable" browserstack-local.log; then
158+
echo "BrowserStack Local tunnel failed:"
159+
cat browserstack-local.log
160+
exit 1
161+
fi
162+
sleep 5
163+
ELAPSED=$((ELAPSED + 5))
164+
done
165+
166+
echo "BrowserStack Local tunnel timeout after ${TIMEOUT}s"
167+
[ -f browserstack-local.log ] && cat browserstack-local.log
168+
exit 1
169+
170+
- name: Create BrowserStack config
171+
working-directory: java-server
172+
run: |
173+
cat > browserstack.yml << EOF
174+
userName: ${{ secrets.BROWSERSTACK_USERNAME }}
175+
accessKey: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
176+
projectName: Ditto Java Server Tasks
177+
buildName: Java Server Selenium Tests #${{ github.run_number }}
178+
platforms:
179+
- os: Windows
180+
osVersion: 11
181+
browserName: Chrome
182+
browserVersion: latest
183+
browserstackLocal: true
184+
debug: true
185+
video: true
186+
parallelsPerPlatform: 1
187+
EOF
188+
189+
- name: Start Spring Boot app in background
190+
working-directory: java-server
191+
env:
192+
DITTO_APP_ID: ${{ secrets.DITTO_APP_ID }}
193+
DITTO_PLAYGROUND_TOKEN: ${{ secrets.DITTO_PLAYGROUND_TOKEN }}
194+
DITTO_AUTH_URL: ${{ secrets.DITTO_AUTH_URL }}
195+
DITTO_WEBSOCKET_URL: ${{ secrets.DITTO_WEBSOCKET_URL }}
196+
DITTO_ENABLE_CLOUD_SYNC: true
197+
run: |
198+
nohup java -jar build/libs/*.jar \
199+
--server.port=8080 \
200+
--spring.profiles.active=test > app.log 2>&1 &
201+
echo $! > app.pid
202+
203+
# Wait for application to be ready
204+
echo "Waiting for Spring Boot app to start..."
205+
for i in {1..30}; do
206+
if curl -f http://localhost:8080 >/dev/null 2>&1; then
207+
echo "Spring Boot app is ready"
208+
break
209+
fi
210+
sleep 2
211+
done
212+
213+
- name: Execute Selenium tests on BrowserStack cloud browsers
214+
working-directory: java-server
215+
env:
216+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
217+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
218+
BROWSERSTACK_LOCAL: true
219+
TEST_TASK_TITLE: ${{ steps.seed_task.outputs.document-title }}
220+
GITHUB_TEST_DOC_ID: ${{ steps.seed_task.outputs.document-title }}
221+
run: |
222+
TITLE="${{ steps.seed_task.outputs.document-title }}"
223+
224+
# Run only the BrowserStack test method, not all test methods
225+
./gradlew test --tests "*TaskVisibilityIntegrationTest.shouldPassWithExistingTask" \
226+
-DBROWSERSTACK_USERNAME="${{ secrets.BROWSERSTACK_USERNAME }}" \
227+
-DBROWSERSTACK_ACCESS_KEY="${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
228+
-DBROWSERSTACK_BUILD_NAME="Java Spring Selenium Tests #${{ github.run_number }}" \
229+
-DBROWSERSTACK_LOCAL=true \
230+
-DTEST_TASK_TITLE="$TITLE" \
231+
-DGITHUB_TEST_DOC_ID="$TITLE" \
232+
--info
233+
234+
- name: Stop Spring Boot app
235+
if: always()
236+
working-directory: java-server
237+
run: |
238+
if [ -f app.pid ]; then
239+
kill $(cat app.pid) || true
240+
rm app.pid
241+
fi
242+
243+
- name: Stop BrowserStack Local tunnel
244+
if: always()
245+
run: pkill -f "BrowserStackLocal" || true
246+
247+
- name: Upload test reports
248+
if: always()
249+
uses: actions/upload-artifact@v4
250+
with:
251+
name: browserstack-test-reports-${{ github.run_number }}
252+
path: java-server/build/reports/tests/
253+
retention-days: 1
254+
255+
- name: Upload app logs
256+
if: always()
257+
uses: actions/upload-artifact@v4
258+
with:
259+
name: spring-boot-logs-${{ github.run_number }}
260+
path: |
261+
java-server/app.log
262+
browserstack-local.log
263+
retention-days: 1
264+
265+
summary:
266+
name: CI Report
267+
runs-on: ubuntu-latest
268+
needs: [browserstack-test]
269+
if: always()
270+
271+
steps:
272+
- name: Report Results
273+
run: |
274+
echo "## ☕ Java Spring CI" >> $GITHUB_STEP_SUMMARY
275+
echo "" >> $GITHUB_STEP_SUMMARY
276+
277+
# Overall status
278+
if [[ "${{ needs.lint.result }}" == "success" && \
279+
"${{ needs.build.result }}" == "success" && \
280+
"${{ needs.browserstack-test.result }}" == "success" ]]; then
281+
echo "**Overall Status:** ✅ All checks passed" >> $GITHUB_STEP_SUMMARY
282+
else
283+
echo "**Overall Status:** ❌ Failed" >> $GITHUB_STEP_SUMMARY
284+
fi
285+
echo "" >> $GITHUB_STEP_SUMMARY
286+
287+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
288+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
289+
echo "| Lint | ${{ needs.lint.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
290+
echo "| Build | ${{ needs.build.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
291+
echo "| BrowserStack Tests | ${{ needs.browserstack-test.result == 'success' && '✅ Passed' || (needs.browserstack-test.result == 'skipped' && '⏭️ Skipped') || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
292+
echo "" >> $GITHUB_STEP_SUMMARY
293+
294+
# BrowserStack link
295+
if [[ "${{ needs.browserstack-test.result }}" != "skipped" ]]; then
296+
echo "### BrowserStack Session" >> $GITHUB_STEP_SUMMARY
297+
echo "" >> $GITHUB_STEP_SUMMARY
298+
echo "🔗 [View Test Results](https://automate.browserstack.com/builds?project=Ditto+Java+Spring+Tasks&build=Java+Spring+Selenium+Tests+%23${{ github.run_number }})" >> $GITHUB_STEP_SUMMARY
299+
echo "" >> $GITHUB_STEP_SUMMARY
300+
echo "**Tested Browser:**" >> $GITHUB_STEP_SUMMARY
301+
echo "- Chrome Latest (Windows 11)" >> $GITHUB_STEP_SUMMARY
302+
fi

0 commit comments

Comments
 (0)