fix(specs): Change trigger input for task update #10587
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Checks | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
push: | |
branches: | |
- main | |
merge_group: | |
types: [checks_requested] | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
# Uncomment the line below to enable artifacts debugging | |
# env: | |
# ACTIONS_RUNNER_DEBUG: true | |
jobs: | |
setup: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- name: debugging - dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup | |
id: setup | |
uses: ./.github/actions/setup | |
with: | |
type: matrix | |
- name: Lint GitHub actions | |
run: yarn github-actions:lint | |
- name: Lint generators | |
run: | | |
yarn cli format java generators | |
diff=$(git status --porcelain ./generators | wc -l) | |
if [[ $diff > 0 ]]; then | |
echo "Format the generators folder by running 'yarn docker format java generators'" | |
fi | |
exit $diff | |
- name: Lint json files | |
run: | | |
yarn eslint --ext=json . | |
echo 'Use yarn fix:json to fix issues' | |
outputs: | |
RUN_SCRIPTS: ${{ steps.setup.outputs.RUN_SCRIPTS }} | |
SPECS_MATRIX: ${{ steps.setup.outputs.SPECS_MATRIX }} | |
RUN_GEN: ${{ steps.setup.outputs.RUN_GEN }} | |
GEN_MATRIX: ${{ steps.setup.outputs.GEN_MATRIX }} | |
RUN_GEN_JAVASCRIPT: ${{ steps.setup.outputs.RUN_GEN_JAVASCRIPT }} | |
RUN_GEN_JAVA: ${{ steps.setup.outputs.RUN_GEN_JAVA }} | |
RUN_GEN_PHP: ${{ steps.setup.outputs.RUN_GEN_PHP }} | |
RUN_GEN_GO: ${{ steps.setup.outputs.RUN_GEN_GO }} | |
RUN_GEN_KOTLIN: ${{ steps.setup.outputs.RUN_GEN_KOTLIN }} | |
RUN_GEN_DART: ${{ steps.setup.outputs.RUN_GEN_DART }} | |
RUN_JS_UTILS: ${{ steps.setup.outputs.RUN_JS_UTILS }} | |
RUN_CODEGEN: ${{ steps.setup.outputs.RUN_CODEGEN }} | |
scripts: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
needs: setup | |
if: ${{ needs.setup.outputs.RUN_SCRIPTS == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
type: minimal | |
- name: Check script linting | |
run: yarn scripts:lint | |
- name: Test scripts | |
run: yarn scripts:test | |
- name: Test custom eslint plugin | |
run: yarn workspace eslint-plugin-automation-custom test | |
specs: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
needs: setup | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache bundled specs | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
key: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).cacheKey }} | |
path: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).bundledPath }} | |
- name: Setup | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: ./.github/actions/setup | |
with: | |
type: minimal | |
- name: Building specs | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }} | |
- name: Store bundled specs | |
uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: specs | |
path: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).bundledPath }} | |
client_javascript_utils: | |
timeout-minutes: 10 | |
runs-on: ubuntu-22.04 | |
needs: setup | |
if: ${{ needs.setup.outputs.RUN_JS_UTILS == 'true' }} | |
strategy: | |
matrix: | |
client: | |
- client-common | |
- requester-browser-xhr | |
- requester-node-http | |
- requester-fetch | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache '${{ matrix.client }}' client folder | |
if: ${{ github.ref != 'refs/heads/main' }} | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
key: | | |
${{ matrix.client }}-${{ hashFiles( | |
format('clients/algoliasearch-client-javascript/packages/{0}/**', matrix.client), | |
'clients/algoliasearch-client-javascript/yarn.lock' | |
)}} | |
path: clients/algoliasearch-client-javascript/packages/${{ matrix.client }} | |
- name: Remove generated clients | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: cd clients/algoliasearch-client-javascript/packages && ls | grep -v -E "(client-common|requester-*)" | xargs rm -rf | |
- name: Setup | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: ./.github/actions/setup | |
with: | |
type: minimal | |
language: javascript | |
- name: Build '${{ matrix.client }}' client | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: cd clients/algoliasearch-client-javascript && yarn build:many @algolia/${{ matrix.client }} | |
- name: Run tests for '${{ matrix.client }}' | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: cd clients/algoliasearch-client-javascript && yarn workspace @algolia/${{ matrix.client }} test | |
client_gen: | |
timeout-minutes: 15 | |
runs-on: ubuntu-22.04 | |
needs: | |
- setup | |
- specs | |
- scripts | |
- client_javascript_utils | |
if: | | |
always() && | |
needs.setup.outputs.RUN_GEN == 'true' && | |
!contains(needs.*.result, 'cancelled') && | |
!contains(needs.*.result, 'failure') | |
strategy: | |
matrix: ${{ fromJSON(needs.setup.outputs.GEN_MATRIX) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache clients folder | |
if: ${{ github.ref != 'refs/heads/main' }} | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
key: ${{ matrix.client.cacheKey }} | |
path: ${{ matrix.client.path }} | |
- name: Download specs artifacts | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: ./.github/actions/restore-artifacts | |
with: | |
type: specs | |
- name: Remove generated clients | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' && startsWith(env.head_ref, 'chore/prepare-release-') }} | |
run: | | |
cd ${{ matrix.client.path }}/packages | |
ls | grep -v -E "(client-common|requester-*|algoliasearch)" | xargs rm -rf | |
cd algoliasearch | |
ls | grep -v -E "(__tests__|jest.config.ts)" | xargs rm -rf | |
- 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: ${{ matrix.client.buildCommand }} | |
- name: Test JavaScript bundle size | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' && startsWith(env.head_ref, 'chore/prepare-release-') }} | |
run: cd ${{ matrix.client.path }} && yarn test:size | |
- name: Run JavaScript 'algoliasearch' client tests | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' && contains(matrix.client.toRun,'algoliasearch') }} | |
run: cd ${{ matrix.client.path }} && yarn workspace algoliasearch test | |
- name: Run Java 'algoliasearch' public API validation | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'java' }} | |
run: | | |
cd ${{ matrix.client.path }} | |
./gradlew :api:japicmp || exit 0 | |
FILE=${{ matrix.client.path }}/api/build/reports/japi.txt | |
if [[ -f "$FILE" ]]; then | |
cat $FILE | |
fi | |
- name: Remove previous CTS output | |
run: rm -rf ${{ matrix.client.testsToDelete }} || true | |
- name: Generate CTS | |
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }} | |
# 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 "dir=$(cd ${{ matrix.client.testsRootFolder }} && yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- 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 }} | |
- name: Zip artifact before storing | |
run: zip -r -y clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsToStore }} -x "**/node_modules**" "**/.yarn/cache/**" "**/build/**" "**/dist/**" "**/.gradle/**" "**/bin/**" "**/vendor/**" | |
- name: Store ${{ matrix.client.language }} clients | |
uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: clients-${{matrix.client.language }} | |
path: clients-${{matrix.client.language }}.zip | |
codegen: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
needs: | |
- setup | |
- client_gen | |
if: | | |
always() && | |
!contains(needs.*.result, 'cancelled') && | |
!contains(needs.*.result, 'failure') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
token: ${{ secrets.ALGOLIA_BOT_TOKEN }} | |
- name: Download all artifacts | |
if: ${{ needs.setup.outputs.RUN_CODEGEN == 'true' }} | |
uses: ./.github/actions/restore-artifacts | |
with: | |
type: all | |
javascript: ${{ needs.setup.outputs.RUN_GEN_JAVASCRIPT }} | |
php: ${{ needs.setup.outputs.RUN_GEN_PHP }} | |
java: ${{ needs.setup.outputs.RUN_GEN_JAVA }} | |
go: ${{ needs.setup.outputs.RUN_GEN_GO }} | |
kotlin: ${{ needs.setup.outputs.RUN_GEN_KOTLIN }} | |
dart: ${{ needs.setup.outputs.RUN_GEN_DART }} | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
type: minimal | |
- name: Push generated code | |
id: pushGeneratedCode | |
run: yarn workspace scripts pushGeneratedCode | |
env: | |
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }} | |
PR_NUMBER: ${{ github.event.number }} | |
- name: Spread generation to each repository | |
if: ${{ steps.pushGeneratedCode.exitcode == 0 && github.ref == 'refs/heads/main' }} | |
run: yarn workspace scripts spreadGeneration | |
env: | |
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }} |