From b1db026dec2456186fdb586aa74d043ef1bdf633 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 12 Jul 2024 10:58:30 +0200 Subject: [PATCH 1/5] fix(java): add overload for browseObjects --- .../src/main/java/com/algolia/playground/Search.java | 8 +++++++- templates/java/api_helpers.mustache | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/playground/java/src/main/java/com/algolia/playground/Search.java b/playground/java/src/main/java/com/algolia/playground/Search.java index 092ac167f6..c4acc0f67a 100644 --- a/playground/java/src/main/java/com/algolia/playground/Search.java +++ b/playground/java/src/main/java/com/algolia/playground/Search.java @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception { var options = new ClientOptions.Builder() .addAlgoliaAgentSegment("Playground", "1.0.0") - .setLogLevel(LogLevel.BODY) + //.setLogLevel(LogLevel.BODY) .build(); var client = new SearchClient(appId, apiKey, options); @@ -44,6 +44,12 @@ public static void main(String[] args) throws Exception { var response = client.batch(indexName, new BatchWriteParams().setRequests(batch)); client.waitForTask(indexName, response.getTaskID()); + var browse = client.browseObjects(indexName, new BrowseParamsObject().setQuery("tom"), Actor.class); + System.out.println("-> Browse Objects:"); + for (var hit : browse) { + System.out.println("> " + hit.name); + } + singleSearch(client, indexName, query); multiSearch(indexName, query, client); client.close(); diff --git a/templates/java/api_helpers.mustache b/templates/java/api_helpers.mustache index 3580a60338..18d06b58e9 100644 --- a/templates/java/api_helpers.mustache +++ b/templates/java/api_helpers.mustache @@ -289,6 +289,16 @@ public Iterable browseObjects(String indexName, BrowseParamsObject params return browseObjects(indexName, params, innerType, null); } +/** + * Helper: Returns an iterator on top of the `browse` method. + * + * @param indexName The index in which to perform the request. + * @param innerType The class held by the index, could be your custom class or {@link Object}. + */ +public Iterable browseObjects(String indexName, Class innerType) { + return browseObjects(indexName, new BrowseParamsObject(), innerType, null); +} + /** * Helper: Returns an iterator on top of the `searchSynonyms` method. * From 23273ef72280e7d48149750c26f88aace578bd18 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 12 Jul 2024 11:31:34 +0200 Subject: [PATCH 2/5] fix ci --- .github/workflows/check.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 85efee9523..1dc91d054c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -241,13 +241,17 @@ jobs: path: tests/output/javascript/node_modules key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }} - - name: Run CTS - id: cts + - name: Run unit CTS + run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-e2e + + - name: Run e2e CTS + id: cts-e2e continue-on-error: true - run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }} + if: ${{ !github.event.pull_request.head.repo.fork }} + run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit - name: Retry e2e CTS - if: ${{ !github.event.pull_request.head.repo.fork && github.event.number && steps.cts.outcome == 'failure' }} + if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }} run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit - name: Generate code snippets for documentation @@ -331,10 +335,14 @@ jobs: - name: Generate CTS run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }} - - name: Run CTS - id: cts + - name: Run unit CTS + run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-e2e + + - name: Run e2e CTS + id: cts-e2e continue-on-error: true - run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }} + if: ${{ !github.event.pull_request.head.repo.fork }} + run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit - name: Retry e2e CTS if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }} From d181707636500900dc8be5d0901f7febafb9dc32 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 12 Jul 2024 11:49:24 +0200 Subject: [PATCH 3/5] review --- .github/workflows/check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1dc91d054c..b6e66b9c2d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -251,7 +251,7 @@ jobs: run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit - name: Retry e2e CTS - if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }} + if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }} run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit - name: Generate code snippets for documentation @@ -345,7 +345,7 @@ jobs: run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit - name: Retry e2e CTS - if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }} + if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }} run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit - name: Generate code snippets for documentation From 92cedba151fd222f4d7189f8f36441dda820403b Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 12 Jul 2024 12:10:41 +0200 Subject: [PATCH 4/5] ruby --- scripts/cts/runCts.ts | 2 +- tests/output/ruby/Rakefile | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/cts/runCts.ts b/scripts/cts/runCts.ts index 0e4e5f4f6a..4656011ad8 100644 --- a/scripts/cts/runCts.ts +++ b/scripts/cts/runCts.ts @@ -89,7 +89,7 @@ async function runCtsOne( ); break; case 'ruby': - await run(`bundle install && bundle exec rake test --trace`, { + await run(`bundle install && bundle exec rake ${filter((f) => `test:${f}`)} --trace`, { cwd, language, }); diff --git a/tests/output/ruby/Rakefile b/tests/output/ruby/Rakefile index 08bca58eb7..a697aa1b74 100644 --- a/tests/output/ruby/Rakefile +++ b/tests/output/ruby/Rakefile @@ -2,12 +2,26 @@ require 'rake/testtask' -task test: 'test:unit' +task test: %w[test:client test:requests test:e2e] namespace :test do - Rake::TestTask.new(:unit) do |t| + Rake::TestTask.new(:client) do |t| t.libs << 'test' - t.test_files = FileList['test/**/*_test.rb'] + t.test_files = FileList['test/client/*_test.rb'] + t.verbose = true + t.warning = false + end + + Rake::TestTask.new(:requests) do |t| + t.libs << 'test' + t.test_files = FileList['test/requests/*_test.rb'] + t.verbose = true + t.warning = false + end + + Rake::TestTask.new(:e2e) do |t| + t.libs << 'test' + t.test_files = FileList['test/e2e/*_test.rb'] t.verbose = true t.warning = false end From e2a4454b2dbd68f38c84a7a7cbedb1100e1426cb Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 12 Jul 2024 12:25:08 +0200 Subject: [PATCH 5/5] scala --- scripts/cts/runCts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cts/runCts.ts b/scripts/cts/runCts.ts index 4656011ad8..329a4bd7f6 100644 --- a/scripts/cts/runCts.ts +++ b/scripts/cts/runCts.ts @@ -95,7 +95,7 @@ async function runCtsOne( }); break; case 'scala': - await run(`sbt test`, { + await run(`sbt 'testOnly ${filter((f) => `algoliasearch.${f}.*`)}'`, { cwd, language, });