Skip to content

ci(javascript-tui): add lint, build and integration test#164

Merged
Teodor Ciuraru (teodorciuraru) merged 77 commits into
mainfrom
teodorciuraru/sdks-1617-javascript-tui-add-integration-test-support
Sep 25, 2025
Merged

ci(javascript-tui): add lint, build and integration test#164
Teodor Ciuraru (teodorciuraru) merged 77 commits into
mainfrom
teodorciuraru/sdks-1617-javascript-tui-add-integration-test-support

Conversation

@teodorciuraru
Copy link
Copy Markdown
Contributor

@teodorciuraru Teodor Ciuraru (teodorciuraru) commented Sep 10, 2025

Summary

  • Add CI workflow with lint, build, and integration test jobs
  • Update javascript-tui to use DittoConfig API (matching React Native implementation)
  • Fix error logging to show full error objects instead of just messages
  • Rename format check script (was incorrectly labeled as lint)

Changes Made

  • CI: Added comprehensive 3-job workflow with real Ditto Cloud integration testing
  • API Update: Migrated from new Ditto(identity) to DittoConfig + Ditto.open() pattern
  • Auth Handling: Added proper authentication setup with expiration handlers
  • Error Logging: Changed error.message to error for better debugging
  • Scripts: Renamed test:lint to test:format (it was doing format checks, not linting)
  • Node Version: Upgraded to Node 22 in CI

Test Status

✅ Integration test passes with 'Basic Test Task'
✅ Build and format checks pass
✅ Authentication and sync working properly

🤖 Generated with Claude Code

Teodor Ciuraru and others added 30 commits September 2, 2025 13:24
- Add comprehensive C++ CI workflow with lint, build, and integration tests
- Add BrowserStack workflow for real machine testing (Linux/macOS)
- Create integration tests using Ditto SDK DQL API (not HTTP)
- Create unit tests for core functionality and configuration
- Enhance build system with CMake and Make test targets
- Use idiomatic C++ tools: clang-format, clang-tidy, cmake, make

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Apply clang-format to existing C++ source files to pass CI linting
- Fix execute permissions on generate_env.awk script
- Ensure code style consistency across C++ codebase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add mock Ditto SDK for BrowserStack CI builds to avoid missing dependency
- Build only main app (no tests) in BrowserStack workflow since SDK not available
- Apply Copilot suggestions: safer getenv usage, specific using declarations
- Improve C++ code quality and null safety in test files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add mock Ditto SDK setup to Ubuntu and macOS builds in C++ CI
- Apply same successful approach from BrowserStack workflow to main CI
- Disable integration tests until real Ditto SDK available in CI
- Enable complete build verification across all platforms
- Ensure C++ pipeline works from lint → build → test end-to-end

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Enhanced mock SDK with JSON operator[] support for comprehensive testing
- Fixed unit test compilation with proper using declarations
- Improved mock nlohmann::json to handle test assertions correctly
- Applied complete mock SDK to both CI and BrowserStack workflows
- Verified local compilation success with enhanced mock SDK
- Ready for end-to-end CI pipeline validation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Implemented complete nlohmann::json mock with all required operators and methods
- Added comprehensive Ditto SDK mock including LogLevel, Log class, StoreObserver
- Fixed C++11 compatibility issues by removing make_unique and using proper namespaces
- Added C++11 compatible to_string implementation for integration and unit tests
- Updated both C++ CI and BrowserStack workflows with comprehensive mock SDK
- Addressed all compilation errors identified in CI run 17401468269

The mock SDK now includes:
- Complete nlohmann::json API with proper operators, assignments, and conversions
- Full Ditto SDK class hierarchy (Ditto, Store, QueryResult, etc.)
- Logging infrastructure with LogLevel enum and Log class
- Store observer pattern with StoreObserver and SyncSubscription
- C++11 compatible implementations throughout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Created comprehensive mock_sdk_comprehensive.h with complete Ditto SDK API
- Added brace-enclosed initializer list support for nlohmann::json
- Implemented both single and dual argument Log methods for tasks_log.cpp
- Added missing Ditto SDK methods: sync(), get_is_sync_active()
- Fixed C++11 compatibility issues in integration and unit tests
- Streamlined CI workflows to use external comprehensive mock file

Key features of the comprehensive mock SDK:
- Complete nlohmann::json API with std::initializer_list constructor
- Full Ditto SDK class hierarchy (Ditto, Store, QueryResult, etc.)
- Comprehensive logging infrastructure with overloaded methods
- Store observer pattern implementation
- Transport configuration and identity management
- C++11 compatible implementation throughout

This addresses all compilation errors from CI run 17402119502 and should
allow the C++ CI pipeline to work end-to-end.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added value type constructors for nlohmann::json (string, bool, int, char*)
- Fixed register_subscription to return shared_ptr<SyncSubscription> instead of void
- Added missing get_sdk_version() static method to Ditto class
- Added register_observer template method to Store class
- Improved brace-enclosed initializer list support

