Skip to content

Commit

Permalink
chore: optimize building repository (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP authored and trivikr committed Aug 21, 2019
1 parent f8794b4 commit 00443da
Show file tree
Hide file tree
Showing 10 changed files with 9,178 additions and 38 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: node_js
node_js:
- "10.9.0"
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.17.3
- export PATH="$HOME/.yarn/bin:$PATH"
install:
- npm install
- travis_wait 180 npm run bootstrap
- yarn
script:
- travis_wait 180 npm run test
- yarn test
after_success:
- ./node_modules/.bin/codecov -f coverage/*.json
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspaces-experimental true
33 changes: 16 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ and pull requests. Please read through this document before submitting any
issues or pull requests to ensure we have all the necessary information to
effectively respond to your bug report or contribution.


## Filing Bug Reports

You can file bug reports against the SDK on the [GitHub issues][issues] page.
Expand Down Expand Up @@ -41,7 +40,6 @@ guidelines prior to filing a bug report.
as well, like whether this is a persistent issue, or if it only occurs
some of the time.


## Submitting Pull Requests

We are always happy to receive code and documentation contributions to the SDK.
Expand All @@ -57,7 +55,7 @@ Please be aware of the following notes prior to opening a pull request:

3. Wherever possible, pull requests should contain tests as appropriate.
Bugfixes should contain tests that exercise the corrected behavior (i.e., the
test should fail without the bugfix and pass with it), and new features
test should fail without the bugfix and pass with it), and new features
should be accompanied by tests exercising the feature. Pull requests that
contain failing tests will not be merged until the test failures are addressed.
Pull requests that cause a significant drop in the SDK's test coverage
Expand All @@ -67,10 +65,9 @@ Please be aware of the following notes prior to opening a pull request:
[conventional commits][conventional commits]. Title must begin with `feat(module): title`,
`fix(module): title`, `docs(module): title`, `test(module): title`, `chore(module): title`.
Title should be lowercase and not period at the end of it. If the commit includes
a breaking change, the commit message must end with a single paragraph: `BREAKING
CHANGE: a description of what broke`
a breaking change, the commit message must end with a single paragraph: `BREAKING CHANGE: a description of what broke`

5. After getting ready to open a pull request, make sure to run the `npm run update-clients`
5. After getting ready to open a pull request, make sure to run the `yarn update-clients`
to re-generate all the service clients, and commit the change(if any) to a
standalone commit following the guide above.

Expand All @@ -79,32 +76,34 @@ Please be aware of the following notes prior to opening a pull request:
This project uses a monorepo to manage all of the packages.
This allows us to easily test the effects of changes in one package to others.

To run the tests locally, install the dependencies for the root project. This includes Lerna, the tool
we use to manage the monorepo.
Make sure you have [`yarn`](https://yarnpkg.com/en/) installed by:

```
npm install
yarn --version
```

Then, run the following command to tell Lerna to install and link any dependencies in the `packages` directory:
If not, please refer to [yarn installation](https://yarnpkg.com/en/docs/install#mac-stable) to install `yarn`.

To install the dependencies and link the library, run the following command:

```
npm run bootstrap
yarn
```

To run all of the tests in the repository, still from the root package, run the following:
To run all of the tests in the repository, still from the root package, run the following command:

```
npm test
yarn test-all
```

The above command will use Lerna to run the `test` script in every package in the `packages` directory.

To run the tests for a specific package, you can run `npm test` from within the specified package folder, assuming the above steps have been run.
To run the tests for a specific package, you can run `yarn test` from within the specified package folder, assuming the above steps have been run.

### Generating Service Clients

You can generate service client by yourself from either [AWS service models][] or customized models. The SDK provides
a command line interface for generating packages. In order to use the CLI, first complete the test and setup steps (above) to
You can generate service client by yourself from either [AWS service models][] or customized models. The SDK provides
a command line interface for generating packages. In order to use the CLI, first complete the test and setup steps (above) to
build the package-generator and its dependencies.

```
Expand Down Expand Up @@ -138,5 +137,5 @@ node ./packages/package-generator/build/cli.js client --model models/dynamodb/20
[pr]: https://github.com/aws/aws-sdk-js-v3/pulls
[license]: http://aws.amazon.com/apache2.0/
[cla]: http://en.wikipedia.org/wiki/Contributor_License_Agreement
[AWS service models]: https://github.com/aws/aws-sdk-js-v3/tree/master/models
[aws service models]: https://github.com/aws/aws-sdk-js-v3/tree/master/models
[conventional commits]: https://www.conventionalcommits.org/
8 changes: 4 additions & 4 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- echo Installing dependencies
- npm install && npm run bootstrap
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.17.3
- export PATH="$HOME/.yarn/bin:$PATH"
- yarn
build:
commands:
- echo Executing unit tests
- npm test
- yarn test
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ module.exports = {
projects: ["<rootDir>/packages/*/jest.config.js"],
testPathIgnorePatterns: [
"<rootDir>/packages/add-glacier-checksum-headers-browser",
"<rootDir>/packages/client-.*"
"<rootDir>/clients/.*/client-.*"
],
coveragePathIgnorePatterns: [
"/node_modules/",
"<rootDir>/packages/add-glacier-checksum-headers-browser",
"<rootDir>/packages/crypto-sjcl-*",
"<rootDir>/packages/xml-body-parser/vendor/",
"<rootDir>/packages/client-.*",
"<rootDir>/clients/.*/client-.*",
"/__fixtures__/"
]
};
8 changes: 6 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
"packages/*",
"clients/browser/*",
"clients/node/*",
"client/universal/*"
"clients/universal/*"
],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"bootstrap": {
"nohoist": ["@types/*", "typedoc", "karma*"]
},
"run": {
"npmClient": "yarn"
}
},
"hoist": true,
"nohoist": ["@types/*", "typedoc", "karma*"]
}
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
"description": "AWS SDK for JavaScript from the future",
"main": "index.js",
"scripts": {
"bootstrap": "lerna bootstrap",
"clean": "npm run clear-build-cache && lerna clean",
"bootstrap": "yarn",
"clean": "yarn clear-build-cache && yarn clear-build-info && lerna clean",
"clear-build-cache": "rimraf ./packages/*/build/* ./clients/*/*/build/*",
"clear-build-info": "rimraf ./packages/*/*.tsbuildinfo ./clients/*/*/*.tsbuildinfo",
"copy-models": "node ./scripts/copyModels.js",
"update-clients": "node ./scripts/rebuildClients.js",
"pretest": "lerna run pretest",
"test": "jest --coverage"
"update-clients": "node ./packages/package-generator/build/cli.js import-all --matching './models/*/*/service-2.json'",
"pretest": "lerna run pretest --since --include-filtered-dependents --include-filtered-dependencies",
"test": "jest --coverage",
"pretest-all": "lerna run pretest",
"test-all": "jest --coverage"
},
"repository": {
"type": "git",
Expand All @@ -38,10 +41,14 @@
"lerna": "3.16.2",
"lint-staged": "^9.0.0",
"prettier": "1.18.2",
"typescript": "~3.4.0"
"typescript": "~3.4.0",
"yarn": "1.17.3"
},
"workspaces": [
"packages/*"
"packages/*",
"clients/browser/*",
"clients/node/*",
"clients/universal/*"
],
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/package-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/prettier": "1.16.4",
"@types/rimraf": "^2.0.2",
"@types/semver": "^6.0.0",
"@types/yargs": "^8.0",
"@types/yargs": "~8.0",
"jest": "^24.7.1",
"typescript": "~3.4.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/util-create-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
},
"devDependencies": {
"@aws-sdk/middleware-stack": "^0.1.0-preview.5",
"@types/jest": "^20.0.2",
"@types/jest": "^24.0.12",
"@types/node": "^10.0.3",
"jest": "^20.0.4",
"jest": "^24.7.1",
"typescript": "~3.4.0"
}
}
Loading

0 comments on commit 00443da

Please sign in to comment.