Skip to content

Commit

Permalink
feat(specs): add abtesting specs and client (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jan 13, 2022
1 parent 9592e77 commit 5ba87a0
Show file tree
Hide file tree
Showing 127 changed files with 2,984 additions and 994 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ module.exports = {
'max-classes-per-file': 0,
'no-continue': 0,
'@typescript-eslint/prefer-enum-initializers': 0,
// there's a conflict when declaring `type` and `namespaces`, even with `ignoreDeclarationMerge`
'no-redeclare': 0,
'@typescript-eslint/no-redeclare': 0,

'@typescript-eslint/no-unused-vars': 2,
'unused-imports/no-unused-imports-ts': 2,
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ runs:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-analytics/dist
key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/client-analytics/**') }}

- name: Restore built JavaScript abtesting client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-abtesting/dist
key: ${{ runner.os }}-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/client-abtesting/**') }}

- name: Restore built JavaScript insights client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
Expand Down
12 changes: 8 additions & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runs:
echo "::set-output name=PERSO_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/personalization | wc -l)"
echo "::set-output name=INSIGHTS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/insights | wc -l)"
echo "::set-output name=ANALYTICS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/analytics | wc -l)"
echo "::set-output name=AB_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/abtesting | wc -l)"
echo "::set-output name=ABTESTING_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/abtesting | wc -l)"
echo "::set-output name=TESTS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- tests | wc -l)"
Expand All @@ -47,6 +47,7 @@ runs:
echo "::set-output name=JS_QUERY_SUGGESTIONS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-query-suggestions | wc -l)"
echo "::set-output name=JS_PERSO_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-personalization | wc -l)"
echo "::set-output name=JS_ANALYTICS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-analytics | wc -l)"
echo "::set-output name=JS_ABTESTING_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-abtesting | wc -l)"
echo "::set-output name=JS_INSIGHTS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-insights | wc -l)"
echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/javascript | wc -l)"
Expand All @@ -73,9 +74,9 @@ outputs:
RUN_SPECS_ANALYTICS:
description: Determine if the `specs_analytics` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }}
RUN_SPECS_AB:
description: Determine if the `specs_ab` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }}
RUN_SPECS_ABTESTING:
description: Determine if the `specs_abtesting` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ABTESTING_SPECS_CHANGED > 0 }}

# js client variables
RUN_JS_CLIENT_SEARCH:
Expand All @@ -93,6 +94,9 @@ outputs:
RUN_JS_CLIENT_ANALYTICS:
description: Determine if the `client_javascript_analytics` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
RUN_JS_CLIENT_ABTESTING:
description: Determine if the `client_javascript_abtesting` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ABTESTING_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ABTESTING_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
RUN_JS_CLIENT_INSIGHTS:
description: Determine if the `client_javascript_insights` job should run
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_INSIGHTS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
Expand Down
45 changes: 44 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ jobs:
RUN_SPECS_PERSO: ${{ steps.setup.outputs.RUN_SPECS_PERSO }}
RUN_SPECS_INSIGHTS: ${{ steps.setup.outputs.RUN_SPECS_INSIGHTS }}
RUN_SPECS_ANALYTICS: ${{ steps.setup.outputs.RUN_SPECS_ANALYTICS }}
RUN_SPECS_AB: ${{ steps.setup.outputs.RUN_SPECS_AB }}
RUN_SPECS_ABTESTING: ${{ steps.setup.outputs.RUN_SPECS_ABTESTING }}

RUN_JS_CLIENT_SEARCH: ${{ steps.setup.outputs.RUN_JS_CLIENT_SEARCH }}
RUN_JS_CLIENT_RECOMMEND: ${{ steps.setup.outputs.RUN_JS_CLIENT_RECOMMEND }}
RUN_JS_CLIENT_QUERY_SUGGESTIONS: ${{ steps.setup.outputs.RUN_JS_CLIENT_QUERY_SUGGESTIONS }}
RUN_JS_CLIENT_PERSO: ${{ steps.setup.outputs.RUN_JS_CLIENT_PERSO }}
RUN_JS_CLIENT_ANALYTICS: ${{ steps.setup.outputs.RUN_JS_CLIENT_ANALYTICS }}
RUN_JS_CLIENT_ABTESTING: ${{ steps.setup.outputs.RUN_JS_CLIENT_ABTESTING }}
RUN_JS_CLIENT_INSIGHTS: ${{ steps.setup.outputs.RUN_JS_CLIENT_INSIGHTS }}

RUN_JAVA_CLIENT: ${{ steps.setup.outputs.RUN_JAVA_CLIENT }}
Expand Down Expand Up @@ -125,6 +126,22 @@ jobs:
- name: Lint analytics specs
run: yarn eslint --ext=yml specs/analytics

specs_abtesting:
runs-on: ubuntu-20.04
needs: setup
if: ${{ always() && needs.setup.outputs.RUN_SPECS_ABTESTING == 'true' }}
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache

- name: Checking abtesting specs
run: yarn build:specs abtesting

- name: Lint abtesting specs
run: yarn eslint --ext=yml specs/abtesting

specs_insights:
runs-on: ubuntu-20.04
needs: setup
Expand Down Expand Up @@ -266,6 +283,31 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn build:clients javascript analytics

client_javascript_abtesting:
runs-on: ubuntu-20.04
needs: [specs_abtesting]
if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_ABTESTING == 'true' }}
steps:
- uses: actions/checkout@v2

- name: Restore cache
uses: ./.github/actions/cache

- name: Cache abtesting client
id: cache
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-abtesting/dist
key: ${{ runner.os }}-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/client-abtesting/**') }}

- name: Generate abtesting client
if: steps.cache.outputs.cache-hit != 'true'
run: yarn generate javascript abtesting

- name: Build abtesting client
if: steps.cache.outputs.cache-hit != 'true'
run: yarn build:clients javascript abtesting

client_javascript_insights:
runs-on: ubuntu-20.04
needs: [specs_insights]
Expand Down Expand Up @@ -326,6 +368,7 @@ jobs:
- client_javascript_query_suggestions
- client_javascript_perso
- client_javascript_analytics
- client_javascript_abtesting
- client_javascript_insights
- client_java_search

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ The clients can be tested inside the [`playground`](./playground) folder
### Usage

```bash
yarn docker playground:<language>:<client>
yarn docker playground <language> <client>
```

### JavaScript

```bash
yarn docker playground:js:search
yarn docker playground javascript search
```

### Java

```bash
yarn docker playground:java:search
yarn docker playground java search
```

# Troubleshooting
Expand Down
13 changes: 11 additions & 2 deletions clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ This folder hosts the generated clients and their utils.

## Generated clients

### Java

- [algoliasearch-client-java-2](./algoliasearch-client-java-2/): The Algolia search client.

### JavaScript

- [algoliasearch](./algoliasearch-client-javascript/algoliasearch/): The Algolia search client.
- [@algolia/client-abtesting](./algoliasearch-client-javascript/client-abtesting/): The Algolia AB testing client.
- [@algolia/client-analytics](./algoliasearch-client-javascript/client-analytics/): The Algolia analytics client.
- [@algolia/client-insights](./algoliasearch-client-javascript/client-insights/): The Algolia insights client.
- [@algolia/client-personalization](./algoliasearch-client-javascript/client-personalization/): The Algolia personalization client.
- [@algolia/client-query-suggestions](./algoliasearch-client-javascript/client-query-suggestions/): The Algolia query suggestions client.
- [@algolia/client-search](./algoliasearch-client-javascript/client-search/): The Algolia search client.
- [@algolia/recommend](./algoliasearch-client-javascript/recommend/): The Algolia recommend client.

## Utils
#### Utils

- [JavaScript](./algoliasearch-client-javascript/utils/): The JavaScript clients utils.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public BatchResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public DeletedAtResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SaveObjectResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SaveSynonymResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public UpdatedAtResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public UpdatedAtWithObjectIdResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public UpdatedRuleResponse taskID(Integer taskID) {
}

/**
* taskID of the indexing task to wait for.
* taskID of the task to wait for.
*
* @return taskID
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,8 @@ public Call getLogsAsync(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param attributesToRetrieve (optional)
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
* attributes are returned. (optional)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
Expand Down Expand Up @@ -2546,7 +2547,8 @@ private Call getObjectValidateBeforeCall(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param attributesToRetrieve (optional)
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
* attributes are returned. (optional)
* @return Map&lt;String, String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
* response body
Expand All @@ -2572,7 +2574,8 @@ public Map<String, String> getObject(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param attributesToRetrieve (optional)
* @param attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable
* attributes are returned. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
Expand Down Expand Up @@ -3297,7 +3300,7 @@ public Call getUserIdAsync(
/**
* Build call for hasPendingMappings
*
* @param getClusters (optional)
* @param getClusters Whether to get clusters or not. (optional)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
Expand Down Expand Up @@ -3346,7 +3349,7 @@ private Call hasPendingMappingsValidateBeforeCall(
* response is 200 OK. A successful response indicates that the operation has been taken into
* account, and the userIDs are directly usable.
*
* @param getClusters (optional)
* @param getClusters Whether to get clusters or not. (optional)
* @return CreatedAtResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
* response body
Expand All @@ -3366,7 +3369,7 @@ public CreatedAtResponse hasPendingMappings(Boolean getClusters)
* done. Upon success, the response is 200 OK. A successful response indicates that the operation
* has been taken into account, and the userIDs are directly usable.
*
* @param getClusters (optional)
* @param getClusters Whether to get clusters or not. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
Expand Down Expand Up @@ -3985,7 +3988,7 @@ public Call operationIndexAsync(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param buildInOperation The Algolia object. (required)
* @param buildInOperation List of attributes to update. (required)
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
* true)
* @param _callback Callback for upload/download progress
Expand Down Expand Up @@ -4081,7 +4084,7 @@ private Call partialUpdateObjectValidateBeforeCall(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param buildInOperation The Algolia object. (required)
* @param buildInOperation List of attributes to update. (required)
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
* true)
* @return UpdatedAtWithObjectIdResponse
Expand Down Expand Up @@ -4117,7 +4120,7 @@ public UpdatedAtWithObjectIdResponse partialUpdateObject(
*
* @param indexName The index in which to perform the request. (required)
* @param objectID Unique identifier of an object. (required)
* @param buildInOperation The Algolia object. (required)
* @param buildInOperation List of attributes to update. (required)
* @param createIfNotExists Creates the record if it does not exist yet. (optional, default to
* true)
* @param _callback The callback to be executed when the API call finishes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.openapi-generator
.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

git_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is the entrypoint for the package
export * from './src/apis';
export * from './model/models';
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Variant } from './variant';

export type ABTest = {
/**
* The A/B test ID.
*/
abTestID: number;
/**
* A/B test significance based on click data. Should be > 0.95 to be considered significant (no matter which variant is winning).
*/
clickSignificance: number;
/**
* A/B test significance based on conversion data. Should be > 0.95 to be considered significant (no matter which variant is winning).
*/
conversionSignificance: number;
/**
* End date for the A/B test expressed as YYYY-MM-DDThh:mm:ssZ.
*/
endAt: Date;
/**
* End date for the A/B test expressed as YYYY-MM-DDThh:mm:ssZ.
*/
createdAt: Date;
/**
* A/B test name.
*/
name: string;
/**
* Status of the A/B test.
*/
status: string;
/**
* List of A/B test variant.
*/
variants: Variant[];
};
Loading

0 comments on commit 5ba87a0

Please sign in to comment.