-
Notifications
You must be signed in to change notification settings - Fork 6
refactor(ci): inline seed steps and add BrowserStack summaries #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
teodorciuraru
merged 17 commits into
main
from
teodorciuraru/extract-seed-document-composite-action
Oct 6, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
97f45ce
feat(ci): add GitHub Step Summary to all workflows and standardize na…
teodorciuraru 41fb8b6
feat(ci): extract seed document logic into reusable composite action
teodorciuraru 66ffba3
fix(javascript-web): use ORDER BY _id ASC instead of ORDER BY done
teodorciuraru 6bec5bf
fix: use ORDER BY title ASC for consistency across all apps
teodorciuraru 1be6a8c
fix(javascript-web): correct document ID matching in BrowserStack test
teodorciuraru b49e294
fix: portable head command and exact doc ID matching in tests
teodorciuraru 9daf1c6
refactor(ci): standardize KMP workflow to use single seed job after b…
teodorciuraru 1a444ed
refactor(ci): standardize seed job name to seed-ditto-cloud
teodorciuraru 32d3110
refactor(ci): extract inline seed to seed-ditto-cloud job in android-…
teodorciuraru 88b3184
refactor(ci): extract inline seed to seed-ditto-cloud job in android-…
teodorciuraru 8d999e3
refactor(ci): standardize seed-ditto-cloud job in swift and flutter
teodorciuraru efec197
refactor(ci): extract inline seed to seed-ditto-cloud job in java-spring
teodorciuraru 75e718e
fix: remove redundant job dependencies from summary jobs
teodorciuraru b52d6e7
fix(java-spring): ensure Ditto cloud sync is enabled at runtime
teodorciuraru 57c7d96
fix(ci): remove retry logic from android-java and fix kotlin-multipla…
teodorciuraru b4a63aa
refactor(ci): move seed steps inline to BrowserStack test jobs
teodorciuraru a899b26
fix(ci): use specific BrowserStack links in android-cpp and java-spri…
teodorciuraru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: 'Seed Ditto Test Document' | ||
description: 'Creates a test document in Ditto Cloud with inverted timestamp for CI testing' | ||
author: 'Ditto' | ||
|
||
inputs: | ||
ditto-api-key: | ||
description: 'Ditto API key for authentication' | ||
required: true | ||
ditto-api-url: | ||
description: 'Ditto API URL (e.g., cloud.ditto.live)' | ||
required: true | ||
app-name: | ||
description: 'Name of the app/platform being tested (e.g., android-kotlin, swift, etc.)' | ||
required: true | ||
|
||
outputs: | ||
document-id: | ||
description: 'The generated document ID' | ||
value: ${{ steps.seed.outputs.document_id }} | ||
document-title: | ||
description: 'The generated document title (same as ID)' | ||
value: ${{ steps.seed.outputs.document_title }} | ||
inverted-timestamp: | ||
description: 'The inverted timestamp used for ordering' | ||
value: ${{ steps.seed.outputs.inverted_timestamp }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Generate and insert test document | ||
id: seed | ||
shell: bash | ||
run: | | ||
# Generate inverted timestamp for top position in list | ||
TIMESTAMP=$(date +%s) | ||
INVERTED_TIMESTAMP=$((9999999999 - TIMESTAMP)) | ||
|
||
# Create unique document ID and title | ||
DOC_ID="${INVERTED_TIMESTAMP}_${{ inputs.app-name }}_ci_test_${{ github.run_id }}_${{ github.run_number }}" | ||
DOC_TITLE="$DOC_ID" | ||
|
||
echo "📝 Seeding test document to Ditto Cloud" | ||
echo "📝 App: ${{ inputs.app-name }}" | ||
echo "📝 ID: ${DOC_ID}" | ||
echo "📝 Timestamp: ${TIMESTAMP} → Inverted: ${INVERTED_TIMESTAMP}" | ||
|
||
# Insert document using Ditto API v4 | ||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ | ||
-H 'Content-type: application/json' \ | ||
-H "Authorization: Bearer ${{ inputs.ditto-api-key }}" \ | ||
-d "{ | ||
\"statement\": \"INSERT INTO tasks DOCUMENTS (:newTask) ON ID CONFLICT DO UPDATE\", | ||
\"args\": { | ||
\"newTask\": { | ||
\"_id\": \"${DOC_ID}\", | ||
\"title\": \"${DOC_TITLE}\", | ||
\"done\": false, | ||
\"deleted\": false | ||
} | ||
} | ||
}" \ | ||
"https://${{ inputs.ditto-api-url }}/api/v4/store/execute") | ||
|
||
# Extract HTTP status code and response body (portable version) | ||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | ||
BODY=$(echo "$RESPONSE" | sed '$d') | ||
|
||
# Check if insertion was successful | ||
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 201 ]; then | ||
echo "✅ Successfully inserted test document" | ||
echo "document_id=${DOC_ID}" >> $GITHUB_OUTPUT | ||
echo "document_title=${DOC_TITLE}" >> $GITHUB_OUTPUT | ||
echo "inverted_timestamp=${INVERTED_TIMESTAMP}" >> $GITHUB_OUTPUT | ||
else | ||
echo "❌ Failed to insert document. HTTP Status: $HTTP_CODE" | ||
echo "Response: $BODY" | ||
exit 1 | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# | ||
# Generic retry wrapper for BrowserStack API calls | ||
# Retries on BROWSERSTACK_ALL_PARALLELS_IN_USE errors with exponential backoff | ||
# | ||
# Usage: .github/scripts/retry-browserstack.sh '<your curl command>' | ||
# | ||
|
||
set -e | ||
|
||
# Configuration | ||
MAX_ATTEMPTS=${MAX_ATTEMPTS:-5} | ||
INITIAL_WAIT=${INITIAL_WAIT:-60} # Start with 1 minute | ||
MAX_WAIT=${MAX_WAIT:-300} # Max 5 minutes between retries | ||
|
||
# Function to run command with retry logic | ||
retry_on_queue_full() { | ||
local attempt=1 | ||
local wait_time=$INITIAL_WAIT | ||
|
||
while [ $attempt -le $MAX_ATTEMPTS ]; do | ||
echo "🔄 Attempt $attempt/$MAX_ATTEMPTS..." | ||
|
||
# Run the command and capture output | ||
set +e | ||
OUTPUT=$(eval "$@" 2>&1) | ||
EXIT_CODE=$? | ||
set -e | ||
|
||
echo "$OUTPUT" | ||
|
||
# Check if it's a BrowserStack queue error | ||
if echo "$OUTPUT" | grep -q "BROWSERSTACK_ALL_PARALLELS_IN_USE"; then | ||
if [ $attempt -lt $MAX_ATTEMPTS ]; then | ||
echo "⏳ BrowserStack queue is full. Waiting ${wait_time}s before retry (attempt $attempt/$MAX_ATTEMPTS)..." | ||
sleep $wait_time | ||
|
||
# Exponential backoff with max cap | ||
wait_time=$((wait_time * 2)) | ||
if [ $wait_time -gt $MAX_WAIT ]; then | ||
wait_time=$MAX_WAIT | ||
fi | ||
|
||
attempt=$((attempt + 1)) | ||
else | ||
echo "❌ Max attempts ($MAX_ATTEMPTS) reached. BrowserStack queue still full." | ||
return 1 | ||
fi | ||
else | ||
# Not a queue error - either success or fail immediately | ||
if [ $EXIT_CODE -eq 0 ]; then | ||
echo "✅ Command succeeded!" | ||
else | ||
echo "❌ Command failed with non-queue error" | ||
fi | ||
return $EXIT_CODE | ||
fi | ||
done | ||
|
||
return 1 | ||
} | ||
|
||
# Check if command was provided | ||
if [ $# -eq 0 ]; then | ||
echo "Usage: $0 '<command>'" | ||
echo "" | ||
echo "Examples:" | ||
echo " $0 'curl -u \$USER:\$KEY -X POST https://api.browserstack.com/...'" | ||
echo " $0 './gradlew test'" | ||
echo "" | ||
echo "Environment variables:" | ||
echo " MAX_ATTEMPTS=$MAX_ATTEMPTS (default: 5)" | ||
echo " INITIAL_WAIT=$INITIAL_WAIT (default: 60 seconds)" | ||
echo " MAX_WAIT=$MAX_WAIT (default: 300 seconds)" | ||
exit 1 | ||
fi | ||
|
||
# Run with retry logic | ||
retry_on_queue_full "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.