| aliases: |
| - &install_yarn_version |
| name: Install specific Yarn version |
| command: | |
| curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.16.0 |
| echo 'export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"' >> $BASH_ENV |
| |
| - &restore_yarn_cache |
| name: Restore Yarn cache |
| keys: |
| - yarn-{{ .Branch }}-packages-{{ checksum "yarn.lock" }} |
|
|
| - &save_yarn_cache |
| name: Save Yarn cache |
| key: yarn-{{ .Branch }}-packages-{{ checksum "yarn.lock" }} |
| paths: |
| - ~/.cache/yarn |
|
|
| - &run_yarn_install |
| name: Install dependencies |
| command: yarn install |
|
|
| defaults: &defaults |
| working_directory: ~/react-instantsearch |
| docker: |
| - image: cimg/node:12.22.7 |
|
|
| version: 2 |
| jobs: |
| test_build: |
| <<: *defaults |
| docker: |
| - image: cimg/node:14.18.2 |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Build & Test packages size |
| command: yarn test:build |
| - store_artifacts: |
| path: packages/react-instantsearch/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-core/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-dom/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-dom-maps/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-hooks/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-hooks-server/dist |
| - store_artifacts: |
| path: packages/react-instantsearch-native/dist |
|
|
| test_unit: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Lint & Code styles |
| command: yarn lint |
| - run: |
| name: Build |
| command: yarn build |
| - run: |
| name: Type checking |
| command: yarn type-check |
| - run: |
| name: Unit Tests |
| command: | |
| retry() { |
| MAX_RETRY=2 |
| n=0 |
| until [ $n -ge $MAX_RETRY ] |
| do |
| "$@" && break |
| n=$[$n+1] |
| done |
| if [ $n -ge $MAX_RETRY ]; then |
| exit 1 |
| fi |
| } |
| |
| |
| |
| retry yarn test --maxWorkers=4 |
| - store_test_results: |
| path: junit/jest/ |
|
|
| test_unit_react_v17: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Install React v17 dependencies |
| command: | |
| yarn add --force -DW \ |
| react@17.0.2 \ |
| @types/react@17.0.47 \ |
| react-dom@17.0.2 \ |
| @types/react-dom@17.0.17 \ |
| react-test-renderer@17.0.2 \ |
| @types/react-test-renderer@17.0.2 \ |
| @testing-library/react@12.1.4 |
| - run: |
| name: Unit Tests |
| command: | |
| retry() { |
| MAX_RETRY=2 |
| n=0 |
| until [ $n -ge $MAX_RETRY ] |
| do |
| "$@" && break |
| n=$[$n+1] |
| done |
| if [ $n -ge $MAX_RETRY ]; then |
| exit 1 |
| fi |
| } |
| |
| |
| |
| retry yarn test --maxWorkers=4 |
| - store_test_results: |
| path: junit/jest/ |
|
|
| test_unit_algoliasearch_v3: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Install algoliasearch v3 |
| command: | |
| rm -rf examples |
| yarn add -W -D @types/algoliasearch@3.34.8 algoliasearch@3.35.1 |
| - run: |
| name: Type checking |
| command: yarn type-check |
| - run: |
| name: Unit Tests |
| command: | |
| retry() { |
| MAX_RETRY=2 |
| n=0 |
| until [ $n -ge $MAX_RETRY ] |
| do |
| "$@" && break |
| n=$[$n+1] |
| done |
| if [ $n -ge $MAX_RETRY ]; then |
| exit 1 |
| fi |
| } |
| |
| |
| |
| retry yarn test --maxWorkers=4 |
| - store_test_results: |
| path: junit/jest/ |
|
|
| test_e2e: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: End-2-End tests |
| command: | |
| yarn run website:build |
| yarn run test:e2e:saucelabs |
| - store_test_results: |
| path: junit/wdio/ |
|
|
| test_examples: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Build libraries |
| command: yarn build |
| - run: |
| name: Build & Test examples |
| command: yarn test:examples |
|
|
| release_if_needed: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Trigger a release if the latest commit is a release commit |
| command: yarn shipjs trigger |
|
|
| prepare_release: |
| <<: *defaults |
| steps: |
| - checkout |
| - run: *install_yarn_version |
| - restore_cache: *restore_yarn_cache |
| - run: *run_yarn_install |
| - save_cache: *save_yarn_cache |
| - run: |
| name: Prepare a pull request for next release |
| command: | |
| git config --global user.email "instantsearch-bot@algolia.com" |
| git config --global user.name "InstantSearch" |
| yarn run release --yes --no-browse |
| |
| workflows: |
| version: 2 |
| ci: |
| jobs: |
| - test_build |
| - test_unit |
| - test_unit_react_v17 |
| - test_unit_algoliasearch_v3 |
| - test_e2e |
| - test_examples |
| - release_if_needed: |
| filters: |
| branches: |
| only: |
| - master |
| - next |
| scheduled_release: |
| triggers: |
| - schedule: |
| cron: '0 9 * * 2' |
| filters: |
| branches: |
| only: |
| - master |
| jobs: |
| - prepare_release |
|
|