Skip to content

Commit 6e0f6d9

Browse files
authored
chore: fix codegen restore (#491)
1 parent 1219ef5 commit 6e0f6d9

File tree

3 files changed

+41
-57
lines changed

3 files changed

+41
-57
lines changed

.github/actions/restore-artifacts/action.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ description: |
77
88
inputs:
99
type:
10-
description: Type of artifacts to restore (`all` | `specs` | `utils`)
10+
description: Type of artifacts to restore (`all` | `specs` | `js_utils`)
11+
required: false
12+
php:
13+
description: Whether this job ran or not
14+
required: false
15+
java:
16+
description: Whether this job ran or not
17+
required: false
18+
javascript:
19+
description: Whether this job ran or not
1120
required: false
1221

1322
runs:
@@ -23,58 +32,58 @@ runs:
2332

2433
# JavaScript utils
2534
- name: client-javascript-utils-client-common
26-
if: ${{ inputs.type == 'all' || inputs.type == 'utils' }}
35+
if: ${{ inputs.type == 'all' || inputs.type == 'js_utils' }}
2736
uses: actions/download-artifact@v3
2837
with:
2938
name: client-javascript-utils-client-common
3039
path: clients/algoliasearch-client-javascript/packages/client-common/
3140

3241
- name: client-javascript-utils-requester-browser-xhr
33-
if: ${{ inputs.type == 'all' || inputs.type == 'utils' }}
42+
if: ${{ inputs.type == 'all' || inputs.type == 'js_utils' }}
3443
uses: actions/download-artifact@v3
3544
with:
3645
name: client-javascript-utils-requester-browser-xhr
3746
path: clients/algoliasearch-client-javascript/packages/requester-browser-xhr/
3847

3948
- name: client-javascript-utils-requester-node-http
40-
if: ${{ inputs.type == 'all' || inputs.type == 'utils' }}
49+
if: ${{ inputs.type == 'all' || inputs.type == 'js_utils' }}
4150
uses: actions/download-artifact@v3
4251
with:
4352
name: client-javascript-utils-requester-node-http
4453
path: clients/algoliasearch-client-javascript/packages/requester-node-http/
4554

4655
# JavaScript
4756
- name: Download clients-javascript artifact
48-
if: ${{ inputs.type == 'all' }}
57+
if: ${{ inputs.javascript == 'true' && inputs.type == 'all' }}
4958
uses: actions/download-artifact@v3
5059
with:
5160
name: clients-javascript
5261

5362
- name: Unzip clients-javascript artifact
54-
if: ${{ inputs.type == 'all' }}
63+
if: ${{ inputs.javascript == 'true' && inputs.type == 'all' }}
5564
shell: bash
5665
run: unzip -q -o clients-javascript.zip
5766

5867
# PHP
5968
- name: Download clients-php artifact
60-
if: ${{ inputs.type == 'all' }}
69+
if: ${{ inputs.php == 'true' && inputs.type == 'all' }}
6170
uses: actions/download-artifact@v3
6271
with:
6372
name: clients-php
6473

6574
- name: Unzip clients-php artifact
66-
if: ${{ inputs.type == 'all' }}
75+
if: ${{ inputs.php == 'true' && inputs.type == 'all' }}
6776
shell: bash
6877
run: unzip -q -o clients-php.zip
6978

7079
# Java
7180
- name: Download clients-java artifact
72-
if: ${{ inputs.type == 'all' }}
81+
if: ${{ inputs.java == 'true' && inputs.type == 'all' }}
7382
uses: actions/download-artifact@v3
7483
with:
7584
name: clients-java
7685

7786
- name: Unzip clients-java artifact
78-
if: ${{ inputs.type == 'all' }}
87+
if: ${{ inputs.java == 'true' && inputs.type == 'all' }}
7988
shell: bash
8089
run: unzip -q -o clients-java.zip

.github/actions/setup/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ outputs:
119119
description: The generated `client_gen` matrix
120120
value: ${{ steps.gen-matrix.outputs.GEN_MATRIX }}
121121

122+
RUN_GEN_JAVASCRIPT:
123+
description: Indicates if we plan to run the job for this language
124+
value: ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT }}
125+
RUN_GEN_JAVA:
126+
description: Indicates if we plan to run the job for this language
127+
value: ${{ steps.gen-matrix.outputs.RUN_GEN_JAVA }}
128+
RUN_GEN_PHP:
129+
description: Indicates if we plan to run the job for this language
130+
value: ${{ steps.gen-matrix.outputs.RUN_GEN_PHP }}
131+
122132
RUN_JS_ALGOLIASEARCH:
123133
description: Determine if the `client-javascript-algoliasearch` job should run
124134
value: ${{ steps.js-utils.outputs.RUN_JS_ALGOLIASEARCH }}

