Skip to content

Commit

Permalink
chore: migrate mono-repository to use "yarn workspaces" (aws#891)
Browse files Browse the repository at this point in the history
* chore: migrate mono-repository to use "yarn workspaces"

This appears to improve the bootsrapping performance and makes the lock
files much easier to manager (`yarn` maintains a single `yarn.lock` file
at the root of the mono-repository instead of having one for each
package like `npm` does).

As required, this adjusted the `jsii/superchain` Docker image to also
contain `yarn`, and changes how the `node` binary is installed to using
the `nodesource` repository (so as to satisfy the `yarn` RPM
dependencies without hacking around too much).

* CodeBuild: install yarn if it is not there already (temporarily)

* Temporarily skip yarn's engine check

* better way to tune the ignore-engines

* fixup Gemfile.lock

* add missing yarn install

* added required link for bundled dependency

* fix hoisting problem w/ jsii-calc-bundled, use * versions where possible.

* increase timeout of negatives test (need to investigate why they are so slow though)

* fix build-test

* fixup python test

* try to install & test from the same container (suspecting ruby's .bundle directory somehow gets lost)

* unset some problematic BUNDLER_ environment variables in Docker (they assumed single-app workloads, we're making a development image)

* revert * dependency versions
  • Loading branch information
RomainMuller authored and mergify[bot] committed Oct 17, 2019
1 parent 69851e6 commit d145f2b
Show file tree
Hide file tree
Showing 80 changed files with 8,317 additions and 69,021 deletions.
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Helps with using npm package-locally, while in a yarn workflow (avoids coupling scripts to yarn).
# This is needed because yarn goes out of it's way to ensure it controls what `node` binary is used (for good!)
scripts-prepend-node-path=auto
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ branches:
- master
- /v\d+\.\d+.\d+/

cache:
yarn: true
directories: node_modules

services:
- docker

Expand All @@ -13,7 +17,7 @@ script:
# Building the Docker image
- docker build --pull --build-arg BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg COMMIT_ID="${TRAVIS_COMMIT}" -t "jsii/superchain:nightly" ./superchain
# Building jsii itself within the Docker image
- docker run --rm -it --net=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:nightly npm run build
- docker run --rm -it --network=host -v ${PWD}:${PWD} -w ${PWD} jsii/superchain:nightly bash -c "yarn install && yarn build && yarn test"
# Make sure the build did not change the source tree
- git update-index --refresh
- git diff-index --exit-code --stat HEAD
Expand Down
4 changes: 4 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is required as the *current* CodeBuild image has node8, but we "require" node 10.
# The whole file can be dropped once the new Docker image is released.
--install.ignore-engines true
--run.ignore-engines true
16 changes: 9 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ using the docker image from the above section, but if you wish to, you can insta
in your development environment.

- [Node `8.11.0`] or later
- [Yarn `1.19.1`] or later
- An OpenJDK-8 distribution (e.g: [Oracle's OpenJDK8], [Amazon Corretto 8])
+ [`maven >= 3.0.5`](https://maven.apache.org)
- [.NET Core `2.0`] or later
- [.NET Core `2.1`] or later
+ *Recommended:* [`mono >= 5`](https://www.mono-project.com)
- [Python `3.6.5`] or later
+ [`pip`](https://pip.pypa.io/en/stable/installing/)
Expand All @@ -53,6 +54,7 @@ in your development environment.
+ [`bundler ~> 1.17.2`](https://bundler.io)

[Node `8.11.0`]: https://nodejs.org/download/release/v8.11.0/
[Yarn `1.19.1`]: https://yarnpkg.com/en/docs/install
[Oracle's OpenJDK8]: http://openjdk.java.net/install/
[Amazon Corretto 8]: https://aws.amazon.com/corretto/
[.NET Core `2.0`]: https://www.microsoft.com/net/download
Expand All @@ -68,7 +70,7 @@ The project is managed as a [monorepo] using [lerna].
[lerna]: https://github.com/lerna/lerna

1. Check out this respository and change directory to its root.
2. Run `npm run bootstrap && npm run build` to install lerna, bootstrap the repository
2. Run `yarn install && yarn build` to install lerna, bootstrap the repository
and perform an initial build and test cycle.

### Development Workflow
Expand All @@ -83,20 +85,20 @@ All packages within this repository have the following scripts:

Each one of these scripts can be executed either from the root of the repo using
`npx lerna run <script> --scope <package>` or from individual modules using
`npm run <script>`.
`yarn <script>`.

### Bump

To bump the version of this repository, use the [`npm run bump`] script.
To bump the version of this repository, use the [`yarn bump`] script.

[`npm run bump`]: ./scripts/bump.sh
[`yarn bump`]: ./scripts/bump.sh

### Packaging and Bundling

This repository emits artifacts in multiple languages. The [`npm run package`]
This repository emits artifacts in multiple languages. The [`yarn package`]
script is used to prepare the repository for publishing.

[`npm run package`]: ./scripts/package.sh
[`yarn package`]: ./scripts/package.sh

Each module that needs to be published implements an npm script called `package`
which emits publishable artifacts to `dist/<lang>` (e.g. `dist/dotnet` for
Expand Down
10 changes: 6 additions & 4 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ version: 0.2
phases:
install:
commands:
- npm run bootstrap
# Temporarily - install yarn if it's not there already
- yarn --version || npm install --global yarn
- yarn install
pre_build:
commands:
- npm run fetch-dotnet-snk
- yarn fetch-dotnet-snk
build:
commands:
- npm run build
- yarn build && yarn test
post_build:
commands:
- '[ ${CODEBUILD_BUILD_SUCCEEDING} = 1 ] && npm run package'
- '[ ${CODEBUILD_BUILD_SUCCEEDING} = 1 ] && yarn package'
artifacts:
files:
- "**/*"
Expand Down
2 changes: 2 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"lerna": "3.13.1",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
Expand Down
Loading

0 comments on commit d145f2b

Please sign in to comment.