Skip to content

Commit

Permalink
chore: update build flow (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored Nov 5, 2020
1 parent e872003 commit 569ea44
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 30 deletions.
110 changes: 86 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
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
- &restore_dist_folders
name: Restore dist folders
command: |
set -exu
mkdir -p packages/autocomplete-core/dist
mkdir -p packages/autocomplete-js/dist
mkdir -p packages/autocomplete-plugin-recent-searches/dist
mkdir -p packages/autocomplete-preset-algolia/dist
cp -R /tmp/workspace/packages/autocomplete-core/dist packages/autocomplete-core
cp -R /tmp/workspace/packages/autocomplete-js/dist packages/autocomplete-js
cp -R /tmp/workspace/packages/autocomplete-plugin-recent-searches/dist packages/autocomplete-plugin-recent-searches
cp -R /tmp/workspace/packages/autocomplete-preset-algolia/dist packages/autocomplete-preset-algolia
defaults: &defaults
working_directory: ~/autocomplete
docker:
- image: circleci/node:14.15.0

version: 2.1
references:
workspace_root: &workspace_root /tmp/workspace
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

jobs:
test_build:
build:
<<: *defaults
steps:
- checkout
Expand All @@ -37,46 +54,86 @@ jobs:
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- run:
name: Build & Test packages size
name: Build
command: yarn run build
- run:
name: Move dist folders to workspace
command: |
yarn run build
yarn run test:size
set -exu
mkdir -p /tmp/workspace/packages/autocomplete-core/dist
mkdir -p /tmp/workspace/packages/autocomplete-js/dist
mkdir -p /tmp/workspace/packages/autocomplete-plugin-recent-searches/dist
mkdir -p /tmp/workspace/packages/autocomplete-preset-algolia/dist
cp -R packages/autocomplete-core/dist /tmp/workspace/packages/autocomplete-core
cp -R packages/autocomplete-js/dist /tmp/workspace/packages/autocomplete-js
cp -R packages/autocomplete-plugin-recent-searches/dist /tmp/workspace/packages/autocomplete-plugin-recent-searches
cp -R packages/autocomplete-preset-algolia/dist /tmp/workspace/packages/autocomplete-preset-algolia
- 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: Lint & Code styles
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 test:types

name: Type checking
command: yarn run test:types
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

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: Test packages size
command: yarn run test:size
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: Release if needed
command: yarn run shipjs trigger
Expand All @@ -85,19 +142,24 @@ workflows:
version: 2.1
ci:
jobs:
- test_build:
filters:
branches:
only: next
- test_unit:
filters:
branches:
only: next
- build
- test_lint:
filters:
branches:
only: next
requires:
- build
- test_types
- test_unit:
requires:
- build
- test_size:
requires:
- build
- release:
requires:
- test_unit
- test_lint
- test_types
- test_size
- build
filters:
branches:
only: next
4 changes: 2 additions & 2 deletions examples/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"start": "parcel index.html"
},
"dependencies": {
"@algolia/autocomplete-js": "^1.0.0-alpha.34",
"@algolia/autocomplete-plugin-recent-searches": "^1.0.0-alpha.32",
"@algolia/autocomplete-js": "1.0.0-alpha.34",
"@algolia/autocomplete-plugin-recent-searches": "1.0.0-alpha.34",
"@algolia/client-search": "4.5.1",
"algoliasearch": "4.5.1"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/autocomplete-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
},
"dependencies": {
"@algolia/autocomplete-core": "^1.0.0-alpha.34",
"@algolia/autocomplete-preset-algolia": "^1.0.0-alpha.34",
"@algolia/autocomplete-preset-algolia": "^1.0.0-alpha.34"
},
"devDependencies": {
"@algolia/client-search": "4.5.1"
},
"peerDependencies": {
"@algolia/client-search": "^4.5.1"
}
}
7 changes: 6 additions & 1 deletion packages/autocomplete-plugin-recent-searches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
"prepare": "yarn run build:esm",
"watch": "watch \"yarn on:change\" --ignoreDirectoryPattern \"/dist/\""
},
"devDependencies": {
"@algolia/autocomplete-core": "^1.0.0-alpha.34",
"@algolia/autocomplete-js": "^1.0.0-alpha.34"
},
"peerDependencies": {
"@algolia/autocomplete-core": "^1.0.0-alpha.34"
"@algolia/autocomplete-core": "^1.0.0-alpha.34",
"@algolia/autocomplete-js": "^1.0.0-alpha.34"
}
}
7 changes: 5 additions & 2 deletions ship.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ module.exports = {
`yarn workspace @algolia/autocomplete-js add "@algolia/autocomplete-core@^${version}" "@algolia/autocomplete-preset-algolia@^${version}"`
);
exec(
`yarn workspace @algolia/autocomplete-plugin-recent-searches add --peer "@algolia/autocomplete-core@^${version}"`
`yarn workspace @algolia/autocomplete-plugin-recent-searches add --peer "@algolia/autocomplete-core@^${version}" "@algolia/autocomplete-js@^${version}"`
);
exec(
`yarn workspace @algolia/js-example add "@algolia/autocomplete-js@^${version}"`
`yarn workspace @algolia/autocomplete-plugin-recent-searches add --dev "@algolia/autocomplete-core@^${version}" "@algolia/autocomplete-js@^${version}"`
);
exec(
`yarn workspace @algolia/js-example add "@algolia/autocomplete-js@${version}" "@algolia/autocomplete-plugin-recent-searches@${version}"`
);

updatePackagesVersion({
Expand Down

0 comments on commit 569ea44

Please sign in to comment.