From 65d12cde99c42af6eefae5c74b29da5f937c027a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 15 Feb 2022 10:44:46 +0100 Subject: [PATCH 1/4] feat(ci): build JavaScript client common --- .github/actions/cache/action.yml | 4 ++-- .github/actions/setup/action.yml | 9 ++++++++ .github/workflows/check.yml | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 8ef35b49d98..de14ead2b98 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -30,14 +30,14 @@ runs: uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/requester-node-http/dist - key: ${{ runner.os }}-1-js-node-requester-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-node-http/**') }} + key: ${{ runner.os }}-1-js-requester-node-http-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-node-http/**') }} - name: Restore built JavaScript browser requester if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/requester-browser-xhr/dist - key: ${{ runner.os }}-1-js-browser-requester-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-browser-xhr/**') }} + key: ${{ runner.os }}-1-js-requester-browser-xhr-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-browser-xhr/**') }} - name: Restore built JavaScript search client if: ${{ inputs.job == 'cts' }} diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a5d0ff84161..fa4f1123a43 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -38,6 +38,7 @@ runs: echo "::set-output name=SCRIPTS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- scripts | wc -l)" echo "::set-output name=JS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript | wc -l)" + echo "::set-output name=JS_COMMON_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/packages/client-common clients/algoliasearch-client-javascript/packages/requester-browser-xhr clients/algoliasearch-client-javascript/packages/requester-node-http | wc -l)" echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/javascript | wc -l)" echo "::set-output name=JAVA_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-java-2 | wc -l)" @@ -80,6 +81,10 @@ runs: echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_CLIENT::$run" + if [[ $run == 'false' && steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then + echo "::set-output name=RUN_COMMON::true" + fi + - name: Compute the Java client build matrix id: java-matrix shell: bash @@ -127,6 +132,10 @@ outputs: description: Whether to run js client or not value: ${{ steps.js-matrix.outputs.RUN_CLIENT }} + RUN_JS_COMMON: + description: Whether to build JS client common folders when RUN_JS is false + value: ${{ steps.js-matrix.outputs.RUN_COMMON }} + JS_MATRIX: description: Generate the matrix for the Javascript client value: ${{ steps.js-matrix.outputs.MATRIX }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f02c4d1ef4f..1af6f692325 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -32,6 +32,7 @@ jobs: SPECS_MATRIX: ${{ steps.setup.outputs.SPECS_MATRIX }} RUN_JS: ${{ steps.setup.outputs.RUN_JS }} + RUN_JS_COMMON: ${{ steps.setup.outputs.RUN_JS_COMMON }} JS_MATRIX: ${{ steps.setup.outputs.JS_MATRIX }} RUN_JAVA: ${{ steps.setup.outputs.RUN_JAVA }} @@ -98,6 +99,39 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: yarn build:clients javascript ${{ matrix.client.name }} + client_javascript_common: + timeout-minutes: 10 + runs-on: ubuntu-20.04 + needs: + - setup + - specs + if: ${{ always() && needs.setup.outputs.RUN_JS_COMMON == 'true' }} + strategy: + matrix: + client: + - client-common + - requester-browser-xhr + - requester-node-http + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: client + spec: ${{ matrix.client }} + + - name: Cache ${{ matrix.client }} client + id: cache + uses: actions/cache@v2 + with: + path: '/home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/${{ matrix.client }}/dist' + key: ${{ runner.os }}-1-js-${{ matrix.client }}-${{ hashFiles(format('clients/algoliasearch-client-javascript/packages/{0}/**', matrix.client)) }} + + - name: Build ${{ matrix.client }} client + if: steps.cache.outputs.cache-hit != 'true' + run: yarn workspace @algolia/${{ matrix.client }} build + client_java: runs-on: ubuntu-20.04 timeout-minutes: 10 @@ -172,6 +206,7 @@ jobs: timeout-minutes: 20 needs: - client_javascript + - client_javascript_common - client_java - client_php From 728bcda8aab1dbd869b7f2f4689002724903c37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 15 Feb 2022 11:40:40 +0100 Subject: [PATCH 2/4] build common after js step --- .github/actions/setup/action.yml | 2 +- scripts/builds/clients.sh | 2 -- scripts/post-gen/global.sh | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index fa4f1123a43..6a8a4e5b161 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -81,7 +81,7 @@ runs: echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_CLIENT::$run" - if [[ $run == 'false' && steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then + if [[ $base_changed == 'true' || steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then echo "::set-output name=RUN_COMMON::true" fi diff --git a/scripts/builds/clients.sh b/scripts/builds/clients.sh index 25a03b8a6c7..1a65602cace 100755 --- a/scripts/builds/clients.sh +++ b/scripts/builds/clients.sh @@ -20,11 +20,9 @@ fi # Commands are based on the LANGUAGE if [[ $LANGUAGE == 'javascript' ]]; then echo "> Cleaning previous build $GENERATOR..." - yarn workspace $PACKAGE clean echo "> Bundling $GENERATOR..." - CMD="yarn workspace $PACKAGE build" elif [[ $LANGUAGE == 'php' ]]; then # no build needed (for now) diff --git a/scripts/post-gen/global.sh b/scripts/post-gen/global.sh index 69c795f8299..0181cd848ae 100755 --- a/scripts/post-gen/global.sh +++ b/scripts/post-gen/global.sh @@ -6,6 +6,8 @@ set -e LANGUAGE=$1 if [[ $CI ]]; then + echo "Not running post-gen/global on CI for $LANGUAGE" + exit 0 fi From 75e24662f2196e279cf44ad095562576929a28a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 15 Feb 2022 11:53:22 +0100 Subject: [PATCH 3/4] should invalidate cache --- .../packages/client-common/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/algoliasearch-client-javascript/packages/client-common/package.json b/clients/algoliasearch-client-javascript/packages/client-common/package.json index df841ee4326..937d8bdc27e 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-common/package.json @@ -1,7 +1,7 @@ { "name": "@algolia/client-common", "version": "5.0.0", - "description": "Common package for the Algolia JavaScript API client.", + "description": "Common package for the Algolia JavaScript API client. wouhou", "repository": "algolia/algoliasearch-client-javascript", "author": "Algolia", "private": true, From 2900b2134a752eb5dfe7429318b42d9329ccadad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 15 Feb 2022 12:07:12 +0100 Subject: [PATCH 4/4] Revert "should invalidate cache" This reverts commit 75e24662f2196e279cf44ad095562576929a28a1. --- .../packages/client-common/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/algoliasearch-client-javascript/packages/client-common/package.json b/clients/algoliasearch-client-javascript/packages/client-common/package.json index 937d8bdc27e..df841ee4326 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-common/package.json @@ -1,7 +1,7 @@ { "name": "@algolia/client-common", "version": "5.0.0", - "description": "Common package for the Algolia JavaScript API client. wouhou", + "description": "Common package for the Algolia JavaScript API client.", "repository": "algolia/algoliasearch-client-javascript", "author": "Algolia", "private": true,