Skip to content

Commit

Permalink
refactor: migrate to a monorepo (#5162)
Browse files Browse the repository at this point in the history
* move examples

* move everything

* CI: workspace trial

* put places in root to make sure everything builds fine

* harmonise babel version between example and root

* ci: e2e only requires examples

* netlify: redirects

* avoids horrible mismatch between algoliasearch versions

* codesandbox only build published

* order deps the same

* codesandbox hardcode package (it publishes private ones otherwise)

* RIP shared mocks used inside (es and src types aren't the same)

* lower concurrency for examples

* fix typo, run in root

* correct redirects

* ie compatible e2e tests

* re-introduce v3 test

* correct lockfile

* netlify swap order of redirects, prevent infinite redirect

* colocate packages

* fix jest ignore

* update contributing

* private testutils

* update readme

* replicate readme in root

* correct doctoc script

* localised version update script

* independent versioning

* order packages

* wip

* changelog via lerna

* clean

* wip

* wip

* ignore changelog

* wip

* */*

* update shipjs to alpha

* yes

* right prepare

* remove wrong stuff

* request newest, possibly bug in shipjs

* remove non-working diff

* fix undefined

* lower concurrency

* ok this is needed after all

* chore: remove unused config file

* move all jest together

* removing that part again for now, later only we'll actively use it

* move to tests

* move dependencies

* chore: latest released

* no concurrency on netlify, it's too much change it overloads
  • Loading branch information
Haroenv authored Nov 22, 2022
1 parent d7b62ed commit 644f456
Show file tree
Hide file tree
Showing 644 changed files with 5,824 additions and 13,302 deletions.
218 changes: 129 additions & 89 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,132 +1,198 @@
aliases:
- &install_yarn_version
name: Install specific Yarn version
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.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
version: 2

- &run_yarn_install
name: Install dependencies
command: yarn install
references:
workspace_root: &workspace_root
~/instantsearch
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root
install_yarn_version: &install_yarn_version
run:
name: Install specific Yarn version
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0
echo 'export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"' >> $BASH_ENV
restore_yarn_cache: &restore_yarn_cache
restore_cache:
name: Restore Yarn cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
save_yarn_cache: &save_yarn_cache
save_cache:
name: Save Yarn cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
run_yarn_install: &run_yarn_install
run:
name: Install dependencies
command: yarn install --frozen-lockfile

defaults: &defaults
working_directory: ~/instantsearchjs
working_directory: ~/instantsearch
docker:
- image: cimg/node:14.17.0

version: 2
workflows:
version: 2
ci:
jobs:
- build
- lint:
requires:
- build
- unit tests:
requires:
- build
- legacy algoliasearch:
requires:
- build
- examples:
requires:
- build
- e2e tests:
requires:
- examples
- release if needed:
requires:
- build
- lint
- unit tests
- examples
- legacy algoliasearch
- e2e tests
filters:
branches:
only:
- master
scheduled release:
triggers:
- schedule:
cron: '0 9 * * 2'
filters:
branches:
only:
- master
jobs:
- prepare release


jobs:
'build and size':
build:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- *save_yarn_cache
- run:
name: Build library
command: |
yarn run build:umd
yarn run build:cjs
yarn run build:es
yarn run build --ignore='example-*'
- run:
name: Test packages size
command: yarn run test:size
- run:
name: Type Export
command: yarn run build:types
- run:
name: Test Exports
command: yarn run test:exports
- persist_to_workspace:
root: *workspace_root
paths:
- packages/instantsearch.js/es
- packages/instantsearch.js/cjs
- packages/instantsearch.js/dist

lint:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: Lint & Code styles
command: yarn run lint
- run:
name: Type Checking
command: yarn run type-check

'type check algoliasearch v3':
legacy algoliasearch:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: Update dependencies
command: |
yarn remove @algolia/client-search
yarn add @types/[email protected] [email protected]
./scripts/legacy/downgrade-algoliasearch-dependency.js
- run:
name: Type Checking
command: yarn run type-check:v3

'unit tests':
unit tests:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: Unit tests
command: yarn run test --maxWorkers=4
- store_test_results:
path: junit/jest/

'e2e tests':
examples:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: Build example
command: yarn run website:build e-commerce
name: Build examples
command: yarn run website:examples --concurrency=1
- persist_to_workspace:
root: *workspace_root
paths:
- website/examples

e2e tests:
<<: *defaults
steps:
- checkout
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: End-2-End tests
command: yarn run test:e2e:saucelabs
- store_test_results:
path: junit/wdio/

'release if needed':
release if needed:
<<: *defaults
steps:
- checkout
- run: *install_yarn_version
- restore_cache: *restore_yarn_cache
- run: *run_yarn_install
- save_cache: *save_yarn_cache
- *attach_workspace
- *install_yarn_version
- *restore_yarn_cache
- *run_yarn_install
- run:
name: Trigger a release if the latest commit is a release commit
command: |
yarn shipjs trigger
'prepare release':
prepare release:
<<: *defaults
steps:
- checkout
Expand All @@ -139,30 +205,4 @@ jobs:
command: |
git config --global user.email "[email protected]"
git config --global user.name "InstantSearch"
yarn run release --yes --no-browse
workflows:
version: 2
ci:
jobs:
- build and size
- unit tests
- lint
- type check algoliasearch v3
- e2e tests
- 'release if needed':
filters:
branches:
only:
- master
- next
'scheduled release':
triggers:
- schedule:
cron: '0 9 * * 2'
filters:
branches:
only:
- master
jobs:
- prepare release
yarn run shipjs prepare --yes --no-browse
3 changes: 2 additions & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sandboxes": ["instantsearchjs-es-template-pcw1k"],
"buildCommand": "build",
"buildCommand": "build --no-private",
"packages": ["packages/instantsearch.js"],
"node": "14"
}
16 changes: 7 additions & 9 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/cjs
/es
**/cjs
**/es
**/dist

/website
dist
.cache
node_modules/

# TODO: don't ignore these examples once they're updated
/examples/calendar-widget
/examples/media
/examples/tourism
.cache
.parcel-cache
**/node_modules
23 changes: 11 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ module.exports = {
{
files: ['*.ts', '*.tsx'],
// this is the same files as ignored in tsconfig.json
excludedFiles: [
'examples/**/*',
'es',
// these two files are temporarily excluded because
// they import files from node_modules/search-insights directly
// and it causes the type-checking to fail.
'src/middlewares/__tests__/createInsightsMiddleware.ts',
'test/mock/createInsightsClient.ts',
],
excludedFiles: ['examples/**/*', '*/es'],
parserOptions: {
project: './tsconfig.json',
},
Expand All @@ -92,7 +84,11 @@ module.exports = {
},
},
{
files: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.js'],
files: [
'packages/instantsearch.js/src/**/*.ts',
'packages/instantsearch.js/src/**/*.tsx',
'packages/instantsearch.js/src/**/*.js',
],
rules: {
'import/extensions': ['error', 'never'],
},
Expand All @@ -104,8 +100,11 @@ module.exports = {
},
},
{
files: ['src/**/*'],
excludedFiles: ['**/__tests__/**/*', 'src/widgets/**/*'],
files: ['packages/instantsearch.js/src/**/*'],
excludedFiles: [
'**/__tests__/**/*',
'packages/instantsearch.js/src/widgets/**/*',
],
rules: {
'no-restricted-globals': [
'error',
Expand Down
16 changes: 12 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
node_modules/
!scripts/docs/

.eslintcache
.parcel-cache

npm-debug.log
yarn-error.log

.DS_Store

.env

# Bundle build files
/dist
/cjs
/es
/packages/instantsearch.js/dist
/packages/instantsearch.js/cjs
/packages/instantsearch.js/es

# Generated files
/docs
/website/examples
/website/stories
/storybook/dist/*

# Unneeded changelogs
examples/*/*/CHANGELOG.md
tests/*/CHANGELOG.md

# Test output
/junit
Loading

0 comments on commit 644f456

Please sign in to comment.