From 767169fd1f1f3a93eef7cfd75ebaca64f03579c3 Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Mon, 14 Jul 2025 21:11:54 +0100 Subject: [PATCH 1/5] GH action to spin up test app --- .github/workflows/test.yml | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..15970a6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: Test Ruby Gem with Rack App + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + + - name: Install dependencies + run: | + bundle install + gem install bundler + + - name: Run unit tests + run: bundle exec rspec + + - name: Start Rack test app + run: | + # Start the test app in background on port 9292 + bundle exec puma examples/test.ru & + + # Store the PID for cleanup + echo $! > rack_app.pid + + # Wait for the app to start + sleep 5 + + # Verify the app is running + curl -f http://localhost:9292/ || (echo "App failed to start" && exit 1) + + - name: Run integration tests + run: | + curl -f http://localhost:9292/ || (echo "App failed to start" && exit 1) + # Make the test script executable + # chmod +x test/integration_test.rb + + # Run the integration tests + # ruby test/integration_test.rb + env: + TEST_APP_URL: http://localhost:9292 + + - name: Cleanup + if: always() + run: | + # Kill the Rack app if it's still running + if [ -f rack_app.pid ]; then + kill $(cat rack_app.pid) 2>/dev/null || true + rm rack_app.pid + fi From 9b87246f73492889bc590c1ac2aa1d0fc10a94cf Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Tue, 15 Jul 2025 10:55:13 +0100 Subject: [PATCH 2/5] Test pulling D* repo via gaspachoking/datastar branch with fixes --- .github/workflows/test.yml | 39 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15970a6..5eaefcc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,6 @@ name: Test Ruby Gem with Rack App on: push: - pull_request: jobs: test: @@ -27,29 +26,35 @@ jobs: - name: Start Rack test app run: | - # Start the test app in background on port 9292 - bundle exec puma examples/test.ru & + # Start the test app in background on port 8000 + bundle exec puma -p 8000 examples/test.ru & # Store the PID for cleanup echo $! > rack_app.pid # Wait for the app to start - sleep 5 + sleep 3 # Verify the app is running - curl -f http://localhost:9292/ || (echo "App failed to start" && exit 1) - - - name: Run integration tests - run: | - curl -f http://localhost:9292/ || (echo "App failed to start" && exit 1) - # Make the test script executable - # chmod +x test/integration_test.rb - - # Run the integration tests - # ruby test/integration_test.rb - env: - TEST_APP_URL: http://localhost:9292 - + curl -f http://localhost:8000/ || (echo "App failed to start" && exit 1) + + - name: Checkout datastar repository + uses: actions/checkout@v4 + with: + repository: gazpachoking/datastar + ref: fix-go-sdk-tests + path: datastar + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache-dependency-path: datastar/sdk/tests + + - name: Run SDK tests against test server + working-directory: datastar/sdk/tests + run: go run ./cmd/datastar-sdk-tests -server http://localhost:8000 + - name: Cleanup if: always() run: | From 7f2a969018b68b5cfa8bd67c9e6db1d54d17bde1 Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Tue, 15 Jul 2025 11:02:33 +0100 Subject: [PATCH 3/5] Guard against missing events in test app --- examples/test.ru | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test.ru b/examples/test.ru index 9ff83aa..c718e0f 100644 --- a/examples/test.ru +++ b/examples/test.ru @@ -32,7 +32,7 @@ run do |env| end datastar.stream do |sse| - sse.signals['events'].each do |event| + (sse.signals['events'] || []).each do |event| type = event.delete('type') case type when 'patchSignals' From bab598d1a208eaff9519e135f86ec65819d23075 Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Tue, 15 Jul 2025 12:58:08 +0100 Subject: [PATCH 4/5] Run Go tests in ismasan/datastar@go_sdk_tests --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5eaefcc..9382708 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,8 +41,8 @@ jobs: - name: Checkout datastar repository uses: actions/checkout@v4 with: - repository: gazpachoking/datastar - ref: fix-go-sdk-tests + repository: ismasan/datastar + ref: go_sdk_tests path: datastar - name: Set up Go From 8484637edb96d1d252255cb891723d2f138ac333 Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Tue, 15 Jul 2025 16:30:51 +0100 Subject: [PATCH 5/5] Point Go tests to main d* repo, develop branch --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9382708..8794fe8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,8 +41,8 @@ jobs: - name: Checkout datastar repository uses: actions/checkout@v4 with: - repository: ismasan/datastar - ref: go_sdk_tests + repository: starfederation/datastar + ref: develop path: datastar - name: Set up Go