Skip to content

Commit cb1faba

Browse files
authored
feat(spec): commit bundled specs (#134)
1 parent a53e10c commit cb1faba

19 files changed

+8110
-53
lines changed

.github/actions/cache/action.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,23 @@ inputs:
1717
runs:
1818
using: composite
1919
steps:
20-
# restore specs
21-
- name: Restore built ${{ inputs.spec }} spec
22-
if: ${{ inputs.job == 'client' }}
23-
uses: actions/cache@v2
24-
with:
25-
path: /home/runner/work/api-clients-automation/api-clients-automation/specs/dist/${{ inputs.spec }}.yml
26-
key: ${{ runner.os }}-${{ inputs.spec }}-specs-${{ hashFiles(format('specs/{0}/**', inputs.spec)) }}
27-
2820
# restore clients
2921
- name: Restore built JavaScript common client
22+
if: ${{ inputs.job == 'cts' }}
3023
uses: actions/cache@v2
3124
with:
3225
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-common/dist
3326
key: ${{ runner.os }}-1-js-client-common-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-common/**') }}
3427

3528
- name: Restore built JavaScript node requester
29+
if: ${{ inputs.job == 'cts' }}
3630
uses: actions/cache@v2
3731
with:
3832
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/requester-node-http/dist
3933
key: ${{ runner.os }}-1-js-node-requester-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-node-http/**') }}
4034

4135
- name: Restore built JavaScript browser requester
36+
if: ${{ inputs.job == 'cts' }}
4237
uses: actions/cache@v2
4338
with:
4439
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/requester-browser-xhr/dist
@@ -49,56 +44,56 @@ runs:
4944
uses: actions/cache@v2
5045
with:
5146
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-search/dist
52-
key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/dist/search.yml') }}
47+
key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/bundled/search.yml') }}
5348

5449
- name: Restore built JavaScript recommend client
5550
if: ${{ inputs.job == 'cts' }}
5651
uses: actions/cache@v2
5752
with:
5853
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/recommend/dist
59-
key: ${{ runner.os }}-1-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/dist/recommend.yml') }}
54+
key: ${{ runner.os }}-1-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/bundled/recommend.yml') }}
6055

6156
- name: Restore built JavaScript query-suggestions client
6257
if: ${{ inputs.job == 'cts' }}
6358
uses: actions/cache@v2
6459
with:
6560
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-query-suggestions/dist
66-
key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/dist/query-suggestions.yml') }}
61+
key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/bundled/query-suggestions.yml') }}
6762

6863
- name: Restore built JavaScript personalization client
6964
if: ${{ inputs.job == 'cts' }}
7065
uses: actions/cache@v2
7166
with:
7267
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-personalization/dist
73-
key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/dist/personalization.yml') }}
68+
key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/bundled/personalization.yml') }}
7469

7570
- name: Restore built JavaScript analytics client
7671
if: ${{ inputs.job == 'cts' }}
7772
uses: actions/cache@v2
7873
with:
7974
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-analytics/dist
80-
key: ${{ runner.os }}-1-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/dist/analytics.yml') }}
75+
key: ${{ runner.os }}-1-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/bundled/analytics.yml') }}
8176

8277
- name: Restore built JavaScript abtesting client
8378
if: ${{ inputs.job == 'cts' }}
8479
uses: actions/cache@v2
8580
with:
8681
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-abtesting/dist
87-
key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/dist/abtesting.yml') }}
82+
key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/bundled/abtesting.yml') }}
8883

8984
- name: Restore built JavaScript insights client
9085
if: ${{ inputs.job == 'cts' }}
9186
uses: actions/cache@v2
9287
with:
9388
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-insights/dist
94-
key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/dist/insights.yml') }}
89+
key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/bundled/insights.yml') }}
9590

9691
- name: Restore built JavaScript sources client
9792
if: ${{ inputs.job == 'cts' }}
9893
uses: actions/cache@v2
9994
with:
10095
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-sources/dist
101-
key: ${{ runner.os }}-1-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/dist/sources.yml') }}
96+
key: ${{ runner.os }}-1-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/bundled/sources.yml') }}
10297

10398
- name: Restore built JavaScript predict client
10499
if: ${{ inputs.job == 'cts' }}
@@ -112,7 +107,7 @@ runs:
112107
uses: actions/cache@v2
113108
with:
114109
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-java-2/target
115-
key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/dist/search.yml') }}
110+
key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/bundled/search.yml') }}
116111

117112
# setup yarn
118113
- name: Get yarn cache directory path

.github/workflows/check.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,12 @@ jobs:
5555
- name: Restore cache
5656
uses: ./.github/actions/cache
5757

58-
- name: Cache ${{ matrix.client }} spec
59-
id: cache
60-
uses: actions/cache@v2
61-
with:
62-
path: '/home/runner/work/api-clients-automation/api-clients-automation/specs/dist/${{ matrix.client }}.yml'
63-
key: ${{ runner.os }}-${{ matrix.client }}-specs-${{ hashFiles(format('specs/{0}/**', matrix.client)) }}
64-
6558
- name: Building ${{ matrix.client }} specs
66-
if: steps.cache.outputs.cache-hit != 'true'
6759
run: yarn build:specs ${{ matrix.client }}
6860

61+
- name: Check diff with pushed spec
62+
run: exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l)
63+
6964
client_javascript:
7065
timeout-minutes: 10
7166
runs-on: ubuntu-20.04
@@ -89,7 +84,7 @@ jobs:
8984
uses: actions/cache@v2
9085
with:
9186
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist'
92-
key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/dist/{0}.yml', matrix.client.name)) }}
87+
key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }}
9388

9489
- name: Generate ${{ matrix.client.name }} client
9590
if: steps.cache.outputs.cache-hit != 'true'
@@ -127,7 +122,7 @@ jobs:
127122
uses: actions/cache@v2
128123
with:
129124
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/target'
130-
key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/dist/{0}.yml', matrix.client.name)) }}
125+
key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }}
131126

132127
- name: Generate ${{ matrix.client.name }} client
133128
if: steps.cache.outputs.cache-hit != 'true'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
node_modules
22
.bash_profile
33
.env
4-
dist
54
.pnp.cjs
65

76
yarn-error.log
@@ -18,4 +17,6 @@ target
1817
.gradle
1918
build
2019

20+
dist
21+
2122
.openapi-generator

doc/CTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ The test generation script requires a JSON file name from the `operationId` (e.g
4646
"searchParam": {
4747
"$objectName": "the name of the object for strongly type language, should be on every 'object' type (can be 'Object' if free-form)",
4848
"query": "the string to search",
49-
"acl": {
49+
"acl": {
5050
"$enumType": "the name of the enum object if marked as enum in the spec",
51-
"value": "the string value of the enum",
51+
"value": "the string value of the enum"
5252
}
5353
}
5454
},
@@ -117,6 +117,6 @@ When writing your template, here is a list of variables accessible from `mustach
117117
To get the list of `operationId` not yet in the CTS but in the spec, run this command:
118118

119119
```bash
120-
rm -rf ./specs/dist
120+
rm -rf ./specs/bundled
121121
comm -3 <(grep -r operationId ./specs | awk -F: '{gsub(/ /,""); print $NF}' | sort) <(find ./tests/CTS/clients -type f -name '*.json' | awk -F/ '{gsub(/.json/,"");print $NF}' | sort)
122122
```

openapitools.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"config": "#{cwd}/openapitools.json",
1010
"apiPackage": "src",
1111
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-search",
12-
"glob": "specs/dist/search.yml",
12+
"glob": "specs/bundled/search.yml",
1313
"gitHost": "algolia",
1414
"gitUserId": "algolia",
1515
"gitRepoId": "algoliasearch-client-javascript",
@@ -30,7 +30,7 @@
3030
"config": "#{cwd}/openapitools.json",
3131
"apiPackage": "src",
3232
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/recommend",
33-
"glob": "specs/dist/recommend.yml",
33+
"glob": "specs/bundled/recommend.yml",
3434
"gitHost": "algolia",
3535
"gitUserId": "algolia",
3636
"gitRepoId": "algoliasearch-client-javascript",
@@ -51,7 +51,7 @@
5151
"config": "#{cwd}/openapitools.json",
5252
"apiPackage": "src",
5353
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-personalization",
54-
"glob": "specs/dist/personalization.yml",
54+
"glob": "specs/bundled/personalization.yml",
5555
"gitHost": "algolia",
5656
"gitUserId": "algolia",
5757
"gitRepoId": "algoliasearch-client-javascript",
@@ -75,7 +75,7 @@
7575
"config": "#{cwd}/openapitools.json",
7676
"apiPackage": "src",
7777
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-analytics",
78-
"glob": "specs/dist/analytics.yml",
78+
"glob": "specs/bundled/analytics.yml",
7979
"gitHost": "algolia",
8080
"gitUserId": "algolia",
8181
"gitRepoId": "algoliasearch-client-javascript",
@@ -100,7 +100,7 @@
100100
"config": "#{cwd}/openapitools.json",
101101
"apiPackage": "src",
102102
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-insights",
103-
"glob": "specs/dist/insights.yml",
103+
"glob": "specs/bundled/insights.yml",
104104
"gitHost": "algolia",
105105
"gitUserId": "algolia",
106106
"gitRepoId": "algoliasearch-client-javascript",
@@ -125,7 +125,7 @@
125125
"config": "#{cwd}/openapitools.json",
126126
"apiPackage": "src",
127127
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-abtesting",
128-
"glob": "specs/dist/abtesting.yml",
128+
"glob": "specs/bundled/abtesting.yml",
129129
"gitHost": "algolia",
130130
"gitUserId": "algolia",
131131
"gitRepoId": "algoliasearch-client-javascript",
@@ -150,7 +150,7 @@
150150
"config": "#{cwd}/openapitools.json",
151151
"apiPackage": "src",
152152
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-query-suggestions",
153-
"glob": "specs/dist/query-suggestions.yml",
153+
"glob": "specs/bundled/query-suggestions.yml",
154154
"gitHost": "algolia",
155155
"gitUserId": "algolia",
156156
"gitRepoId": "algoliasearch-client-javascript",
@@ -174,7 +174,7 @@
174174
"config": "#{cwd}/openapitools.json",
175175
"apiPackage": "src",
176176
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-sources",
177-
"glob": "specs/dist/sources.yml",
177+
"glob": "specs/bundled/sources.yml",
178178
"gitHost": "algolia",
179179
"gitUserId": "algolia",
180180
"gitRepoId": "algoliasearch-client-javascript",
@@ -224,7 +224,7 @@
224224
"invokerPackage": "com.algolia",
225225
"modelPackage": "com.algolia.model",
226226
"library": "okhttp-gson",
227-
"glob": "specs/dist/search.yml",
227+
"glob": "specs/bundled/search.yml",
228228
"gitHost": "algolia",
229229
"gitUserId": "algolia",
230230
"gitRepoId": "algoliasearch-client-java-2",
@@ -240,7 +240,7 @@
240240
"templateDir": "#{cwd}/templates/php/",
241241
"config": "#{cwd}/openapitools.json",
242242
"output": "#{cwd}/clients/algoliasearch-client-php",
243-
"glob": "specs/dist/search.yml",
243+
"glob": "specs/bundled/search.yml",
244244
"gitHost": "algolia",
245245
"gitUserId": "algolia",
246246
"gitRepoId": "algoliasearch-client-php",
@@ -258,7 +258,7 @@
258258
"templateDir": "#{cwd}/templates/php/",
259259
"config": "#{cwd}/openapitools.json",
260260
"output": "#{cwd}/clients/algoliasearch-client-php",
261-
"glob": "specs/dist/recommend.yml",
261+
"glob": "specs/bundled/recommend.yml",
262262
"gitHost": "algolia",
263263
"gitUserId": "algolia",
264264
"gitRepoId": "algoliasearch-client-php",
@@ -276,7 +276,7 @@
276276
"templateDir": "#{cwd}/templates/php/",
277277
"config": "#{cwd}/openapitools.json",
278278
"output": "#{cwd}/clients/algoliasearch-client-php",
279-
"glob": "specs/dist/personalization.yml",
279+
"glob": "specs/bundled/personalization.yml",
280280
"gitHost": "algolia",
281281
"gitUserId": "algolia",
282282
"gitRepoId": "algoliasearch-client-php",
@@ -298,7 +298,7 @@
298298
"templateDir": "#{cwd}/templates/php/",
299299
"config": "#{cwd}/openapitools.json",
300300
"output": "#{cwd}/clients/algoliasearch-client-php",
301-
"glob": "specs/dist/analytics.yml",
301+
"glob": "specs/bundled/analytics.yml",
302302
"gitHost": "algolia",
303303
"gitUserId": "algolia",
304304
"gitRepoId": "algoliasearch-client-php",
@@ -321,7 +321,7 @@
321321
"templateDir": "#{cwd}/templates/php/",
322322
"config": "#{cwd}/openapitools.json",
323323
"output": "#{cwd}/clients/algoliasearch-client-php",
324-
"glob": "specs/dist/insights.yml",
324+
"glob": "specs/bundled/insights.yml",
325325
"gitHost": "algolia",
326326
"gitUserId": "algolia",
327327
"gitRepoId": "algoliasearch-client-php",
@@ -344,7 +344,7 @@
344344
"templateDir": "#{cwd}/templates/php/",
345345
"config": "#{cwd}/openapitools.json",
346346
"output": "#{cwd}/clients/algoliasearch-client-php",
347-
"glob": "specs/dist/abtesting.yml",
347+
"glob": "specs/bundled/abtesting.yml",
348348
"gitHost": "algolia",
349349
"gitUserId": "algolia",
350350
"gitRepoId": "algoliasearch-client-php",
@@ -367,7 +367,7 @@
367367
"templateDir": "#{cwd}/templates/php/",
368368
"config": "#{cwd}/openapitools.json",
369369
"output": "#{cwd}/clients/algoliasearch-client-php",
370-
"glob": "specs/dist/query-suggestions.yml",
370+
"glob": "specs/bundled/query-suggestions.yml",
371371
"gitHost": "algolia",
372372
"gitUserId": "algolia",
373373
"gitRepoId": "algoliasearch-client-php",

scripts/builds/specs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ check_format_spec() {
2525

2626
build_spec() {
2727
local client=$1
28-
yarn openapi bundle specs/${client}/spec.yml -o specs/dist/${client}.${OUTPUT} --ext ${OUTPUT}
28+
yarn openapi bundle specs/${client}/spec.yml -o specs/bundled/${client}.${OUTPUT} --ext ${OUTPUT}
2929
echo ""
3030
}
3131

3232
validate_output_spec() {
3333
local client=$1
34-
yarn openapi lint specs/dist/${client}.${OUTPUT}
34+
yarn openapi lint specs/bundled/${client}.${OUTPUT}
3535
echo ""
3636
}
3737

38-
CLIENTS=$(find specs/*/spec.yml | awk -F / '{ print $(NF-1) }')
38+
CLIENTS=($(find specs/*/spec.yml | awk -F / '{ print $(NF-1) }'))
3939

4040
if [[ $CLIENT == "all" ]]; then
4141
CLIENTS=("${CLIENTS[@]}")

scripts/generate.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ compute_hash() {
2020
# build spec before generating client
2121
build_spec() {
2222
# check if file and cache exist
23+
mkdir -p specs/dist
2324
cacheFile="specs/dist/$CLIENT.cache"
24-
if [[ -f specs/dist/$CLIENT.yml ]]; then
25+
if [[ -f specs/bundled/$CLIENT.yml ]]; then
2526
cache=$(compute_hash)
2627
# compare with stored cache
2728
if [[ -f $cacheFile && $(cat $cacheFile) == $cache ]]; then

scripts/pre-gen/setHostsOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function setHostsOptions(): Promise<void> {
4343
throw new Error(`Generator not found: ${generator}`);
4444
}
4545

46-
const specPath = path.join(__dirname, `../../specs/dist/${client}.yml`);
46+
const specPath = path.join(__dirname, `../../specs/bundled/${client}.yml`);
4747

4848
if (!(await stat(specPath))) {
4949
throw new Error(`File not found ${specPath}`);

specs/bundled/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Bundled specs
2+
3+
**Please do not edit the files in this folder, they are generated and changes will be overwritten on next use**
4+
5+
Output folder of the specs located in `/specs/<CLIENT_NAME>/spec.yml`.
6+
7+
This folder hosts the bundled specs used to:
8+
9+
- Generate clients.
10+
- Generate documentation.
11+
- Share single readable spec file for a specific client.

0 commit comments

Comments
 (0)