1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
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 --pure-lockfile --ignore-engines
defaults: &defaults
working_directory: ~/algoliasearch-client-javascript
parameters:
cimg_version:
type: string
node_version:
type: string
default: ''
docker:
- image: cimg/node:<< parameters.cimg_version >>
version: 2.1
jobs:
test_build:
description: Testing build & Test Size & Declarations File
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Build
command: yarn build
- run:
name: Test size
command: yarn test:build-size
- run:
name: Validate declarations
command: yarn test:build-declarations
test_lint:
description: Testing coding style
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Lint tests
command: yarn test:lint
test_types:
description: Testing type checking
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Lint tests
command: yarn test:types
test_unit:
description: Testing code against node << parameters.node_version >>
<<: *defaults
steps:
- checkout
- run:
name: Install node version
command: |
if [ '<< parameters.node_version >>' ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash;
export NVM_DIR="$HOME/.nvm";
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh";
nvm install '<< parameters.node_version >>';
fi;
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Unit Tests
command: yarn test:unit --maxWorkers=4
test_browser:
description: Testing code within browsers
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Build
command: yarn build
- run:
name: Browser tests
command: yarn test:browser-ci
release:
working_directory: ~/algoliasearch-client-javascript
description: Perform a new release of the JavaScript client
docker:
- image: cimg/node:14.17
steps:
- checkout
- run:
command: yarn install
- run:
command: |
if [[ -z "$GITHUB_TOKEN" ]]; then echo '$GITHUB_TOKEN is not set'; exit 1; fi
yarn shipjs trigger
workflows:
version: 2
ci:
jobs:
- test_unit:
# workaround: cimg/node:8 certificate is unsigned, we use nvm instead
cimg_version: '14.17'
node_version: '8.17'
name: 'test_unit_8'
- test_unit:
cimg_version: '14.17'
name: 'test_unit_14'
- test_lint:
cimg_version: '12.22'
- test_types:
cimg_version: '12.22'
- test_build:
cimg_version: '12.16.2'
- test_browser:
cimg_version: '12.16.2'
- release:
requires:
- test_unit_8
- test_unit_14
- test_lint
- test_types
- test_build
- test_browser
filters:
branches:
only:
- master
|