UNPKG

4.4 kBMarkdownView Raw
1Contributing Guide
2==================
3
4Thanks for your interest in contributing to this project! This document aims to
5serve as a friendly guide for making your first contribution.
6
7### Cloning the project
8
9```sh
10git clone https://github.com/balena-io-modules/rendition.git
11cd rendition
12```
13
14### Installing npm dependencies
15
16```sh
17npm install
18```
19
20### Installing docker
21
22[Docker][Docker] is required to run [visual regresion tests](#visual-testing)
23and to generate new screenshots. See the [docker installation
24documentation][Docker install] for information on how to install Docker in your
25environment.
26
27### Running the storybook
28
29The interactive storybook can be launched by running:
30
31```sh
32npm run build
33npm run start
34```
35
36The storybook can be accessed at http://localhost:6006.
37
38Adding new components
39---------------------
40
41Please open an issue to discuss any new components before starting work on
42them.
43
44Testing
45-------
46
47To run the test suite, run the following command:
48
49```sh
50npm test
51```
52
53We encourage our contributors to test the library before sending a pull request.
54
55We use [Jest snapshot testing](https://jestjs.io/docs/en/snapshot-testing) to
56help prevent regression bugs. If your change affects the html output of
57a component you may needs to update a snapshot, you can do this by running the
58following command:
59
60```sh
61npm run jest -- -u
62```
63
64*The test suite is run automatically by CI servers when you send a pull
65request.*
66
67Code is automatically linted and formatted by [Husky][husky] as a pre-commit hook.
68
69We make use of [EditorConfig] to communicate indentation, line endings and
70other text editing default. We encourage you to install the relevant plugin in
71your text editor of choice to avoid having to fix any issues during the review
72process.
73
74
75### Visual testing
76
77You can run a screenshot test using the command:
78
79```
80npm run test:local-visual
81```
82
83A report will be generated and saved to `visual-testing-report.html`.
84
85If you have made changes to a component that will affect the way it
86looks in a story, screenshots should be generated using the command:
87
88```
89npm run generate-screenshots
90```
91
92This command will spawn a docker container, generate screenshots
93and copy them back to your local file system.
94
95Visual testing relies on a consistent execution environment, ensuring that
96control inputs and fonts are always rendered the same way. To ensure this
97happens both screenshot generation and testing steps are run inside a docker
98container.
99
100Screenshots of each story are stored in the `__screenshots__` directory. When
101the test suite runs, new screenshots are created and compared against the
102existing ones in the `__screenshots__` directory. Any differences will cause the
103tests to fail, as it indicates an unexpected visual change to a component.
104
105Updating documentation
106----------------------
107
108All components have a corresponding markdown file that documents their API. The
109markdown files are found in `src/stories/README/`. The markdown files are
110displayed in the interactive storybook and also aggregated into the main README
111file. After making any changes to a component, make sure the corresponding
112markdown file is up to date and then update the README using the following
113command:
114
115```sh
116npm run build:docs
117```
118
119Commit Guidelines
120-----------------
121
122See [COMMIT-GUIDELINES.md][COMMIT-GUIDELINES] for a thorough guide on how to
123write commit messages.
124
125Sending a pull request
126----------------------
127
128When sending a pull request, consider the following guidelines:
129
130- Write a concise commit message explaining your changes.
131
132- If applies, write more descriptive information in the commit body.
133
134- If your change affects the visuals of the library, consider attaching a
135screenshot.
136
137- Refer to the issue/s your pull request fixes, so they're closed automatically
138when your pull request is merged.
139
140- Write a descriptive pull request title.
141
142- Squash commits when possible, for example, when committing review changes.
143
144Before your pull request can be merged, the following conditions must hold:
145
146- The linter doesn't throw any warning.
147
148- All the tests pass.
149
150- The coding style aligns with the project's convention.
151
152Don't hesitate to get in touch if you have any questions or need any help!
153
154[COMMIT-GUIDELINES]: COMMIT-GUIDELINES.md
155[EditorConfig]: http://editorconfig.org
156[Docker]: https://www.docker.com/
157[Docker install]: https://docs.docker.com/install/