This addresses compilation errors from CI run 17402388014 where the
mock SDK was missing several required methods and constructors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix method name mismatch: set_task_done() -> mark_task_complete()
- Fix string conversion error in mutated_document_ids() usage
- Add missing std::exception using declaration in integration tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix namespace issues by using fully qualified std:: names
- Fix nlohmann::json brace initialization with proper constructors
- Fix return type mismatch in observer registration method
- Ensure compatibility across Linux/macOS compilers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Simplify CI to focus on essentials: lint, build, integration test
- Insert test document to Ditto Cloud via HTTP API
- Verify sync works with C++ TUI app using SDK DQL API
- Remove over-engineered workflows and focus on core functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Download real Ditto C++ SDK v4.12.0 in CI instead of mock
- Build with real libditto.a and Ditto.h headers
- Run integration test that actually connects to Ditto Cloud
- Verify test document syncs down via real SDK DQL API
- Use proper C++17 and linking flags (-ldl -lrt -pthread)

This enables true integration testing like other quickstart apps.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update LogLevel enum references to use proper case (Warning, Error, Info, etc.)
to match Ditto SDK definitions. This ensures compatibility with both mock and
real Ditto C++ SDK implementations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Restore changes needed for real Ditto SDK:
- Use get_sync() instead of deprecated sync() method
- Add to_string() calls for DocumentId type conversion

These changes are required for CI integration tests with the real Ditto C++ SDK.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The real Ditto C++ SDK uses lowercase enum values (warning, error, info, etc.)
rather than capitalized ones. Update main.cpp to match the real SDK API.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove mock SDK files and artifacts
- Remove unit tests (keeping only integration tests)
- Remove redundant C++ section from PR checks (now handled by dedicated workflows)
- Clean up CMakeLists.txt to remove unit test references

The C++ CI pipeline is now streamlined with only real SDK integration tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The sdk/ directory is needed for CI workflows to copy downloaded Ditto SDK files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update test script to use C++17 (matching CI workflows)
- Remove references to non-existent unit tests
- Keep only integration tests with real Ditto SDK

Addresses Copilot code review feedback about C++ standard version
inconsistency between local testing and CI environments.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
**Automatic SDK Download (like other quickstarts):**
- Add platform/architecture detection to Makefile
- Automatic SDK download with `make download-sdk` and `make build`
- Support Linux x86_64/aarch64 and macOS x86_64/arm64 platforms
- No manual SDK installation needed for customers

**CI Improvements:**
- Extract DITTO_SDK_VERSION to shared environment variable (4.12.0)
- Eliminate version duplication between workflows
- Consistent SDK version management across CI and local builds

**Test Reliability:**
- Replace fixed 2s sleep with intelligent polling + 5s timeout
- Better sync establishment detection in integration tests
- Reduced flaky test behavior as suggested by Copilot

**Developer Experience:**
- Updated README with automatic setup instructions
- Clear platform detection and automatic SDK handling
- Consistent with other quickstart repositories

**Note:** Kept get_sync() method as it's correct - sync() is deprecated in real SDK

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
**What Changed:**
- Renamed `cpp-browserstack.yml` to `cpp-tui-secondary.yml`
- Updated workflow name: "C++ TUI BrowserStack" → "C++ TUI Secondary CI"
- Changed job name: "BrowserStack Test" → "Secondary C++ TUI Testing"
- Updated document IDs: `cpp_browserstack_test_` → `cpp_secondary_test_`

**Why:**
- BrowserStack is for mobile/web apps, not C++ TUI terminal applications
- The workflow was misleading - it just ran on GitHub Ubuntu runners
- Now clearly labeled as "Secondary CI" for additional validation

**What It Actually Does:**
- ✅ Lint: clang-format code style validation
- ✅ Build: Compile C++ TUI app with real Ditto SDK
- ✅ Integration Test: Connect to Ditto Cloud and verify sync

This provides additional CI coverage without false claims about BrowserStack.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
We only need one C++ CI pipeline that does:
- Lint (clang-format)
- Build with real Ditto SDK
- Integration tests with Ditto Cloud

No need for duplicate/secondary testing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Clean up CI workflow to use Makefile for SDK download
- Remove experimental environment variables and manual SDK handling
- Enable full integration testing with real Ditto Cloud connectivity
- Verify cloud sync, CRUD operations, and performance with actual SDK

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Integration tests create their own test data, making the separate
document insertion step unnecessary.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…for C++ CI

- Seed unique test document with inverted timestamp (appears at top)
- Sort tasks by title ASC to match Swift implementation
- Update integration test to verify exact GitHub-seeded document
- Follow Swift CI pattern for consistent testing approach

This ensures C++ CI tests actual GitHub → Ditto Cloud → SDK sync flow.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…nt only

Match Swift CI pattern by testing only the core sync functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove all complex test classes and methods
- Simple main() function that syncs and checks for seeded document
- Gets expected title from GITHUB_TEST_DOC_TITLE env var
- Returns 0 on success, 1 on failure - clean and simple

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Linux: automatic SDK download via make build
- macOS/Windows: manual download required
- Clear instructions for both scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
AWK script is called via 'awk -f', doesn't need execute permission.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📱 BrowserStack Test Results

