1
0
Fork 0
docsearch/.circleci/config.yml
2024-11-04 10:14:12 +01:00

194 lines
5.1 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-packages-{{ checksum "yarn.lock" }}
- &save_yarn_cache
name: Save Yarn cache
key: yarn-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:18.20.3
cypress: &cypress
working_directory: ~/docsearch
docker:
- image: cypress/browsers:node-18.20.3-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1
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
- 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
- *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: Type checking
command: yarn run test:types
test_size:
<<: *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: Size checking
command: yarn run test:size
test_unit:
<<: *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: Unit tests
command: yarn run test --maxWorkers=4
release:
<<: *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: Setup git user
command: |
git config --global user.email "accounts+algolia-api-client-bot@algolia.com"
git config --global user.name "algolia-bot"
- run:
name: Release if needed
command: yarn run shipjs trigger
test_cypress:
<<: *cypress
steps:
- checkout
- *attach_workspace
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run: *restore_dist_folders
- run:
name: Cypress test Actions
command: yarn run cy:run
workflows:
version: 2
ci:
jobs:
- build
- test_lint:
requires:
- build
- test_types:
requires:
- build
- test_size:
requires:
- build
- test_unit:
requires:
- build
- test_cypress:
requires:
- build
- release:
requires:
- build
filters:
branches:
only: main