Skip to content

Commit

Permalink
Merge branch 'main' into feat/fat-jar
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Mar 25, 2022
2 parents 6654b8c + 23f75b5 commit ce095a0
Show file tree
Hide file tree
Showing 80 changed files with 3,622 additions and 1,731 deletions.
2 changes: 1 addition & 1 deletion .github/.cache_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4
6
6 changes: 3 additions & 3 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ runs:
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-common/**'
'clients/algoliasearch-client-javascript/packages/client-common/src/**'
)}}
- name: Restore built JavaScript node requester
Expand All @@ -164,7 +164,7 @@ runs:
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-javascript/packages/requester-node-http/**'
'clients/algoliasearch-client-javascript/packages/requester-node-http/src/**'
)}}
- name: Restore built JavaScript browser requester
Expand All @@ -175,7 +175,7 @@ runs:
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-javascript/packages/requester-browser-xhr/**'
'clients/algoliasearch-client-javascript/packages/requester-browser-xhr/src/**'
)}}
# Restore JavaScript clients: used during 'cts' or 'codegen'
Expand Down
10 changes: 8 additions & 2 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 @@ -94,8 +95,9 @@ runs:
id: js-matrix
shell: bash
run: |
base_changed=${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
base_changed=${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 || steps.diff.outputs.JS_COMMON_CHANGED > 0 }}
algoliasearch_changed=${{ steps.diff.outputs.JS_ALGOLIASEARCH_CHANGED > 0 }}
common_changed=${{ steps.diff.outputs.JS_COMMON_CHANGED > 0 }}
matrix=$(./scripts/ci/create-client-matrix.sh javascript $base_changed ${{ steps.diff.outputs.ORIGIN_BRANCH }})
Expand All @@ -116,7 +118,7 @@ runs:
echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_CLIENT::$run"
if [[ $base_changed == 'true' || steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then
if [[ $base_changed == 'true' || $common_changed == 'true' ]]; then
echo "Running common javascript: true"
echo "::set-output name=RUN_COMMON::true"
fi
Expand Down Expand Up @@ -208,6 +210,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
32 changes: 30 additions & 2 deletions .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 @@ -119,7 +120,7 @@ jobs:
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
format('clients/algoliasearch-client-javascript/packages/{0}/**', matrix.client)
format('clients/algoliasearch-client-javascript/packages/{0}/src/**', matrix.client)
)}}
- name: Build '${{ matrix.client }}' client
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 @@ -9,7 +9,7 @@ jobs:
release:
name: Publish
runs-on: ubuntu-20.04
if: "startsWith(github.event.issue.title, 'chore: release v')"
if: "startsWith(github.event.head_commit.message, 'chore: release v')"
steps:
- uses: actions/checkout@v2
with:
Expand Down
24 changes: 12 additions & 12 deletions clients/algoliasearch-client-javascript/bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@
"files": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.browser.js",
"maxSize": "6.50KB"
"maxSize": "7.05KB"
},
{
"path": "packages/client-abtesting/dist/client-abtesting.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.85KB"
},
{
"path": "packages/client-analytics/dist/client-analytics.umd.browser.js",
"maxSize": "4.00KB"
"maxSize": "4.45KB"
},
{
"path": "packages/client-insights/dist/client-insights.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.70KB"
},
{
"path": "packages/client-personalization/dist/client-personalization.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.85KB"
},
{
"path": "packages/client-query-suggestions/dist/client-query-suggestions.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.90KB"
},
{
"path": "packages/client-search/dist/client-search.umd.browser.js",
"maxSize": "5.25KB"
"maxSize": "5.85KB"
},
{
"path": "packages/client-sources/dist/client-sources.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.70KB"
},
{
"path": "packages/recommend/dist/recommend.umd.browser.js",
"maxSize": "3.25KB"
"maxSize": "3.80KB"
},
{
"path": "packages/client-common/dist/client-common.esm.node.js",
"maxSize": "3.00KB"
"maxSize": "3.80KB"
},
{
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
"maxSize": "1.00KB"
"maxSize": "825B"
},
{
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
"maxSize": "1.00KB"
"maxSize": "1.10KB"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import type {
PersonalizationApi,
Region as PersonalizationRegion,
} from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import { createPersonalizationApi } from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import { createSearchApi } from '@experimental-api-clients-automation/client-search/src/searchApi';
import {
createSearchApi,
apiClientVersion,
} from '@experimental-api-clients-automation/client-search/src/searchApi';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
Expand All @@ -39,6 +47,14 @@ export function algoliasearch(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type {
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import type {
PersonalizationApi,
Region as PersonalizationRegion,
Expand Down Expand Up @@ -38,6 +42,9 @@ export function algoliasearch(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {
Host,
Requester,
import type { InitClientOptions } 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 All @@ -13,7 +15,7 @@ export function abtestingApi(
appId: string,
apiKey: string,
region?: Region,
options?: { requester?: Requester; hosts?: Host[] }
options?: InitClientOptions
): AbtestingApi {
if (!appId) {
throw new Error('`appId` is missing.');
Expand All @@ -35,6 +37,19 @@ export function abtestingApi(
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: options?.responsesCache ?? createMemoryCache(),
requestsCache:
options?.requestsCache ?? createMemoryCache({ serializable: false }),
hostsCache:
options?.hostsCache ??
createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: `${apiClientVersion}-${appId}`,
}),
createMemoryCache(),
],
}),
...options,
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
Host,
Requester,
import type { InitClientOptions } 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';

Expand All @@ -13,7 +14,7 @@ export function abtestingApi(
appId: string,
apiKey: string,
region?: Region,
options?: { requester?: Requester; hosts?: Host[] }
options?: InitClientOptions
): AbtestingApi {
if (!appId) {
throw new Error('`appId` is missing.');
Expand All @@ -34,6 +35,9 @@ export function abtestingApi(
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: options?.responsesCache ?? createNullCache(),
requestsCache: options?.requestsCache ?? createNullCache(),
hostsCache: options?.hostsCache ?? createMemoryCache(),
...options,
});
}
Loading

0 comments on commit ce095a0

Please sign in to comment.