Status: ✅ Passed
Build: #104
BrowserStack: View detailed results

Tested Devices:

  • Google Pixel 8 (Android 14)
  • Samsung Galaxy S23 (Android 13)
  • Google Pixel 6 (Android 12)
  • OnePlus 9 (Android 11)

…lint

- Revert android-cpp-browserstack.yml, react-native-ci.yml, react-native-expo-ci.yml to main state
- Remove JavaScript TUI lint job from pr-checks.yml since it exists in javascript-tui-ci.yml
- Eliminate duplicate lint checks and workflow formatting inconsistencies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread javascript-tui/package.json Outdated
Comment thread .github/workflows/javascript-tui-ci.yml
Teodor Ciuraru and others added 14 commits September 11, 2025 19:42
- Use dynamic timestamp for local test document title to prevent conflicts
- Add explanatory comments for timestamp inversion magic number
- Format code with prettier

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add back important logic comments explaining Ditto configuration
- Keep production-ready code without unused variables
- Maintain documentation for temporary directory usage, transport config, and DQL setup

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename e2e_test.js → integration_test.js to reflect actual test type
- Update npm scripts: test:e2e → test:integration
- Update CI workflow job and step names
- Update all log messages to use 'Integration test' terminology
- This test validates Ditto SDK → Cloud → TUI integration, not true end-to-end user flows

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add back 'Flags:' log to show parsed CLI flags
- Restore configuration log showing appId, token, authURL, websocketURL
- Helpful for debugging configuration issues and CLI flag parsing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add teodorciuraru/sdks-1617-javascript-tui-add-integration-test-support to push triggers
- Allow CI testing during development on feature branch
- Remove before merging to main

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add pull_request trigger targeting main branch with javascript-tui path filter
- Remove incorrect branch-specific trigger
- Follow standard CI pattern: push to main + PR against main

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace complex Node.js command substitution with simple 'date +%s'
- Avoid shell escaping issues with nested quotes and parentheses
- Unix timestamp is sufficient for uniqueness in local testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change dynamic timestamp to clear placeholder '<insert-my-task-name-here>'
- Provides better developer UX with obvious instruction for usage
- Avoids shell escaping complexity while maintaining clear intent
- Test will predictably fail with helpful error message

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change CI to run 'npm run build && node tests/integration_test.js' directly
- Avoid npm script that hardcodes GITHUB_TEST_DOC_TITLE
- Allow CI environment variable to be properly passed to test
- Keep npm script for local development with helpful placeholder

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add '_MISSING_SUFFIX' to task matcher to force test failure
- Verify CI properly detects when seeded tasks aren't found in TUI
- Test should fail even though sync is active and task is seeded
- Demonstrates proper CI failure handling for integration tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Revert '_MISSING_SUFFIX' test modification to restore working state
- Set RUST_LOG='off' to completely silence verbose Ditto SDK logging
- Keep only essential integration test output for clean CI logs
- Production-ready logging level for automated testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com)
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove node_modules and package-lock.json
- Fresh npm install to eliminate ava, @microsoft/tui-test, chalk cruft
- Keep only production dependencies: ink-testing-library for integration tests
- Verify lint and build still work correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Regenerate package-lock.json to match current package.json dependencies
- Fix CI 'npm ci' failures due to lock file sync issues after package cleanup
- Maintain clean dependency tree without experimental packages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@teodorciuraru Teodor Ciuraru (teodorciuraru) marked this pull request as ready for review September 11, 2025 20:06
Comment thread javascript-tui/tests/integration_test.js
Comment thread javascript-tui/source/app.js
Comment thread javascript-tui/tests/integration_test.js Outdated
Comment thread .github/workflows/javascript-tui-ci.yml Outdated
Comment thread .github/workflows/javascript-tui-ci.yml Outdated
Comment thread .github/workflows/javascript-tui-ci.yml
Comment thread .github/workflows/javascript-tui-ci.yml
Comment thread .github/workflows/pr-checks.yml Outdated
Comment thread javascript-tui/tests/integration_test.js Outdated
Comment thread javascript-tui/package.json Outdated
Teodor Ciuraru and others added 2 commits September 12, 2025 18:50
- Migrate from new Ditto(identity) to DittoConfig + Ditto.open() pattern
- Add proper authentication handling with expiration handlers
- Fix error logging to show full error objects
- Rename test:lint to test:format (was doing format checks)
- Upgrade Node version to 22 in CI
- Revert React Native Expo DITTO_AUTH_URL import (not needed)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@teodorciuraru Teodor Ciuraru (teodorciuraru) merged commit c52399b into main Sep 25, 2025
6 checks passed
@teodorciuraru Teodor Ciuraru (teodorciuraru) deleted the teodorciuraru/sdks-1617-javascript-tui-add-integration-test-support branch September 25, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants