Skip to content

chore(js): decouple workspaces APIC-550 #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ inputs:
workflow_name:
description: Name of the workflow that is executing this action.
required: false
language:
description: the language for which to install deps
required: false

runs:
using: composite
Expand Down Expand Up @@ -52,7 +55,8 @@ runs:
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.dir || '.yarn/cache' }}
key: yarn-cache-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
# let yarn handle the cache hash
key: yarn-cache-${{ env.CACHE_VERSION }}

- name: Cache node modules
uses: actions/cache@v3
Expand All @@ -62,11 +66,38 @@ runs:

- name: Install JavaScript dependencies
shell: bash
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
run: yarn install

# JavaScript client deps
- name: Get yarn js-client cache directory path
if: ${{ inputs.language == 'javascript' }}
shell: bash
id: yarn-cache-dir-client
run: echo "::set-output name=dir::$(cd clients/algoliasearch-client-javascript && yarn config get cacheFolder)"

- name: Restore Yarn js-client
if: ${{ inputs.language == 'javascript' }}
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-client.outputs.dir || 'clients/algoliasearch-client-javascript/.yarn/cache' }}
# let yarn handle the cache hash
key: yarn-cache-client-${{ env.CACHE_VERSION }}

- name: Cache js-client node modules
if: ${{ inputs.language == 'javascript' }}
uses: actions/cache@v3
with:
path: clients/algoliasearch-client-javascript/node_modules
key: node-modules-client-${{ env.CACHE_VERSION }}-${{ hashFiles('clients/algoliasearch-client-javascript/yarn.lock') }}

- name: Install JavaScript client dependencies
if: ${{ inputs.language == 'javascript' }}
shell: bash
run: cd clients/algoliasearch-client-javascript && yarn install

# PHP deps
- name: Run composer update
if: inputs.type != 'minimal'
if: ${{ inputs.language == 'php' }}
shell: bash
run: |
composer update --working-dir=clients/algoliasearch-client-php
Expand Down
47 changes: 36 additions & 11 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: setup
strategy:
env:
matrix: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est bo hein

steps:
- uses: actions/checkout@v2
Expand All @@ -105,8 +105,8 @@ jobs:
id: cache
uses: actions/cache@v3
with:
key: ${{ matrix.client.cacheKey }}
path: ${{ matrix.client.bundledPath }}
key: ${{ matrix.cacheKey }}
path: ${{ matrix.bundledPath }}

- name: Setup
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
Expand All @@ -116,14 +116,14 @@ jobs:

- name: Building specs
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: yarn cli build specs ${{ matrix.client.toRun }}
run: yarn cli build specs ${{ matrix.toRun }}

- name: Store bundled specs
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: specs
path: ${{ matrix.client.bundledPath }}
path: ${{ matrix.bundledPath }}

client_javascript_utils:
timeout-minutes: 10
Expand Down Expand Up @@ -155,14 +155,15 @@ jobs:
uses: ./.github/actions/setup
with:
type: minimal
language: javascript

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

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

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

- name: Setup
uses: ./.github/actions/setup
with:
language: ${{ matrix.client.language }}

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

- name: Update `yarn.lock` for JavaScript
if: ${{ matrix.client.language == 'javascript' }}
run: cd ${{ matrix.client.path }} && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install

- name: Build clients
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language != 'php' }}
run: yarn cli build clients ${{ matrix.client.language }} ${{ matrix.client.toBuild }}
Expand All @@ -226,17 +233,35 @@ jobs:

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

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

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

- name: Update `yarn.lock` for JavaScript release
if: ${{ matrix.client.language == 'javascript' && (startsWith(github.head_ref, 'chore/prepare-release-') || github.ref == 'refs/heads/main') }}
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
# JavaScript test deps (needs to be cached because they are huge and inefficient)
- name: Get yarn js test cache directory path
if: ${{ matrix.client.language == 'javascript' }}
shell: bash
id: yarn-cache-dir-tests
run: echo "::set-output name=dir::$(cd ${{ matrix.client.testsRootFolder }} && yarn config get cacheFolder)"

- name: Restore Yarn js tests
if: ${{ matrix.client.language == 'javascript' }}
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-tests.outputs.dir || format('{0}/.yarn/cache', matrix.client.testsRootFolder) }}
# let yarn handle the cache hash
key: yarn-cache-tests-${{ env.CACHE_VERSION }}

- name: Cache js tests node modules
if: ${{ matrix.client.language == 'javascript' }}
uses: actions/cache@v3
with:
path: ${{ matrix.client.testsRootFolder }}/node_modules
key: node-modules-tests-${{ env.CACHE_VERSION }}-${{ hashFiles(format('{0}/.yarn.lock', matrix.client.testsRootFolder)) }}

- name: Run CTS
run: yarn cli cts run ${{ matrix.client.language }}
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ node_modules

yarn-error.log

.yarn/*
!.yarn/releases
!.yarn/plugins
**/.yarn/*
!**/.yarn/releases
!**/.yarn/plugins

.vscode/
.idea/
Expand Down
Loading