Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 8e7f739

Browse files
author
McLin, Anthony
committed
docs: contribution guidelines
1 parent c429b0d commit 8e7f739

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

CONTRIBUTING.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
## Unit Tests
2+
3+
![Branch Code Coverage](./coverage/badge-branches.svg)
4+
![Functions Code Coverage](./coverage/badge-functions.svg)
5+
![Lines Code Coverage](./coverage/badge-lines.svg)
6+
![Statements Code Coverage](./coverage/badge-statements.svg)
7+
8+
Unit testing is handled using Jest. Code coverage for unit tests must remain above 90%.
9+
10+
Run unit tests via `npm test`.
11+
12+
A coverage report is shown in the inline test results. A browseable coverage report is also output to `./coverage/lcov-report/index.html`
13+
14+
When running unit tests from a CICD pipline, the environment variable `CI` should be set to `true` before executing the test.
15+
`CI=true npm test`
16+
17+
## Code Formatting
18+
19+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
20+
21+
Code styling is managed with [Prettier](https://github.com/prettier/prettier) to reduce churn from developers using different coding styles. Code will be automatically formatted on commit as long as you have run `npm install` after checking out the repo. Rules are exposed to code editors and validation tools using [ESLint](https://www.npmjs.com/package/eslint)
22+
23+
Plugins:
24+
25+
- `eslint` - Defines code linting rules
26+
- `babel-eslint` - Best practices for projects using babel
27+
- `eslint-config-airbnb` - AirBnB rules for React and Prettier
28+
- `eslint-plugin-react` - React-specific rules
29+
- `eslint-plugin-import` - Consistent module import rules
30+
- `eslint-config-prettier` - Turn off ESLint rules that conflict with Prettier
31+
- `eslint-plugin-jsx-a11y` - Ensure developers are considering accessibility when writing code
32+
- `eslint-plugin-react-hooks` - Follow best practices for using React hooks
33+
- `prettier` - opinionated code styling
34+
- `pretty-quick` - format code on commit
35+
36+
To ensure your editor will style code automatically, make sure you have support installed for `.editorconfig` and `.eslint`. For example, VSCode has both plugins for both [editorconfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) and [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) that will pick up the respective configuration files and assist you in formatting your code.
37+
38+
## Commit Messages
39+
40+
Commit messages shouldn't be just "_fixing x_" or "_adding y_". They should explain **why** a change was made so that it is useful for future developers looking at the history. Include links to relevant documents or external library bug reports, and include ticket numbers where appropriate.
41+
42+
### Commit Message Syntax
43+
44+
In order to facilitate [automated changelogs and versionsing](#releases) all git commits are expected to follow the [Angular commit syntax](https://gist.github.com/stephenparish/9941e89d80e2bc58a153). This is enforced using `commitlint` triggered by `husky`.
45+
46+
```
47+
<prefix>(<scope>):<subject>
48+
49+
<longer message>
50+
51+
<footer>
52+
```
53+
54+
Valid prefixes:
55+
56+
- `fix`: Bugfixes (avoid mixing bugfixes and features in the same commit)
57+
- `docs`: Documentation
58+
- `feat`: Features and new functionality
59+
- `test`: Adding unit tests without functional code changes
60+
- `style`: Changes to code styling only (eg. single vs double quotes, spaces vs tabs). **Do not confuse this with CSS styling**
61+
- `refactor`: Internal changes (non-functional) only. Should have no changes to unit tests
62+
- `chore`: Project maintenance
63+
64+
**When a commit contains a breaking change, the footer must begin with: `BREAKING CHANGE:`** so that release versions can properly reflect semantic versioning rules. Breaking changes should also document what other developers will need to do in order to accomidate the change. Breaking changes are those that are not backwards compatible, and change how this project is consumed (APIs, paths to includable libraries, run commands, etc).
65+
66+
#### Skipping CICD pipelines
67+
68+
Automated CICD Pipelines can be skipped on a particular commit by appending the flag `[skip-ci]`. This normally should only be done when the pipelines themselves make commits in order to prevent runaway builds.
69+
70+
## Releases
71+
72+
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
73+
This project follows [Semantic Versioning](https://docs.npmjs.com/about-semantic-versioning) guidelines for release numbers.
74+
75+
New versions of the project are automaticaly released via the CI/CD pipeline, which runs Semantic Release via the command `npm run semantic-release`
76+
77+
This automates several tasks in the release process via plugins:
78+
79+
- `@semantic-release/commit-analyzer` - Analyzes commit syntax to determine versioning and changelog
80+
- `@semantic-release/release-notes-generator` - Builds the release notes from the commit messages
81+
- `@semantic-release/changelog` - Generates changelog
82+
- `@semantic-release/git` - Tags the releaase in the git repo
83+
- `@semantic-release/github` - Adds a release version and changelog notes to a GitHub project
84+
- `@semantic-release/npm` - Updates the version number in package.json (and pushes to NPM if `npmPublish` is not set to `false`)
85+
86+
### Publishing releases
87+
88+
#### Releasing from local
89+
90+
The versioning and release process is automated using `semantic-release`. The following command should be run only by the CICD pipeline, and only on the latest commit on the `master` branch:
91+
92+
`GITHUB_TOKEN=<insert github token> NPM_TOKEN=<insert npm token> npm run test:badges && npm run semantic-release`
93+
94+
#### Release from CICD pipelines
95+
96+
The CICD server must provide the following environment variables:
97+
98+
- `GITHUB_TOKEN` - API Token from Github provisioned with API scope
99+
- `NPM_TOKEN` - API Token from NPM with permissions to publish on this registry
100+

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
66
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
77

8-
# react-project-boilerplate
8+
- [Using the generator](#using)
9+
- [Folder Structure of generated projects](./tree/master/templates/default)
10+
- [Contributing to this project](./CONTRIBUTING.md)
911

1012
This package includes the global command for creating new React projects incorporating [Next.js](https://github.com/zeit/next.js), CICD pipelines, unit testing, quality gates, and code styling. It is useful for ensuring consistent working environments across multiple different applications.
1113

@@ -41,3 +43,6 @@ Skip the process of creating a git repo for the project. **Note:** *this can res
4143
Skip the question and assume the generated project will need server-side rendering:
4244

4345
`npx create-amclin-nextjs-app --with-ssr`
46+
47+
## Contributing
48+
Help is always appreciated, please log bug reports, features, and fixes. See [Contribution Guidelines](CONTRIBUTING.md) for more on how you can help.

0 commit comments

Comments
 (0)