From 5bbdc826b8c90e8bf34df4a6c42893f9119770ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 5 Jan 2022 10:39:20 +0100 Subject: [PATCH 1/3] feat(ci): add cache and job skip --- .github/actions/cache/action.yml | 76 +++++++++++--- .github/actions/setup/action.yml | 95 +++++++++++++++-- .github/workflows/check.yml | 172 +++++++++++++++++++++++++++---- .yamllint | 29 ------ 4 files changed, 302 insertions(+), 70 deletions(-) delete mode 100644 .yamllint diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index eb261f8b698..b11cf0a82cd 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -2,29 +2,79 @@ name: Cache description: Restore cached dependencies. +inputs: + job: + description: 'The job that requires this composite' + required: true + default: 'setup' + runs: using: composite steps: - - name: Get yarn cache directory path - shell: bash - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + # restore clients + - 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/client-search/** + key: ${{ runner.os }}-js-client-search-${{ hashFiles('yarn.lock') }} - - name: Restore yarn cache + - name: Restore built JavaScript recommend client + if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 - id: yarn-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/recommend/** + key: ${{ runner.os }}-js-client-recommend-${{ hashFiles('yarn.lock') }} - - name: Restore node_modules + - name: Restore built JavaScript personalization client + if: ${{ inputs.job == 'cts' }} uses: actions/cache@v2 with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-personalization/** + key: ${{ runner.os }}-js-client-personalization-${{ hashFiles('yarn.lock') }} - - name: Restore maven dependencies + - 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/client-analytics/** + key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('yarn.lock') }} + + - 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/** + key: ${{ runner.os }}-java-client-${{ hashFiles('**/pom.xml') }} + + # setup yarn + - name: Get yarn cache directory path + if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} + shell: bash + id: yarn-cache-dir + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + + - name: Restore Yarn + if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} + 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') }} + + - name: Install JavaScript dependencies + if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} + shell: bash + run: yarn install + + # setup maven + - name: Restore Maven + if: ${{ inputs.job == 'setup' || inputs.job == 'java' }} uses: actions/cache@v2 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + key: setup-java-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Install Maven dependencies + if: ${{ inputs.job == 'setup' || inputs.job == 'java' }} + shell: bash + run: mvn clean install -f clients/algoliasearch-client-java-2/pom.xml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 8a737a34cf4..e7736677868 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -5,24 +5,101 @@ description: Setup CI environment. runs: using: composite steps: - - name: Restore cache - uses: ./.github/actions/cache - - - name: Update apt packages - shell: bash - run: sudo apt update - - name: Install Java uses: actions/setup-java@v2 with: distribution: zulu java-version: 11.0.4 + cache: maven - name: Install Node uses: actions/setup-node@v2 with: node-version-file: .nvmrc + cache: yarn - - name: Install JavaScript Dependencies + - name: Restore cache + uses: ./.github/actions/cache + + - name: Setting diff outputs variables + id: diff shell: bash - run: yarn install + run: | + echo "::set-output name=GITHUB_ACTIONS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- .github/actions .github/workflows | wc -l)" + + echo "::set-output name=SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs | wc -l)" + echo "::set-output name=SEARCH_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/search | wc -l)" + echo "::set-output name=RECOMMEND_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/recommend | wc -l)" + echo "::set-output name=QS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/query_suggestions | wc -l)" + echo "::set-output name=PERSO_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/personalization | wc -l)" + echo "::set-output name=INSIGHTS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/insights | wc -l)" + echo "::set-output name=ANALYTICS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/analytics | wc -l)" + echo "::set-output name=AB_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/abtesting | wc -l)" + + echo "::set-output name=TESTS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- tests | wc -l)" + + 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_SEARCH_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-search | wc -l)" + echo "::set-output name=JS_RECOMMEND_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/recommend | wc -l)" + echo "::set-output name=JS_PERSO_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-personalization | wc -l)" + echo "::set-output name=JS_ANALYTICS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-analytics | 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)" + echo "::set-output name=JAVA_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/java | wc -l)" + +outputs: + # specs variables + RUN_SPECS: + description: 'Determine if the `specs_*` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 }} + RUN_SPECS_SEARCH: + description: 'Determine if the `specs_search` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 }} + RUN_SPECS_RECOMMEND: + description: 'Determine if the `specs_recommend` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 }} + RUN_SPECS_QS: + description: 'Determine if the `specs_qs` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.QS_SPECS_CHANGED > 0 }} + RUN_SPECS_PERSO: + description: 'Determine if the `specs_perso` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 }} + RUN_SPECS_INSIGHTS: + description: 'Determine if the `specs_insights` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 }} + RUN_SPECS_ANALYTICS: + description: 'Determine if the `specs_analytics` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }} + RUN_SPECS_AB: + description: 'Determine if the `specs_ab` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }} + + # js client variables + RUN_JS_CLIENT: + description: 'Determine if the `client_javascript_*` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + RUN_JS_CLIENT_SEARCH: + description: 'Determine if the `client_javascript_search` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + RUN_JS_CLIENT_RECOMMEND: + description: 'Determine if the `client_javascript_recommend` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + RUN_JS_CLIENT_PERSO: + description: 'Determine if the `client_javascript_perso` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + RUN_JS_CLIENT_ANALYTICS: + description: 'Determine if the `client_javascript_analytics` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + + # java client variables + RUN_JAVA_CLIENT: + description: 'Determine if the `client_java_*` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} + + # cts variables + RUN_CTS: + description: 'Determine if the `cts` job should run' + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.CTS_CHANGED > 0 || steps.diff.outputs.JS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a3cc084a2cd..5ce2e98335a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,8 @@ name: Checks -on: [push] +on: + pull_request: + types: [opened, synchronize, closed] concurrency: group: ${{ github.ref }} @@ -11,42 +13,103 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Setup + id: setup uses: ./.github/actions/setup - - specs: + outputs: + RUN_SPECS: ${{ steps.setup.outputs.RUN_SPECS }} + RUN_SPECS_SEARCH: ${{ steps.setup.outputs.RUN_SPECS_SEARCH }} + RUN_SPECS_RECOMMEND: ${{ steps.setup.outputs.RUN_SPECS_RECOMMEND }} + RUN_SPECS_QS: ${{ steps.setup.outputs.RUN_SPECS_QS }} + RUN_SPECS_PERSO: ${{ steps.setup.outputs.RUN_SPECS_PERSO }} + RUN_SPECS_INSIGHTS: ${{ steps.setup.outputs.RUN_SPECS_INSIGHTS }} + RUN_SPECS_ANALYTICS: ${{ steps.setup.outputs.RUN_SPECS_ANALYTICS }} + RUN_SPECS_AB: ${{ steps.setup.outputs.RUN_SPECS_AB }} + + RUN_JS_CLIENT: ${{ steps.setup.outputs.RUN_JS_CLIENT }} + RUN_JS_CLIENT_SEARCH: ${{ steps.setup.outputs.RUN_JS_CLIENT_SEARCH }} + RUN_JS_CLIENT_RECOMMEND: ${{ steps.setup.outputs.RUN_JS_CLIENT_RECOMMEND }} + RUN_JS_CLIENT_PERSO: ${{ steps.setup.outputs.RUN_JS_CLIENT_PERSO }} + RUN_JS_CLIENT_ANALYTICS: ${{ steps.setup.outputs.RUN_JS_CLIENT_ANALYTICS }} + + RUN_JAVA_CLIENT: ${{ steps.setup.outputs.RUN_JAVA_CLIENT }} + + RUN_CTS: ${{ steps.setup.outputs.RUN_CTS }} + + specs_search: runs-on: ubuntu-20.04 needs: setup + if: ${{ always() && needs.setup.outputs.RUN_SPECS_SEARCH == 'true' }} steps: - uses: actions/checkout@v2 - name: Restore cache uses: ./.github/actions/cache + with: + job: js - name: Checking search specs run: yarn build:specs search + specs_recommend: + runs-on: ubuntu-20.04 + needs: setup + if: ${{ always() && needs.setup.outputs.RUN_SPECS_RECOMMEND == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Checking recommend specs run: yarn build:specs recommend + specs_perso: + runs-on: ubuntu-20.04 + needs: setup + if: ${{ always() && needs.setup.outputs.RUN_SPECS_PERSO == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Checking personalization specs run: yarn build:specs personalization + specs_analytics: + runs-on: ubuntu-20.04 + needs: setup + if: ${{ always() && needs.setup.outputs.RUN_SPECS_ANALYTICS == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Checking analytics specs run: yarn build:specs analytics - - name: Lint - run: yarn specs:lint - - client_javascript: + client_javascript_search: runs-on: ubuntu-20.04 - needs: [setup, specs] + needs: [specs_search] + if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_SEARCH == 'true' }} steps: - uses: actions/checkout@v2 - name: Restore cache uses: ./.github/actions/cache + with: + job: js - name: Generate search client run: yarn generate javascript search @@ -54,35 +117,95 @@ jobs: - name: Build search client run: yarn build:clients javascript search + - name: Cache search client + uses: actions/cache@v2 + with: + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-search/** + key: ${{ runner.os }}-js-client-search-${{ hashFiles('yarn.lock') }} + + client_javascript_recommend: + runs-on: ubuntu-20.04 + needs: [specs_recommend] + if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_RECOMMEND == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Generate recommend client run: yarn generate javascript recommend - name: Build recommend client run: yarn build:clients javascript recommend + - name: Cache recommend client + uses: actions/cache@v2 + with: + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/recommend/** + key: ${{ runner.os }}-js-client-recommend-${{ hashFiles('yarn.lock') }} + + client_javascript_perso: + runs-on: ubuntu-20.04 + needs: [specs_perso] + if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_PERSO == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Generate personalization client run: yarn generate javascript personalization - name: Build personalization client run: yarn build:clients javascript personalization + - name: Cache personalization client + uses: actions/cache@v2 + with: + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-personalization/** + key: ${{ runner.os }}-js-client-personalization-${{ hashFiles('yarn.lock') }} + + client_javascript_analytics: + runs-on: ubuntu-20.04 + needs: [specs_analytics] + if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_ANALYTICS == 'true' }} + steps: + - uses: actions/checkout@v2 + + - name: Restore cache + uses: ./.github/actions/cache + with: + job: js + - name: Generate analytics client run: yarn generate javascript analytics - name: Build analytics client run: yarn build:clients javascript analytics - - name: Lint - run: yarn lint + - name: Cache analytics client + uses: actions/cache@v2 + with: + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-analytics//** + key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('yarn.lock') }} - client_java: + client_java_search: runs-on: ubuntu-20.04 - needs: [setup, specs] + needs: [specs_search] + if: ${{ always() && needs.setup.outputs.RUN_JAVA_CLIENT == 'true' }} steps: - uses: actions/checkout@v2 - name: Restore cache uses: ./.github/actions/cache + with: + job: java - name: Generate search client run: yarn generate java search @@ -90,20 +213,31 @@ jobs: - name: Build search client run: yarn build:clients java search + - name: Cache built clients + uses: actions/cache@v2 + with: + path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-java-2/** + key: ${{ runner.os }}-java-client-${{ hashFiles('**/pom.xml') }} + cts: runs-on: ubuntu-20.04 - needs: [setup, specs, client_javascript, client_java] + needs: + [ + client_javascript_search, + client_javascript_recommend, + client_javascript_perso, + client_javascript_analytics, + client_java_search, + ] + if: ${{ always() && needs.setup.outputs.RUN_CTS == 'true' }} steps: - uses: actions/checkout@v2 - name: Restore cache + id: restore uses: ./.github/actions/cache - - - name: Generate clients - run: yarn generate - - - name: Build client - run: yarn build:clients + with: + job: cts - name: Generate CTS run: yarn cts:generate diff --git a/.yamllint b/.yamllint deleted file mode 100644 index 936003eef68..00000000000 --- a/.yamllint +++ /dev/null @@ -1,29 +0,0 @@ ---- -yaml-files: - - '*.yml' - -rules: - line-length: disable - braces: enable - brackets: enable - colons: enable - commas: enable - comments: - level: warning - comments-indentation: - level: warning - document-end: disable - document-start: { present: false } - empty-lines: enable - empty-values: disable - hyphens: enable - indentation: enable - key-duplicates: enable - key-ordering: disable - new-line-at-end-of-file: enable - new-lines: enable - octal-values: disable - quoted-strings: disable - trailing-spaces: enable - truthy: - level: warning From 335695916f87c3923f263e268e5b610fd7bff7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 5 Jan 2022 14:01:45 +0100 Subject: [PATCH 2/3] fix: remove unused output variables, fix clients conditions --- .github/actions/setup/action.yml | 16 +++++----------- .github/workflows/check.yml | 2 -- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index e7736677868..21f6af1a3c8 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -52,9 +52,6 @@ runs: outputs: # specs variables - RUN_SPECS: - description: 'Determine if the `specs_*` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 }} RUN_SPECS_SEARCH: description: 'Determine if the `specs_search` job should run' value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 }} @@ -78,26 +75,23 @@ outputs: value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }} # js client variables - RUN_JS_CLIENT: - description: 'Determine if the `client_javascript_*` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_SEARCH: description: 'Determine if the `client_javascript_search` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_RECOMMEND: description: 'Determine if the `client_javascript_recommend` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_PERSO: description: 'Determine if the `client_javascript_perso` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_ANALYTICS: description: 'Determine if the `client_javascript_analytics` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} # java client variables RUN_JAVA_CLIENT: description: 'Determine if the `client_java_*` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} # cts variables RUN_CTS: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5ce2e98335a..595b6eedda5 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,7 +20,6 @@ jobs: id: setup uses: ./.github/actions/setup outputs: - RUN_SPECS: ${{ steps.setup.outputs.RUN_SPECS }} RUN_SPECS_SEARCH: ${{ steps.setup.outputs.RUN_SPECS_SEARCH }} RUN_SPECS_RECOMMEND: ${{ steps.setup.outputs.RUN_SPECS_RECOMMEND }} RUN_SPECS_QS: ${{ steps.setup.outputs.RUN_SPECS_QS }} @@ -29,7 +28,6 @@ jobs: RUN_SPECS_ANALYTICS: ${{ steps.setup.outputs.RUN_SPECS_ANALYTICS }} RUN_SPECS_AB: ${{ steps.setup.outputs.RUN_SPECS_AB }} - RUN_JS_CLIENT: ${{ steps.setup.outputs.RUN_JS_CLIENT }} RUN_JS_CLIENT_SEARCH: ${{ steps.setup.outputs.RUN_JS_CLIENT_SEARCH }} RUN_JS_CLIENT_RECOMMEND: ${{ steps.setup.outputs.RUN_JS_CLIENT_RECOMMEND }} RUN_JS_CLIENT_PERSO: ${{ steps.setup.outputs.RUN_JS_CLIENT_PERSO }} From 96442bbce13d0b5379838c9a16e9b44c4295f6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 5 Jan 2022 16:46:17 +0100 Subject: [PATCH 3/3] apply changes from suggestion --- .github/actions/cache/action.yml | 9 +++------ .github/actions/setup/action.yml | 25 +++++++++++++------------ .github/workflows/check.yml | 23 ++++------------------- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index b11cf0a82cd..d4a0edf6a70 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -6,7 +6,7 @@ inputs: job: description: 'The job that requires this composite' required: true - default: 'setup' + default: 'cts' runs: using: composite @@ -49,32 +49,29 @@ runs: # setup yarn - name: Get yarn cache directory path - if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} shell: bash id: yarn-cache-dir run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - name: Restore Yarn - if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} 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') }} - name: Install JavaScript dependencies - if: ${{ inputs.job == 'cts' || inputs.job == 'setup' || inputs.job == 'java' || inputs.job == 'js' }} shell: bash run: yarn install # setup maven - name: Restore Maven - if: ${{ inputs.job == 'setup' || inputs.job == 'java' }} + if: ${{ inputs.job == 'java' }} uses: actions/cache@v2 with: path: ~/.m2/repository key: setup-java-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - name: Install Maven dependencies - if: ${{ inputs.job == 'setup' || inputs.job == 'java' }} + if: ${{ inputs.job == 'java' }} shell: bash run: mvn clean install -f clients/algoliasearch-client-java-2/pom.xml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 21f6af1a3c8..0e7c6eff728 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -28,6 +28,7 @@ runs: echo "::set-output name=GITHUB_ACTIONS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- .github/actions .github/workflows | wc -l)" echo "::set-output name=SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs | wc -l)" + echo "::set-output name=COMMON_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/common | wc -l)" echo "::set-output name=SEARCH_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/search | wc -l)" echo "::set-output name=RECOMMEND_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/recommend | wc -l)" echo "::set-output name=QS_SPECS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/query_suggestions | wc -l)" @@ -54,44 +55,44 @@ outputs: # specs variables RUN_SPECS_SEARCH: description: 'Determine if the `specs_search` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 }} RUN_SPECS_RECOMMEND: description: 'Determine if the `specs_recommend` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 }} RUN_SPECS_QS: description: 'Determine if the `specs_qs` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.QS_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.QS_SPECS_CHANGED > 0 }} RUN_SPECS_PERSO: description: 'Determine if the `specs_perso` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 }} RUN_SPECS_INSIGHTS: description: 'Determine if the `specs_insights` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 }} RUN_SPECS_ANALYTICS: description: 'Determine if the `specs_analytics` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }} RUN_SPECS_AB: description: 'Determine if the `specs_ab` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }} # js client variables RUN_JS_CLIENT_SEARCH: description: 'Determine if the `client_javascript_search` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_RECOMMEND: description: 'Determine if the `client_javascript_recommend` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_PERSO: description: 'Determine if the `client_javascript_perso` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} RUN_JS_CLIENT_ANALYTICS: description: 'Determine if the `client_javascript_analytics` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }} # java client variables RUN_JAVA_CLIENT: description: 'Determine if the `client_java_*` job should run' - value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} + value: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }} # cts variables RUN_CTS: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 595b6eedda5..cad1dd69ba0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -2,7 +2,10 @@ name: Checks on: pull_request: - types: [opened, synchronize, closed] + types: [opened, synchronize] + push: + branches: + - main concurrency: group: ${{ github.ref }} @@ -46,8 +49,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Checking search specs run: yarn build:specs search @@ -61,8 +62,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Checking recommend specs run: yarn build:specs recommend @@ -76,8 +75,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Checking personalization specs run: yarn build:specs personalization @@ -91,8 +88,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Checking analytics specs run: yarn build:specs analytics @@ -106,8 +101,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Generate search client run: yarn generate javascript search @@ -130,8 +123,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Generate recommend client run: yarn generate javascript recommend @@ -154,8 +145,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Generate personalization client run: yarn generate javascript personalization @@ -178,8 +167,6 @@ jobs: - name: Restore cache uses: ./.github/actions/cache - with: - job: js - name: Generate analytics client run: yarn generate javascript analytics @@ -234,8 +221,6 @@ jobs: - name: Restore cache id: restore uses: ./.github/actions/cache - with: - job: cts - name: Generate CTS run: yarn cts:generate