Skip to content
Merged
4 changes: 2 additions & 2 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -80,6 +81,10 @@ runs:
echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_CLIENT::$run"

if [[ $base_changed == 'true' || 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
Expand Down Expand Up @@ -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 }}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -98,6 +99,39 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn build:clients javascript ${{ matrix.client.name }}

client_javascript_common:
Copy link
Member Author

Choose a reason for hiding this comment

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

We should be able to group jobs after #135

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
Expand Down Expand Up @@ -172,6 +206,7 @@ jobs:
timeout-minutes: 20
needs:
- client_javascript
- client_javascript_common
- client_java
- client_php

Expand Down
2 changes: 0 additions & 2 deletions scripts/builds/clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions scripts/post-gen/global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -e
LANGUAGE=$1

if [[ $CI ]]; then
echo "Not running post-gen/global on CI for $LANGUAGE"

exit 0
fi

Expand Down