Skip to content

Commit

Permalink
Merge branch 'main' into feat/javascript-requestsOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Mar 24, 2022
2 parents bebc94c + 272ebd3 commit bf5a304
Show file tree
Hide file tree
Showing 40 changed files with 318 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/.cache_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4
6
5 changes: 5 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ runs:
echo "::set-output name=JS_CLIENT_CHANGED::$(git diff --shortstat $origin..HEAD -- clients/algoliasearch-client-javascript | wc -l)"
echo "::set-output name=JS_ALGOLIASEARCH_CHANGED::$(git diff --shortstat $origin..HEAD -- clients/algoliasearch-client-javascript/packages/algoliasearch clients/algoliasearch-client-javascript/packages/client-search clients/algoliasearch-client-javascript/packages/client-analytics clients/algoliasearch-client-javascript/packages/client-personalization | wc -l)"
echo "::set-output name=JS_COMMON_CHANGED::$(git diff --shortstat $origin..HEAD -- clients/algoliasearch-client-javascript/packages/client-common clients/algoliasearch-client-javascript/packages/requester-browser-xhr clients/algoliasearch-client-javascript/packages/requester-node-http | wc -l)"
echo "::set-output name=JS_COMMON_TESTS_CHANGED::$(git diff --shortstat $origin..HEAD -- clients/algoliasearch-client-javascript/packages/client-common/src/__tests__ | wc -l)"
echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat $origin..HEAD -- templates/javascript | wc -l)"
echo "::set-output name=JAVA_CLIENT_CHANGED::$(git diff --shortstat $origin..HEAD -- clients/algoliasearch-client-java-2 | wc -l)"
Expand Down Expand Up @@ -208,6 +209,10 @@ outputs:
description: The generated `client-php` matrix
value: ${{ steps.php-matrix.outputs.MATRIX }}

RUN_JS_TESTS:
description: Determine if the `client_javascript_tests` job should run
value: ${{ steps.diff.outputs.JS_COMMON_TESTS_CHANGED > 0 }}

