1
0
Fork 0
docsearch/.circleci/config.yml

166 lines
4.4 KiB
YAML

version: 2.1
aliases:
- &install_yarn_version
name: Install specific Yarn version
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.5
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 --frozen-lockfile
- &restore_dist_folders
name: Restore dist folders
command: |
set -exu
mkdir -p packages/docsearch-react/dist
mkdir -p packages/docsearch-js/dist
mkdir -p packages/docsearch-css/dist
cp -R /tmp/workspace/packages/docsearch-react/dist packages/docsearch-react
cp -R /tmp/workspace/packages/docsearch-js/dist packages/docsearch-js
cp -R /tmp/workspace/packages/docsearch-css/dist packages/docsearch-css
defaults: &defaults
working_directory: ~/docsearch
docker:
- image: cimg/node:16.13.0
cypress: &cypress
working_directory: ~/docsearch
docker:
- image: cypress/browsers:node13.8.0-chrome81-ff75
environment:
## this enables colors in the output
TERM: xterm
references:
workspace_root: &workspace_root /tmp/workspace
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root
jobs:
build:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Build and Size
command: |
yarn run build
yarn run test:size
- run:
name: Move dist folders to workspace
command: |
set -exu
mkdir -p /tmp/workspace/packages/docsearch-react/dist
mkdir -p /tmp/workspace/packages/docsearch-js/dist
mkdir -p /tmp/workspace/packages/docsearch-css/dist
cp -R packages/docsearch-react/dist /tmp/workspace/packages/docsearch-react
cp -R packages/docsearch-js/dist /tmp/workspace/packages/docsearch-js
cp -R packages/docsearch-css/dist /tmp/workspace/packages/docsearch-css
- persist_to_workspace:
root: *workspace_root
paths:
- packages
test_lint:
<<: *defaults
steps:
- checkout
- *attach_workspace
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run: *restore_dist_folders
- run:
name: Linting
command: yarn run lint
test_types:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Type checking
command: yarn run test:types
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: Unit tests
command: yarn run test --maxWorkers=4
release:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Release if needed
command: yarn run shipjs trigger
test_cypress:
<<: *cypress
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Cypress test Actions
command: yarn run cy:run
- store_test_results:
path: cypress-results
- store_artifacts:
path: cypress\screenshots
- store_artifacts:
path: cypress\videos
workflows:
version: 2.1
ci:
jobs:
- build
- test_lint:
requires:
- build
- test_types
- test_unit
# TODO: Enable again once Cypress is installed on the repo.
# - test_cypress
- release:
filters:
branches:
only: next