|
| 1 | +# Contribution Guide |
| 2 | + |
| 3 | +This is the common top-level contribution guide for this monorepo. |
| 4 | +A sub-package **may** have an additional CONTRIBUTING.md file if needed. |
| 5 | + |
| 6 | +## Legal |
| 7 | + |
| 8 | +All contributors must sign the DCO |
| 9 | + |
| 10 | +- https://cla-assistant.io/SAP-samples/ecmascript-monorepo-template |
| 11 | + |
| 12 | +This is managed automatically via https://cla-assistant.io/ pull request voter. |
| 13 | + |
| 14 | +## Development Environment |
| 15 | + |
| 16 | +### pre-requisites |
| 17 | + |
| 18 | +- [Yarn](https://yarnpkg.com/lang/en/docs/install/) >= 1.4.2 |
| 19 | +- A [Long-Term Support version](https://nodejs.org/en/about/releases/) of node.js |
| 20 | +- (optional) [commitizen](https://github.com/commitizen/cz-cli#installing-the-command-line-tool) for managing commit messages. |
| 21 | + |
| 22 | +### Initial Setup |
| 23 | + |
| 24 | +The initial setup is trivial: |
| 25 | + |
| 26 | +- clone this repo |
| 27 | +- `yarn` |
| 28 | + |
| 29 | +### Commit Messages format. |
| 30 | + |
| 31 | +This project enforces the [conventional-commits][conventional_commits] commit message formats. |
| 32 | +The possible commits types prefixes are limited to those defined by [conventional-commit-types][commit_types]. |
| 33 | +This promotes a clean project history and enabled automatically generating a changelog. |
| 34 | + |
| 35 | +The commit message format will be inspected both on a git pre-commit hook |
| 36 | +and during the central CI build and will **fail the build** if issues are found. |
| 37 | + |
| 38 | +It is recommended to use `git cz` to construct valid conventional commit messages. |
| 39 | + |
| 40 | +- requires [commitizen](https://github.com/commitizen/cz-cli#installing-the-command-line-tool) to be installed. |
| 41 | + |
| 42 | +[commit_types]: https://github.com/commitizen/conventional-commit-types/blob/master/index.json |
| 43 | +[conventional_commits]: https://www.conventionalcommits.org/en/v1.0.0/ |
| 44 | + |
| 45 | +### Formatting. |
| 46 | + |
| 47 | +[Prettier](https://prettier.io/) is used to ensure consistent code formatting in this repository. |
| 48 | +This is normally transparent as it automatically activated in a pre-commit hook using [lint-staged](https://github.com/okonet/lint-staged). |
| 49 | +However, this does mean that dev flows that do not use a full dev env (e.g editing directly on github) |
| 50 | +may result in voter failures due to formatting errors. |
| 51 | + |
| 52 | +### Compiling |
| 53 | + |
| 54 | +Use the following npm scripts at the repo's **root** to compile **all** the TypeScript sub-packages. |
| 55 | + |
| 56 | +- `yarn compile` |
| 57 | +- `yarn compile:watch` (will watch files for changes and re-compile as needed) |
| 58 | + |
| 59 | +These scripts may also be available inside the sub-packages. However, it is recommended to |
| 60 | +use the top-level compilation scripts to avoid forgetting to (re-)compile a sub-package's dependency. |
| 61 | + |
| 62 | +### Testing |
| 63 | + |
| 64 | +[Mocha][mocha] and [Chai][chai] are used for unit-testing and [Istanbul/Nyc][istanbul] for coverage reports. |
| 65 | + |
| 66 | +[mocha]: https://mochajs.org/ |
| 67 | +[chai]: https://www.chaijs.com |
| 68 | +[istanbul]: https://istanbul.js.org/ |
| 69 | + |
| 70 | +- To run the tests execute `yarn test` in a specific sub-package. |
| 71 | +- To run the tests with **coverage** run `yarn coverage` in a specific sub-package. |
| 72 | + |
| 73 | +### Code Coverage |
| 74 | + |
| 75 | +100%\* Code Coverage is enforced for all productive code in this mono repo. |
| 76 | + |
| 77 | +- Specific statements/functions may be [excluded][ignore_coverage] from the report. |
| 78 | + - However, the reason for each exclusion must be documented. |
| 79 | + |
| 80 | +[ignore_coverage]: https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md |
| 81 | + |
| 82 | +### Full Build |
| 83 | + |
| 84 | +To run the full **C**ontinuous **I**ntegration build run `yarn ci` in either the top-level package or a specific subpackage. |
| 85 | + |
| 86 | +### Release Life-Cycle. |
| 87 | + |
| 88 | +This monorepo uses Lerna's [Fixed/Locked][lerna-mode] which means all the sub-packages share the same version number. |
| 89 | + |
| 90 | +[lerna-mode]: https://github.com/lerna/lerna#fixedlocked-mode-default |
| 91 | + |
| 92 | +### Release Process |
| 93 | + |
| 94 | +Performing a release requires push permissions to the repository. |
| 95 | + |
| 96 | +- Ensure you are on the default branch and synced with origin. |
| 97 | +- `yarn run release:version` |
| 98 | +- Follow the lerna CLI instructions. |
| 99 | +- Track the newly pushed **tag** (`/^v[0-9]+(\.[0-9]+)*/`) build in the build system |
| 100 | + until successful completion. |
| 101 | +- Inspect the newly artifacts published on npmjs.com / Github Releases / other relevant release targets. |
0 commit comments