RUN_CTS:
description: Determine if the `cts` job should run
value: ${{
Expand Down
30 changes: 29 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
RUN_JS: ${{ steps.setup.outputs.RUN_JS }}
RUN_JS_ALGOLIASEARCH: ${{ steps.setup.outputs.RUN_JS_ALGOLIASEARCH }}
RUN_JS_COMMON: ${{ steps.setup.outputs.RUN_JS_COMMON }}
RUN_JS_TESTS: ${{ steps.setup.outputs.RUN_JS_TESTS }}
JS_MATRIX: ${{ steps.setup.outputs.JS_MATRIX }}

RUN_JAVA: ${{ steps.setup.outputs.RUN_JAVA }}
Expand Down Expand Up @@ -299,6 +300,28 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn cli build clients php ${{ matrix.client.name }}

client_javascript_tests:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs:
- client_javascript
- client_javascript_algoliasearch
if: |
always() &&
needs.setup.outputs.RUN_JS_TESTS == 'true' &&
contains(needs.*.result, 'success') &&
!contains(needs.*.result, 'failure')
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache
with:
job: cts

- name: Run client-common tests
run: yarn workspace @experimental-api-clients-automation/client-common test

cts:
runs-on: ubuntu-20.04
timeout-minutes: 20
Expand All @@ -320,6 +343,9 @@ jobs:
with:
job: cts

- name: Check JavaScript client size
run: exit $(yarn workspace algoliasearch-client-javascript test:size | echo $?)

- name: Generate
run: yarn cli cts generate

Expand All @@ -334,7 +360,9 @@ jobs:
codegen:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: cts
needs:
- cts
- client_javascript_tests
if: |
always() &&
needs.setup.outputs.RUN_CODEGEN == 'true' &&
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target
**/.DS_Store
.gradle
build
pom.xml

dist

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

import { createAbtestingApi } from '../src/abtestingApi';
import { createAbtestingApi, apiClientVersion } from '../src/abtestingApi';
import type { AbtestingApi, Region } from '../src/abtestingApi';

export * from '../src/abtestingApi';
Expand Down Expand Up @@ -35,6 +40,14 @@ export function abtestingApi(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';

import { createAbtestingApi } from '../src/abtestingApi';
Expand Down Expand Up @@ -34,6 +38,9 @@ export function abtestingApi(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
createAuth,
createMemoryCache,
createTransporter,
getUserAgent,
} from '@experimental-api-clients-automation/client-common';
Expand Down Expand Up @@ -40,7 +39,9 @@ export function createAbtestingApi(
const auth = createAuth(options.appId, options.apiKey, options.authMode);
const transporter = createTransporter({
hosts: options?.hosts ?? getDefaultHosts(options.region),
hostsCache: createMemoryCache(),
hostsCache: options.hostsCache,
requestsCache: options.requestsCache,
responsesCache: options.responsesCache,
baseHeaders: {
'content-type': 'application/x-www-form-urlencoded',
...auth.headers(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

import { createAnalyticsApi } from '../src/analyticsApi';
import { createAnalyticsApi, apiClientVersion } from '../src/analyticsApi';
import type { AnalyticsApi, Region } from '../src/analyticsApi';

export * from '../src/analyticsApi';
Expand Down Expand Up @@ -35,6 +40,14 @@ export function analyticsApi(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';

import { createAnalyticsApi } from '../src/analyticsApi';
Expand Down Expand Up @@ -34,6 +38,9 @@ export function analyticsApi(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
createAuth,
createMemoryCache,
createTransporter,
getUserAgent,
} from '@experimental-api-clients-automation/client-common';
Expand Down Expand Up @@ -53,7 +52,9 @@ export function createAnalyticsApi(
const auth = createAuth(options.appId, options.apiKey, options.authMode);
const transporter = createTransporter({
hosts: options?.hosts ?? getDefaultHosts(options.region),
hostsCache: createMemoryCache(),
hostsCache: options.hostsCache,
requestsCache: options.requestsCache,
responsesCache: options.responsesCache,
baseHeaders: {
'content-type': 'application/x-www-form-urlencoded',
...auth.headers(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Config } from '@jest/types';

const baseConfig: Config.InitialOptions = {
preset: 'ts-jest',
roots: ['src/__tests__/cache'],
roots: ['src/__tests__'],
};

const config: Config.InitialOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

import { createInsightsApi } from '../src/insightsApi';
import { createInsightsApi, apiClientVersion } from '../src/insightsApi';
import type { InsightsApi, Region } from '../src/insightsApi';

export * from '../src/insightsApi';
Expand Down Expand Up @@ -35,6 +40,14 @@ export function insightsApi(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';

import { createInsightsApi } from '../src/insightsApi';
Expand Down Expand Up @@ -34,6 +38,9 @@ export function insightsApi(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
createAuth,
createMemoryCache,
createTransporter,
getUserAgent,
} from '@experimental-api-clients-automation/client-common';
Expand Down Expand Up @@ -38,7 +37,9 @@ export function createInsightsApi(
const auth = createAuth(options.appId, options.apiKey, options.authMode);
const transporter = createTransporter({
hosts: options?.hosts ?? getDefaultHosts(options.region),
hostsCache: createMemoryCache(),
hostsCache: options.hostsCache,
requestsCache: options.requestsCache,
responsesCache: options.responsesCache,
baseHeaders: {
'content-type': 'application/x-www-form-urlencoded',
...auth.headers(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

import { createPersonalizationApi } from '../src/personalizationApi';
import {
createPersonalizationApi,
apiClientVersion,
} from '../src/personalizationApi';
import type { PersonalizationApi, Region } from '../src/personalizationApi';

export * from '../src/personalizationApi';
Expand Down Expand Up @@ -39,6 +47,14 @@ export function personalizationApi(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';

import { createPersonalizationApi } from '../src/personalizationApi';
Expand Down Expand Up @@ -38,6 +42,9 @@ export function personalizationApi(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
createAuth,
createMemoryCache,
createTransporter,
getUserAgent,
} from '@experimental-api-clients-automation/client-common';
Expand Down Expand Up @@ -38,7 +37,9 @@ export function createPersonalizationApi(
const auth = createAuth(options.appId, options.apiKey, options.authMode);
const transporter = createTransporter({
hosts: options?.hosts ?? getDefaultHosts(options.region),
hostsCache: createMemoryCache(),
hostsCache: options.hostsCache,
requestsCache: options.requestsCache,
responsesCache: options.responsesCache,
baseHeaders: {
'content-type': 'application/x-www-form-urlencoded',
...auth.headers(),
Expand Down
Loading

0 comments on commit bf5a304

Please sign in to comment.