Skip to content

Commit

Permalink
feat(specs): bundle specs (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jan 18, 2022
1 parent eeabfe0 commit 622bce1
Show file tree
Hide file tree
Showing 72 changed files with 675 additions and 344 deletions.
37 changes: 26 additions & 11 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,82 @@ description: Restore cached dependencies.
inputs:
job:
description: The job that requires this composite
required: true
required: false
language:
description: The language to retrieve dependencies
required: false
default: javascript
spec:
description: The spec name to restore
required: false

runs:
using: composite
steps:
# restore specs
- name: Restore built ${{ inputs.spec }} spec
if: ${{ inputs.job == 'client' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/specs/dist/${{ inputs.spec }}.yml
key: ${{ runner.os }}-${{ inputs.spec }}-specs-${{ hashFiles(format('specs/{0}/**', inputs.spec)) }}

# restore clients
- name: Restore built JavaScript search 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-search/dist
key: ${{ runner.os }}-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/client-search/**') }}
key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/client-search/**') }}

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

- name: Restore built JavaScript query-suggestions 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-query-suggestions/dist
key: ${{ runner.os }}-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/client-query-suggestions/**') }}
key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/client-query-suggestions/**') }}

- name: Restore built JavaScript personalization 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-personalization/dist
key: ${{ runner.os }}-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/client-personalization/**') }}
key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/client-personalization/**') }}

- name: Restore built JavaScript analytics 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-analytics/dist
key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/client-analytics/**') }}
key: ${{ runner.os }}-1-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/**') }}
key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/client-abtesting/**') }}

- name: Restore built JavaScript insights 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-insights/dist
key: ${{ runner.os }}-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/client-insights/**') }}
key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/client-insights/**') }}

- name: Restore built Java client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-java-2/target
key: ${{ runner.os }}-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}
key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}

# setup yarn
- name: Get yarn cache directory path
Expand All @@ -85,13 +100,13 @@ runs:

# setup maven
- name: Restore Maven
if: ${{ inputs.job == 'java' }}
if: ${{ inputs.language == 'java' }}
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: setup-java-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Install Maven dependencies
if: ${{ inputs.job == 'java' }}
if: ${{ inputs.language == 'java' }}
shell: bash
run: mvn clean install -f clients/algoliasearch-client-java-2/pom.xml
26 changes: 18 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ jobs:
- name: Restore cache
uses: ./.github/actions/cache

- name: Checking ${{ matrix.client }} specs
run: yarn build:specs ${{ matrix.client }}
- name: Cache ${{ matrix.client }} spec
id: cache
uses: actions/cache@v2
with:
path: '/home/runner/work/api-clients-automation/api-clients-automation/specs/dist/${{ matrix.client }}.yml'
key: ${{ runner.os }}-${{ matrix.client }}-specs-${{ hashFiles(format('specs/{0}/**', matrix.client)) }}

- name: Lint ${{ matrix.client }} specs
run: yarn eslint --ext=yml specs/${{ matrix.client }}
- name: Building ${{ matrix.client }} specs
if: steps.cache.outputs.cache-hit != 'true'
run: yarn build:specs ${{ matrix.client }}

client_javascript:
runs-on: ubuntu-20.04
Expand All @@ -69,13 +74,16 @@ jobs:

- name: Restore cache
uses: ./.github/actions/cache
with:
job: client
spec: ${{ matrix.client.name }}

- name: Cache ${{ matrix.client.name }} client
id: cache
uses: actions/cache@v2
with:
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist'
key: ${{ runner.os }}-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}
key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}

- name: Generate ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -99,14 +107,16 @@ jobs:
- name: Restore cache
uses: ./.github/actions/cache
with:
job: java
job: client
language: java
spec: ${{ matrix.client.name }}

- name: Cache ${{ matrix.client.name }} client
id: cache
uses: actions/cache@v2
with:
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist'
key: ${{ runner.os }}-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/target'
key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}

- name: Generate ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand Down
24 changes: 24 additions & 0 deletions .redocly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiDefinitions:
abtesting: specs/abtesting/spec.yml
analytics: specs/analytics/spec.yml
insights: specs/insights/spec.yml
personalization: specs/personalization/spec.yml
query-suggestions: specs/query-suggestions/spec.yml
recommend: specs/recommend/spec.yml
search: specs/search/spec.yml

lint:
extends:
- recommended

rules:
no-empty-servers: off
info-license: off # for now we can keep it off.
no-ambiguous-paths: off # this is out of our scope.
no-enum-type-mismatch: warn # keeping the warning since it only occur on one edge case

tag-description: error
parameter-description: error
operation-description: error
operation-parameters-unique: error
tags-alphabetical: error
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* To update an attribute without pushing the entire record, you can use these built-in operations.
*/
public class BuildInOperation {
public class BuiltInOperation {

/** The operation to apply on the attribute. */
@JsonAdapter(OperationEnum.Adapter.class)
Expand Down Expand Up @@ -79,7 +79,7 @@ public OperationEnum read(final JsonReader jsonReader)
@SerializedName("value")
private String value;

public BuildInOperation operation(OperationEnum operation) {
public BuiltInOperation operation(OperationEnum operation) {
this.operation = operation;
return this;
}
Expand All @@ -98,7 +98,7 @@ public void setOperation(OperationEnum operation) {
this.operation = operation;
}

public BuildInOperation value(String value) {
public BuiltInOperation value(String value) {
this.value = value;
return this;
}
Expand Down Expand Up @@ -126,10 +126,10 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
BuildInOperation buildInOperation = (BuildInOperation) o;
BuiltInOperation builtInOperation = (BuiltInOperation) o;
return (
Objects.equals(this.operation, buildInOperation.operation) &&
Objects.equals(this.value, buildInOperation.value)
Objects.equals(this.operation, builtInOperation.operation) &&
Objects.equals(this.value, builtInOperation.value)
);
}

Expand All @@ -141,7 +141,7 @@ public int hashCode() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BuildInOperation {\n");
sb.append("class BuiltInOperation {\n");
sb
.append(" operation: ")
.append(toIndentedString(operation))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.algolia.model;

public class OneOfstringbuiltInOperation {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class SearchUserIdsResponseHits {

@SerializedName("userID")
private UserId userID;
private String userID;

@SerializedName("clusterName")
private String clusterName;
Expand All @@ -24,22 +24,22 @@ public class SearchUserIdsResponseHits {
@SerializedName("_highlightResult")
private SearchUserIdsResponseHighlightResult highlightResult;

public SearchUserIdsResponseHits userID(UserId userID) {
public SearchUserIdsResponseHits userID(String userID) {
this.userID = userID;
return this;
}

/**
* Get userID
* userID of the user.
*
* @return userID
*/
@javax.annotation.Nonnull
public UserId getUserID() {
public String getUserID() {
return userID;
}

public void setUserID(UserId userID) {
public void setUserID(String userID) {
this.userID = userID;
}

Expand Down
Loading

0 comments on commit 622bce1

Please sign in to comment.