Skip to content

Commit 94d4b36

Browse files
committed
chore(js): decouple workspaces
1 parent d7fcc6d commit 94d4b36

File tree

18 files changed

+14283
-5797
lines changed

18 files changed

+14283
-5797
lines changed

.github/actions/setup/action.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ inputs:
99
workflow_name:
1010
description: Name of the workflow that is executing this action.
1111
required: false
12+
language:
13+
description: the language for which to install deps
14+
required: false
1215

1316
runs:
1417
using: composite
@@ -62,11 +65,37 @@ runs:
6265

6366
- name: Install JavaScript dependencies
6467
shell: bash
65-
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
68+
run: yarn install
69+
70+
# JavaScript client deps
71+
- name: Get yarn js-client cache directory path
72+
if: ${{ inputs.language == 'javascript' }}
73+
shell: bash
74+
id: yarn-cache-dir
75+
run: echo "::set-output name=dir::$(cd clients/algoliasearch-client-javascript && yarn config get cacheFolder)"
76+
77+
- name: Restore Yarn js-client
78+
if: ${{ inputs.language == 'javascript' }}
79+
uses: actions/cache@v3
80+
with:
81+
path: ${{ steps.yarn-cache-dir.outputs.dir || 'clients/algoliasearch-client-javascript/.yarn/cache' }}
82+
key: yarn-cache-client-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}
83+
84+
- name: Cache js-client node modules
85+
if: ${{ inputs.language == 'javascript' }}
86+
uses: actions/cache@v3
87+
with:
88+
path: clients/algoliasearch-client-javascript/node_modules
89+
key: node-modules-client-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}
90+
91+
- name: Install JavaScript client dependencies
92+
if: ${{ inputs.language == 'javascript' }}
93+
shell: bash
94+
run: cd clients/algoliasearch-client-javascript && yarn install
6695

6796
# PHP deps
6897
- name: Run composer update
69-
if: inputs.type != 'minimal'
98+
if: ${{ inputs.language == 'php' }}
7099
shell: bash
71100
run: |
72101
composer update --working-dir=clients/algoliasearch-client-php

.github/workflows/check.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ jobs:
155155
uses: ./.github/actions/setup
156156
with:
157157
type: minimal
158+
language: javascript
158159

159160
- name: Build '${{ matrix.client }}' client
160161
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
161-
run: yarn workspace algoliasearch-client-javascript build ${{ matrix.client }}
162+
run: cd clients/algoliasearch-client-javascript yarn build ${{ matrix.client }}
162163

163164
- name: Run tests for 'client-common'
164165
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client == 'client-common' }}
165-
run: yarn workspace @experimental-api-clients-automation/client-common test
166+
run: cd clients/algoliasearch-client-javascript && yarn workspace @experimental-api-clients-automation/client-common test
166167

167168
- name: Store '${{ matrix.client }}' JavaScript utils package
168169
uses: actions/upload-artifact@v3
@@ -211,11 +212,17 @@ jobs:
211212

212213
- name: Setup
213214
uses: ./.github/actions/setup
215+
with:
216+
language: ${{ matrix.client.language }}
214217

215218
- name: Generate clients
216219
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
217220
run: yarn cli generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}
218221

222+
- name: Update `yarn.lock` for JavaScript release
223+
if: ${{ matrix.client.language == 'javascript' && (startsWith(github.head_ref, 'chore/prepare-release-') || github.ref == 'refs/heads/main') }}
224+
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
225+
219226
- name: Build clients
220227
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language != 'php' }}
221228
run: yarn cli build clients ${{ matrix.client.language }} ${{ matrix.client.toBuild }}
@@ -226,17 +233,34 @@ jobs:
226233

227234
- name: Run JavaScript 'algoliasearch' client tests
228235
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' }}
229-
run: yarn workspace @experimental-api-clients-automation/algoliasearch test
236+
run: cd clients/algoliasearch-client-javascript && yarn workspace @experimental-api-clients-automation/algoliasearch test
230237

231238
- name: Clean CTS output before generate
232239
run: rm -rf ${{ matrix.client.testsToDelete }} || true
233240

234241
- name: Generate CTS
235242
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}
236243

237-
- name: Update `yarn.lock` for JavaScript release
238-
if: ${{ matrix.client.language == 'javascript' && (startsWith(github.head_ref, 'chore/prepare-release-') || github.ref == 'refs/heads/main') }}
239-
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
244+
# JavaScript test deps (needs to be cached because they are huge and inefficient)
245+
- name: Get yarn js test cache directory path
246+
if: ${{ matrix.client.language == 'javascript' }}
247+
shell: bash
248+
id: yarn-cache-dir
249+
run: echo "::set-output name=dir::$(cd tests/output/javascript && yarn config get cacheFolder)"
250+
251+
- name: Restore Yarn js tests
252+
if: ${{ matrix.client.language == 'javascript' }}
253+
uses: actions/cache@v3
254+
with:
255+
path: ${{ steps.yarn-cache-dir.outputs.dir || 'tests/output/javascript/.yarn/cache' }}
256+
key: yarn-cache-tests-${{ env.CACHE_VERSION }}-${{ hashFiles('tests/output/javascript/yarn.lock') }}
257+
258+
- name: Cache js-client node modules
259+
if: ${{ matrix.client.language == 'javascript' }}
260+
uses: actions/cache@v3
261+
with:
262+
path: tests/output/javascript/node_modules
263+
key: node-modules-tests-${{ env.CACHE_VERSION }}-${{ hashFiles('tests/output/javascript/yarn.lock') }}
240264

241265
- name: Run CTS
242266
run: yarn cli cts run ${{ matrix.client.language }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ node_modules
66

77
yarn-error.log
88

9-
.yarn/*
10-
!.yarn/releases
11-
!.yarn/plugins
9+
**/.yarn/*
10+
!**/.yarn/releases
11+
!**/.yarn/plugins
1212

1313
.vscode/
1414
.idea/

0 commit comments

Comments
 (0)