diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index de14ead2b9..cbd1c8eab5 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -4,110 +4,107 @@ description: Restore cached dependencies. inputs: job: - description: The job that requires this composite + description: The job that requires this composite. required: false language: - description: The language to retrieve dependencies + description: The language to retrieve dependencies. required: false default: javascript - spec: - description: The spec name to restore - required: false runs: using: composite steps: # restore clients - name: Restore built JavaScript common client - if: ${{ inputs.job == 'cts' }} + if: ${{ inputs.job == 'cts' || inputs.job == 'javascript-client' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-common/dist - key: ${{ runner.os }}-1-js-client-common-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-common/**') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-common-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-common/**') }} - name: Restore built JavaScript node requester - if: ${{ inputs.job == 'cts' }} + if: ${{ inputs.job == 'cts' || inputs.job == 'javascript-client' }} 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-requester-node-http-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-node-http/**') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-requester-node-http-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-node-http/**') }} - name: Restore built JavaScript browser requester - if: ${{ inputs.job == 'cts' }} + if: ${{ inputs.job == 'cts' || inputs.job == 'javascript-client' }} 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-requester-browser-xhr-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-browser-xhr/**') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-requester-browser-xhr-${{ hashFiles('clients/algoliasearch-client-javascript/packages/requester-browser-xhr/**') }} - name: Restore built JavaScript search client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-search/dist - key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/bundled/search.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/bundled/search.yml') }} - name: Restore built JavaScript recommend client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/recommend/dist - key: ${{ runner.os }}-1-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/bundled/recommend.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/bundled/recommend.yml') }} - name: Restore built JavaScript query-suggestions client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-query-suggestions/dist - key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/bundled/query-suggestions.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/bundled/query-suggestions.yml') }} - name: Restore built JavaScript personalization client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-personalization/dist - key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/bundled/personalization.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/bundled/personalization.yml') }} - name: Restore built JavaScript analytics client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-analytics/dist - key: ${{ runner.os }}-1-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/bundled/analytics.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/bundled/analytics.yml') }} - name: Restore built JavaScript abtesting client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-abtesting/dist - key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/bundled/abtesting.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/bundled/abtesting.yml') }} - name: Restore built JavaScript insights client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-insights/dist - key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/bundled/insights.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/bundled/insights.yml') }} - name: Restore built JavaScript sources client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-sources/dist - key: ${{ runner.os }}-1-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/bundled/sources.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/bundled/sources.yml') }} - name: Restore built JavaScript predict client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-predict/dist - key: ${{ runner.os }}-1-js-client-predict-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-predict/**') }}-${{ hashFiles('specs/dist/predict.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-predict-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-predict/**') }}-${{ hashFiles('specs/dist/predict.yml') }} - name: Restore built Java client if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-java-2/target - key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/bundled/search.yml') }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/bundled/search.yml') }} # setup yarn - name: Get yarn cache directory path @@ -119,7 +116,7 @@ runs: uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir.outputs.dir || '/home/runner/work/api-clients-automation/api-clients-automation/.yarn/cache' }} - key: node-cache-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + key: node-cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} - name: Install JavaScript dependencies shell: bash diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1af6f69232..f61eec366a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,6 +7,9 @@ on: branches: - main +env: + CACHE_VERSION: '5' + concurrency: group: ${{ github.ref }} cancel-in-progress: true @@ -62,15 +65,17 @@ jobs: - name: Check diff with pushed spec run: exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l) - client_javascript: + client_javascript_common: timeout-minutes: 10 runs-on: ubuntu-20.04 - needs: - - setup - - specs - if: ${{ always() && needs.setup.outputs.RUN_JS == 'true' }} + needs: setup + if: ${{ always() && needs.setup.outputs.RUN_JS_COMMON == 'true' }} strategy: - matrix: ${{ fromJSON(needs.setup.outputs.JS_MATRIX) }} + matrix: + client: + - client-common + - requester-browser-xhr + - requester-node-http steps: - uses: actions/checkout@v2 @@ -78,59 +83,54 @@ jobs: uses: ./.github/actions/cache with: job: client - spec: ${{ matrix.client.name }} - - name: Cache ${{ matrix.client.name }} client + - name: Cache ${{ matrix.client }} client id: cache uses: actions/cache@v2 with: - path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist' - key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }} - - - name: Generate ${{ matrix.client.name }} client - if: steps.cache.outputs.cache-hit != 'true' - run: yarn generate javascript ${{ matrix.client.name }} - - - name: Check diff with pushed client - if: steps.cache.outputs.cache-hit != 'true' - run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) + path: '/home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/${{ matrix.client }}/dist' + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-${{ matrix.client }}-${{ hashFiles(format('clients/algoliasearch-client-javascript/packages/{0}/**', matrix.client)) }} - - name: Build ${{ matrix.client.name }} client + - name: Build ${{ matrix.client }} client if: steps.cache.outputs.cache-hit != 'true' - run: yarn build:clients javascript ${{ matrix.client.name }} + run: yarn workspace algoliasearch-client-javascript build:utils ${{ matrix.client }} - client_javascript_common: + client_javascript: timeout-minutes: 10 runs-on: ubuntu-20.04 needs: - setup - specs - if: ${{ always() && needs.setup.outputs.RUN_JS_COMMON == 'true' }} + - client_javascript_common + if: ${{ always() && needs.setup.outputs.RUN_JS == 'true' }} strategy: - matrix: - client: - - client-common - - requester-browser-xhr - - requester-node-http + matrix: ${{ fromJSON(needs.setup.outputs.JS_MATRIX) }} steps: - uses: actions/checkout@v2 - name: Restore cache uses: ./.github/actions/cache with: - job: client - spec: ${{ matrix.client }} + job: javascript-client - - name: Cache ${{ matrix.client }} client + - name: Cache ${{ matrix.client.name }} 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)) }} + path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist' + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }} - - name: Build ${{ matrix.client }} client + - name: Generate ${{ matrix.client.name }} client + if: steps.cache.outputs.cache-hit != 'true' + run: yarn generate javascript ${{ matrix.client.name }} + + - name: Check diff with pushed client if: steps.cache.outputs.cache-hit != 'true' - run: yarn workspace @algolia/${{ matrix.client }} build + run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) + + - name: Build ${{ matrix.client.name }} client + if: steps.cache.outputs.cache-hit != 'true' + run: yarn build:clients javascript ${{ matrix.client.name }} client_java: runs-on: ubuntu-20.04 @@ -149,14 +149,13 @@ jobs: with: job: client language: java - spec: ${{ matrix.client.name }} - name: Cache ${{ matrix.client.name }} client id: cache uses: actions/cache@v2 with: path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/target' - key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }} + key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }} - name: Generate ${{ matrix.client.name }} client if: steps.cache.outputs.cache-hit != 'true' @@ -187,7 +186,6 @@ jobs: with: job: client language: php - spec: ${{ matrix.client.name }} - name: Generate ${{ matrix.client.name }} client if: steps.cache.outputs.cache-hit != 'true' @@ -206,10 +204,8 @@ jobs: timeout-minutes: 20 needs: - client_javascript - - client_javascript_common - client_java - client_php - if: ${{ always() && needs.setup.outputs.RUN_CTS == 'true' }} steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/process-release.yml b/.github/workflows/process-release.yml index 4824cfbb77..c64be83316 100644 --- a/.github/workflows/process-release.yml +++ b/.github/workflows/process-release.yml @@ -1,8 +1,13 @@ name: Process release + on: issues: types: - closed + +env: + CACHE_VERSION: '5' + jobs: build: name: Release diff --git a/clients/algoliasearch-client-javascript/package.json b/clients/algoliasearch-client-javascript/package.json index 8bb5e7e982..69cd7909f4 100644 --- a/clients/algoliasearch-client-javascript/package.json +++ b/clients/algoliasearch-client-javascript/package.json @@ -6,7 +6,7 @@ ], "private": true, "scripts": { - "build:utils": "BUILD_UTILS=true yarn rollup -c rollup.config.js", + "build:utils": "UTILS=${0:-all} yarn rollup -c rollup.config.js", "build": "CLIENT=${0:-all} yarn rollup -c rollup.config.js", "clean:utils": "yarn workspace @algolia/client-common clean && yarn workspace @algolia/requester-node-http clean && yarn workspace @algolia/requester-browser-xhr clean", "clean": "rm -rf packages/*/dist", diff --git a/clients/algoliasearch-client-javascript/packages/client-common/package.json b/clients/algoliasearch-client-javascript/packages/client-common/package.json index 64259de23c..307dd2b583 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-common/package.json @@ -10,7 +10,6 @@ "module": "dist/client-common.esm.node.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc", "clean": "rm -rf dist/" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/requester-node-http/package.json b/clients/algoliasearch-client-javascript/packages/requester-node-http/package.json index 108dc7a844..8b122bd3b5 100644 --- a/clients/algoliasearch-client-javascript/packages/requester-node-http/package.json +++ b/clients/algoliasearch-client-javascript/packages/requester-node-http/package.json @@ -10,7 +10,6 @@ "module": "dist/requester-node-http.esm.node.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc", "clean": "rm -rf dist/" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/rollup.config.js b/clients/algoliasearch-client-javascript/rollup.config.js index b69f8787af..28be4d6329 100644 --- a/clients/algoliasearch-client-javascript/rollup.config.js +++ b/clients/algoliasearch-client-javascript/rollup.config.js @@ -13,7 +13,7 @@ import { version } from './version'; // Retrieve package to build const client = process.env.CLIENT?.replace('@algolia/', ''); -const onlyBuildUtils = Boolean(process.env.BUILD_UTILS); +const utils = process.env.UTILS; function createLicence(name) { return `/*! ${name}.umd.js | ${version} | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */`; @@ -62,7 +62,7 @@ function getAvailableClients() { } function initPackagesConfig() { - if (onlyBuildUtils) { + if (utils) { const commonOptions = { input: 'index.ts', formats: ['cjs-node', 'esm-node'], @@ -70,7 +70,7 @@ function initPackagesConfig() { dependencies: [], }; - return [ + const availableUtils = [ // Common { ...commonOptions, @@ -97,6 +97,12 @@ function initPackagesConfig() { dependencies: ['@algolia/client-common'], }, ]; + + return utils === 'all' + ? availableUtils + : availableUtils.filter( + (availableUtil) => availableUtil.package === utils + ); } const availableClients = getAvailableClients();