.github/workflows/check.yml

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
RUN_GEN: ${{ steps.setup.outputs.RUN_GEN }}
5656
GEN_MATRIX: ${{ steps.setup.outputs.GEN_MATRIX }}
5757

58+
RUN_GEN_JAVASCRIPT: ${{ steps.setup.outputs.RUN_GEN_JAVASCRIPT }}
59+
RUN_GEN_JAVA: ${{ steps.setup.outputs.RUN_GEN_JAVA }}
60+
RUN_GEN_PHP: ${{ steps.setup.outputs.RUN_GEN_PHP }}
61+
5862
RUN_JS_ALGOLIASEARCH: ${{ steps.setup.outputs.RUN_JS_ALGOLIASEARCH }}
5963
RUN_JS_UTILS: ${{ steps.setup.outputs.RUN_JS_UTILS }}
6064
RUN_JS_TESTS: ${{ steps.setup.outputs.RUN_JS_TESTS }}
@@ -189,13 +193,6 @@ jobs:
189193
key: ${{ matrix.client.cacheKey }}
190194
path: ${{ matrix.client.path }}
191195

192-
- name: Download bundled specs
193-
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
194-
uses: actions/download-artifact@v3
195-
with:
196-
name: specs
197-
path: specs/bundled/
198-
199196
- name: Download specs artifacts
200197
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
201198
uses: ./.github/actions/restore-artifacts
@@ -206,7 +203,7 @@ jobs:
206203
if: ${{ matrix.client.language == 'javascript' && steps.cache.outputs.cache-hit != 'true' }}
207204
uses: ./.github/actions/restore-artifacts
208205
with:
209-
type: utils
206+
type: js_utils
210207

211208
- name: Setup
212209
uses: ./.github/actions/setup
@@ -284,15 +281,14 @@ jobs:
284281
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
285282
run: yarn cli build clients javascript algoliasearch
286283

287-
codegen_on_pr:
284+
codegen:
288285
runs-on: ubuntu-20.04
289286
timeout-minutes: 10
290287
needs:
291288
- setup
292289
- client_gen
293290
if: |
294291
always() &&
295-
github.event_name == 'pull_request' &&
296292
!contains(needs.*.result, 'cancelled') &&
297293
!contains(needs.*.result, 'failure')
298294
steps:
@@ -312,51 +308,20 @@ jobs:
312308
uses: ./.github/actions/restore-artifacts
313309
with:
314310
type: all
311+
javascript: ${{ needs.setup.outputs.RUN_GEN_JAVASCRIPT }}
312+
php: ${{ needs.setup.outputs.RUN_GEN_PHP }}
313+
java: ${{ needs.setup.outputs.RUN_GEN_JAVA }}
315314

316-
- name: Push generated code to generated branch
315+
- name: Push generated code
317316
id: pushGeneratedCode
317+
if: ${{ needs.setup.outputs.RUN_CODEGEN == 'true' }}
318318
run: yarn workspace scripts pushGeneratedCode
319319
env:
320320
GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }}
321321
PR_NUMBER: ${{ github.event.number }}
322322

323-
codegen_on_main:
324-
runs-on: ubuntu-20.04
325-
timeout-minutes: 10
326-
needs:
327-
- setup
328-
- client_gen
329-
if: |
330-
always() &&
331-
github.ref == 'refs/heads/main' &&
332-
needs.setup.outputs.RUN_CODEGEN == 'true' &&
333-
!contains(needs.*.result, 'cancelled') &&
334-
!contains(needs.*.result, 'failure')
335-
steps:
336-
- uses: actions/checkout@v2
337-
with:
338-
fetch-depth: 0
339-
ref: ${{ github.event.pull_request.head.ref }}
340-
token: ${{ secrets.TOKEN_GENERATE_BOT }}
341-
342-
- name: Download all the previously stored artifacts
343-
uses: ./.github/actions/restore-artifacts
344-
with:
345-
type: all
346-
347-
- name: Setup
348-
uses: ./.github/actions/setup
349-
with:
350-
type: minimal
351-
352-
- name: Push generated code to main
353-
id: pushGeneratedCode
354-
run: yarn workspace scripts pushGeneratedCode
355-
env:
356-
GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }}
357-
358323
- name: Spread generation to each repository
359-
if: steps.pushGeneratedCode.exitcode == 0
324+
if: ${{ steps.pushGeneratedCode.exitcode == 0 && github.ref == 'refs/heads/main' }}
360325
run: yarn workspace scripts spreadGeneration
361326
env:
362327
GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }}

0 commit comments

Comments
 (0)