Skip to content

Commit

Permalink
Mayflower v10 rush monorepo (#1195)
Browse files Browse the repository at this point in the history
* Updates gitignore file.

* Adds Rush, PNPM support, WIP.

* WIP: Fixes develop, build modes, updates circleci for rush and pnpm.

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP: Testing pnpx with rush

* WIP

* WIP

* Moves patternlab to packages, fixes eslint bugs.

* Fixes circleci pathing for monorepo.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Fixes circleci patternlab.

* Installs node 12 with nvm.

* Installs node 12 with nvm.

* Updates patternlab image to use circleci provided image.

* Updates patternlab image to use circleci provided image.

* Updates patternlab image to use circleci provided image.

* Updates patternlab image to use circleci provided image.

* Updates patternlab image to use circleci provided image.

* Installing aws on patternlab_deploy_branch workflow.

* Installing aws on patternlab_deploy_branch workflow.

* Installing aws on patternlab_deploy_branch workflow.

* WIP.

* Fixes react dependencies for pnpm.

* Lint fixes.

* Updates mayflower repo readme on using the monorepo.

* Updates mayflower repo readme on using the monorepo.

* Fixes gitignore rules that was breaking patternlab builds.

* Fixes patternlab cache in circleci.

* Fixes patternlab to use normalize again.

* add to doc

* update doc

* add back package.json for auto release scripts

* add commands at the root

* fix

* Adds support for running custom rush commands at root for starting sites, fixes circleci build.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci bugs.

* Fixes circleci.

* Fixes circleci.

* Fixes circleci.

* Fixes circleci.

* Updates README file on using rush and rushx commands.

Co-authored-by: Minghua Sun <[email protected]>
  • Loading branch information
smurrayatwork and clairesunstudio authored Oct 13, 2020
1 parent 677b95c commit a144e19
Show file tree
Hide file tree
Showing 4,731 changed files with 26,981 additions and 71,346 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
157 changes: 87 additions & 70 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

version: 2.1


orbs:
php: circleci/[email protected]

references:
configure_npm: &configure_npm
run: { name: 'Configure NPM', command: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'}
Expand All @@ -14,9 +17,9 @@ react_defaults: &react_defaults
docker:
- image: circleci/node:12.18.0-browsers
patternlab_defaults: &patternlab_defaults
working_directory: /var/www/code
working_directory: ~/code
docker:
- image: massgov/drupal-container:1.0.8-ci
- image: cimg/php:7.3-node

backstop_defaults: &backstop_defaults
working_directory: /home/circleci
Expand All @@ -29,17 +32,21 @@ jobs:
steps:
- checkout
- restore_cache:
name: Restore yarn.lock
name: Restore pnpm-lock.yaml
keys:
- root-npm-v3-{{ checksum "yarn.lock" }}
- root-npm-v3-
- run: {name: 'Install packages', command: 'npm i -g yarn && yarn'}
- root-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-2
- run: {name: 'Install packages', command: 'node common/scripts/install-run-rush.js install'}
- save_cache:
name: Save NPM cache
key: root-npm-v3-{{ checksum "yarn.lock" }}
paths: [ node_modules ]
key: root-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-2
paths:
- common
- packages/assets/node_modules
- packages/react/node_modules
- packages/patternlab/styleguide/node_modules
- packages/site/node_modules
- persist_to_workspace:
root: /var/www/code
root: ~/code
paths: ["*"]

patternlab_build:
Expand All @@ -49,16 +56,10 @@ jobs:
- restore_cache:
name: Restore NPM Cache
keys:
- pl-npm-v3-{{ checksum "patternlab/styleguide/package-lock.json" }}
- pl-npm-v3-
- run: { name: 'NPM Install', command: 'cd patternlab/styleguide && npm install' }
- save_cache:
name: Save NPM cache
key: pl-npm-v3-{{ checksum "patternlab/styleguide/package-lock.json" }}
paths: [ patternlab/styleguide/node_modules ]
- run: { name: 'Build', command: 'cd patternlab/styleguide && node_modules/.bin/gulp patternlab:build'}
- root-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-2
- run: { name: 'Build', command: 'cd packages/patternlab/styleguide && node ../../../common/scripts/install-run-rushx.js build'}
- persist_to_workspace:
root: /var/www/code
root: ~/code
paths: ["*"]

patternlab_test:
Expand All @@ -67,37 +68,43 @@ jobs:
- attach_workspace: {at: /home/circleci}
- setup_remote_docker
- run: |
cd patternlab
cd packages/patternlab
docker-compose up --no-start web backstop
docker cp ./ $(docker-compose ps -q backstop):/src/
docker cp ./styleguide/public/. $(docker-compose ps -q web):/usr/share/nginx/html
- run: |
cd patternlab
cd packages/patternlab
docker-compose run backstop test
- run:
command: cd patternlab && docker cp $(docker-compose ps -q backstop):/src/backstopjs/. ./backstopjs/
command: cd packages/patternlab && docker cp $(docker-compose ps -q backstop):/src/backstopjs/. ./backstopjs/
when: always
- store_artifacts:
path: patternlab/backstopjs
path: packages/patternlab/backstopjs
destination: backstop
- store_test_results:
path: patternlab/backstopjs/reports/ci
path: packages/patternlab/backstopjs/reports/ci

patternlab_deploy_branch:
<<: *patternlab_defaults
steps:
- attach_workspace: {at: /var/www/code}
- attach_workspace: {at: ~/code}
- *no_host_check
- add_ssh_keys
- *configure_git
- run:
name: 'Install AWS'
command: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- run:
name: 'Deploy Artifact Branch'
command: |
# This snippet pushes the dist directory to the artifact repo by faking a checkout
# of the artifact repository, creating or reusing an existing branch, committing the
# work, then pushing to github.
# See https://github.com/LastCallMedia/Artifact.sh/blob/master/artifact.sh
cd patternlab/styleguide/dist
cd packages/patternlab/styleguide/dist
git clone --bare [email protected]:massgov/mayflower-artifacts.git .git
git config core.bare false
git rev-parse --verify -q "$CIRCLE_BRANCH" || git branch "$CIRCLE_BRANCH" $(git show-ref -s master)
Expand All @@ -111,12 +118,12 @@ jobs:
fi
- run:
name: 'Deploy S3 Branch'
command: aws s3 sync patternlab/styleguide/public "s3://mayflower.digital.mass.gov/patternlab/b/$CIRCLE_BRANCH"
command: aws s3 sync packages/patternlab/styleguide/public "s3://mayflower.digital.mass.gov/patternlab/b/$CIRCLE_BRANCH"

patternlab_deploy_tag:
<<: *patternlab_defaults
steps:
- attach_workspace: {at: /var/www/code}
- attach_workspace: {at: ~/code}
- *no_host_check
- add_ssh_keys
- *configure_git
Expand All @@ -142,7 +149,7 @@ jobs:
- run:
name: 'Deploy NPM Tag'
command: |
cd patternlab/styleguide/dist
cd packages/patternlab/styleguide/dist
npm version --no-git-tag-version "$CIRCLE_TAG"
if test -z "$(npm show @massds/mayflower@$CIRCLE_TAG)"; then
npm publish
Expand All @@ -164,24 +171,31 @@ jobs:
- checkout
- restore_cache:
keys:
- mfr-dependencies-{{ checksum "react/package.json" }}-4
- run: cd react && npm install
- mfr-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-0
- run:
name: Install Rush on Repo directory
command: node common/scripts/install-run-rush.js install
- save_cache:
name: Save NPM cache
key: mfr-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-0
paths:
- react/node_modules
key: mfr-dependencies-{{ checksum "react/package.json" }}-4
- common
- packages/assets/node_modules
- packages/react/node_modules
- packages/patternlab/styleguide/node_modules
- packages/site/node_modules
- run:
name: Mayflower React Build
command: cd react && npm run build
command: cd packages/react && node ../../common/scripts/install-run-rushx.js build
- run:
name: Mayflower React Build Storybook
command: cd react && npm run build-storybook
command: cd packages/react && node ../../common/scripts/install-run-rushx.js build-storybook
- run:
name: Mayflower React Storybook Extract
command: cd react && npm run storybook:extract
command: cd packages/react && node ../../common/scripts/install-run-rushx.js storybook:extract
- run:
name: Mayflower React Linter
command: cd react && npm run lint
command: cd packages/react && node ../../common/scripts/install-run-rushx.js lint
- persist_to_workspace:
root: ~/repo
paths: ["*"]
Expand All @@ -192,23 +206,23 @@ jobs:
- attach_workspace: {at: /home/circleci}
- setup_remote_docker
- run: |
cd react
cd packages/react
docker-compose up --no-start web backstop
docker cp ./ $(docker-compose ps -q backstop):/src/
docker cp ../assets $(docker-compose ps -q backstop):/src/assets
docker cp ../docs $(docker-compose ps -q backstop):/src/docs
docker cp ../../docs $(docker-compose ps -q backstop):/src/docs
docker cp ./storybook-static/. $(docker-compose ps -q web):/usr/share/nginx/html
- run: |
cd react
cd packages/react
docker-compose run backstop test
- run:
command: cd react && docker cp $(docker-compose ps -q backstop):/src/backstop/. ./backstop/
command: cd packages/react && docker cp $(docker-compose ps -q backstop):/src/backstop/. ./backstop/
when: always
- store_artifacts:
path: react/backstop
path: packages/react/backstop
destination: backstop
- store_test_results:
path: react/backstop/data/ci_report
path: packages/react/backstop/data/ci_report

react_deploy_tag:
<<: *react_defaults
Expand All @@ -219,7 +233,7 @@ jobs:
- run:
name: 'Publish mayflower-react NPM package'
command: |
cd react
cd packages/react
npm version --no-git-tag-version "$CIRCLE_TAG"
if test -z "$(npm show @massds/mayflower-react@$CIRCLE_TAG)"; then
npm publish
Expand All @@ -234,7 +248,7 @@ jobs:
- run: |
# Only sync to S3 for stable tags.
if [[ "$CIRCLE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
cd react
cd packages/react
aws s3 sync storybook-static s3://mayflower.digital.mass.gov/react --delete
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id $AWS_DISTRIBUTION_ID --paths '/react*'
Expand All @@ -258,7 +272,10 @@ jobs:
steps:
- checkout
- *no_host_check
- run: { name: 'NPM Install', command: 'npm install' }
- restore_cache:
keys:
- root-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-2
- run: sudo npm install -g pnpm @microsoft/rush
# Identify the committer i.e. CircleCI deployment bot
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "CircleCI Deployment Bot"
Expand All @@ -269,7 +286,10 @@ jobs:
steps:
- checkout
- *no_host_check
- run: { name: 'NPM Install', command: 'npm install' }
- restore_cache:
keys:
- root-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-2
- run: sudo npm install -g pnpm @microsoft/rush
# Identify the committer i.e. CircleCI deployment bot
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "CircleCI Deployment Bot"
Expand All @@ -282,15 +302,10 @@ jobs:
- checkout
- restore_cache:
keys:
- assets-dependencies-{{ checksum "assets/package.json" }}
- run: cd assets && npm install
- save_cache:
paths:
- assets/node_modules
key: assets-dependencies-{{ checksum "assets/package.json" }}
- mfr-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-0
- run:
name: Mayflower Style Linter
command: cd assets && npm run stylelint
command: cd packages/assets && node ../../common/scripts/install-run-rushx.js stylelint

assets_deploy_tag:
<<: *react_defaults
Expand All @@ -299,16 +314,11 @@ jobs:
- *configure_npm
- restore_cache:
keys:
- assets-dependencies-{{ checksum "assets/package.json" }}
- run: cd assets && npm i
- save_cache:
paths:
- assets/node_modules
key: assets-dependencies-{{ checksum "assets/package.json" }}
- mfr-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-0
- run:
name: 'Publish mayflower-assets NPM package'
command: |
cd assets
cd packages/assets
npm version --no-git-tag-version "$CIRCLE_TAG"
if test -z "$(npm show @massds/mayflower-assets@$CIRCLE_TAG)"; then
npm publish
Expand All @@ -322,15 +332,11 @@ jobs:
- checkout
- restore_cache:
keys:
- site-dependencies-{{ checksum "site/yarn.lock" }}
- run: {name: 'Install packages', command: 'cd site && yarn'}
- save_cache:
paths:
- site/node_modules
key: site-dependencies-{{ checksum "site/yarn.lock" }}
- mfr-npm-v4-{{ checksum "common/config/rush/pnpm-lock.yaml" }}-0
- run: cd packages/react && node ../../common/scripts/install-run-rushx.js build
- run:
name: Validate Package Build
command: cd site && yarn build
command: cd packages/site && node ../../common/scripts/install-run-rushx.js build
- persist_to_workspace:
root: ~/repo
paths: ["*"]
Expand All @@ -349,7 +355,7 @@ jobs:
- run: |
# Only sync to S3 for stable tags.
if [[ "$CIRCLE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
cd site
cd packages/site
aws s3 sync public s3://mayflower.digital.mass.gov/home --delete
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id $AWS_DISTRIBUTION_ID --paths '/home*'
Expand All @@ -361,14 +367,17 @@ workflows:
# Executed on branch pushes.
build_branch:
jobs:
- build
- auto_changelog:
filters:
branches: { only: /dependabot\/.*/ }
- assets_build:
requires: [react_build_storybook]
filters:
branches: { ignore: /(docs|site\/).*/ }
# patternlab
- patternlab_build:
requires: [build]
filters:
branches: { ignore: /(docs|react\/|site\/).*/ }
- patternlab_deploy_branch:
Expand All @@ -389,6 +398,7 @@ workflows:
branches: { ignore: /(docs|patternlab\/|site\/).*/ }
# site
- site_build:
requires: [react_build_storybook]
filters:
branches: { ignore: /(docs|patternlab\/|react\/).*/ }

Expand Down Expand Up @@ -429,7 +439,12 @@ workflows:
# Executed on tag pushes.
build_tag:
jobs:
- build:
filters:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
- patternlab_build:
requires: [build]
filters:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
Expand All @@ -448,15 +463,17 @@ workflows:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
- assets_deploy_tag:
requires: [react_build_storybook]
filters:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
- site_build:
requires: [react_build_storybook]
filters:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
- site_deploy_tag:
requires: [site_build]
requires: [react_build_storybook]
filters:
branches: { ignore: /.*/ }
tags: { only: /.*/ }
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Don't allow people to merge changes to these generated files, because the result
# may be invalid. You need to run "rush update" again.
pnpm-lock.yaml merge=binary
shrinkwrap.yaml merge=binary
npm-shrinkwrap.json merge=binary
yarn.lock merge=binary

# Rush's JSON config files use JavaScript-style code comments. The rule below prevents pedantic
# syntax highlighters such as GitHub's from highlighting these comments as errors. Your text editor
# may also require a special configuration to allow comments in JSON.
#
# For more information, see this issue: https://github.com/microsoft/rushstack/issues/1088
#
*.json linguist-language=JSON-with-Comments
Loading

0 comments on commit a144e19

Please sign in to comment.