Skip to content

Commit 63bc870

Browse files
authored
Merge pull request #5892 from influxdata/jts/issue5887
chore: update CONTRIBUTING.md
2 parents fc40626 + 05cb821 commit 63bc870

File tree

1 file changed

+34
-80
lines changed

1 file changed

+34
-80
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,22 @@ To install dependencies listed in package.json:
4545
3. Run `yarn` to install dependencies (including Hugo).
4646
4. Install the Yarn package manager and run `yarn` to install project dependencies.
4747

48-
`package.json` contains dependencies for linting and running Git hooks.
49-
docs-v2 uses [Lefthook](https://github.com/evilmartians/lefthook) to configure and manage pre-commit hooks for linting and testing Markdown content.
48+
`package.json` contains dependencies used in `/assets/js` JavaScript code and
49+
dev dependencies used in pre-commit hooks for linting, syntax-checking, and testing.
5050

51-
Other dependencies used in the project:
51+
Dev dependencies include:
5252

53-
- **[prettier](https://prettier.io/docs/en/)**: formats code, including Markdown, according to style rules for consistency
53+
- [Lefthook](https://github.com/evilmartians/lefthook): configures and
54+
manages pre-commit hooks for linting and testing Markdown content.
55+
- [prettier](https://prettier.io/docs/en/): formats code, including Markdown, according to style rules for consistency
56+
- [Cypress]: e2e testing for UI elements and URLs in content
5457

5558
### Install Docker
5659

57-
Install [Docker](https://docs.docker.com/get-docker/) for your system.
58-
5960
docs-v2 includes Docker configurations (`compose.yaml` and Dockerfiles) for running the Vale style linter and tests for code blocks (Shell, Bash, and Python) in Markdown files.
6061

62+
Install [Docker](https://docs.docker.com/get-docker/) for your system.
63+
6164
#### Build the test dependency image
6265

6366
After you have installed Docker, run the following command to build the test
@@ -94,7 +97,8 @@ Make your suggested changes being sure to follow the [style and formatting guide
9497

9598
docs-v2 uses Lefthook to manage Git hooks, such as pre-commit hooks that lint Markdown and test code blocks.
9699
When you try to commit changes (`git commit`), Git runs
97-
the commands configured in `lefthook.yml` which pass your **staged** files to Vale, Prettier, and Pytest (in a Docker container).
100+
the commands configured in `lefthook.yml` which pass your **staged** files to Vale,
101+
Prettier, Cypress (for UI tests and link-checking), and Pytest (for testing Python and shell code in code blocks).
98102

99103
### Skip pre-commit hooks
100104

@@ -113,6 +117,9 @@ LEFTHOOK=0 git commit
113117

114118
### Set up test scripts and credentials
115119

120+
Tests for code blocks require your InfluxDB credentials and other typical
121+
InfluxDB configuration.
122+
116123
To set up your docs-v2 instance to run tests locally, do the following:
117124

118125
1. **Set executable permissions on test scripts** in `./test/src`:
@@ -128,91 +135,38 @@ To set up your docs-v2 instance to run tests locally, do the following:
128135
Cloud Dedicated instance for testing in most cases. To avoid conflicts when
129136
running tests, create separate Cloud Dedicated and Clustered databases.
130137

131-
3. **Create .env.test**: Copy the `./test/env.test.example` file into each
138+
1. **Create .env.test**: Copy the `./test/env.test.example` file into each
132139
product directory to test and rename the file as `.env.test`--for example:
133140

134141
```sh
135142
./content/influxdb/cloud-dedicated/.env.test
136143
```
137144

138-
4. Inside each product's `.env.test` file, assign your InfluxDB credentials to
139-
environment variables.
145+
2. Inside each product's `.env.test` file, assign your InfluxDB credentials to
146+
environment variables:
140147

141-
In addition to the usual `INFLUX_` environment variables, in your
142-
`cloud-dedicated/.env.test` and `clustered/.env.test` files define the
148+
- Include the usual `INFLUX_` environment variables
149+
- In
150+
`cloud-dedicated/.env.test` and `clustered/.env.test` files, also define the
143151
following variables:
144152

145-
- `ACCOUNT_ID`, `CLUSTER_ID`: You can find these values in your `influxctl`
146-
`config.toml` configuration file.
147-
- `MANAGEMENT_TOKEN`: Use the `influxctl management create` command to generate
148-
a long-lived management token to authenticate Management API requests
149-
150-
For the full list of variables you'll need to include, see the substitution
151-
patterns in `./test/src/prepare-content.sh`.
152-
153-
**Warning**: The database you configure in `.env.test` and any written data may
154-
be deleted during test runs.
153+
- `ACCOUNT_ID`, `CLUSTER_ID`: You can find these values in your `influxctl`
154+
`config.toml` configuration file.
155+
- `MANAGEMENT_TOKEN`: Use the `influxctl management create` command to generate
156+
a long-lived management token to authenticate Management API requests
155157

156-
**Warning**: To prevent accidentally adding credentials to the docs-v2 repo,
157-
Git is configured to ignore `.env*` files. Don't add your `.env.test` files to Git.
158-
Consider backing them up on your local machine in case of accidental deletion.
158+
See the substitution
159+
patterns in `./test/src/prepare-content.sh` for the full list of variables you may need to define in your `.env.test` files.
159160

160-
5. For influxctl commands to run in tests, move or copy your `config.toml` file
161+
3. For influxctl commands to run in tests, move or copy your `config.toml` file
161162
to the `./test` directory.
162163

163-
### Pre-commit linting and testing
164-
165-
When you try to commit your changes using `git commit` or your editor,
166-
the project automatically runs pre-commit checks for spelling, punctuation,
167-
and style on your staged files.
168-
169-
`.husky/pre-commit` script runs Git pre-commit hook commands, including
170-
[`lint-staged`](https://github.com/lint-staged/lint-staged).
171-
172-
The `.lintstagedrc.mjs` lint-staged configuration maps product-specific glob
173-
patterns to lint and test commands and passes a product-specific
174-
`.env.test` file to a test runner Docker container.
175-
The container then loads the `.env` file into the container's environment variables.
176-
177-
To test or troubleshoot testing and linting scripts and configurations before
178-
committing, choose from the following:
179-
180-
- To run pre-commit scripts without actually committing, append `exit 1` to the
181-
`.husky/pre-commit` script--for example:
182-
183-
```sh
184-
./test/src/monitor-tests.sh start
185-
npx lint-staged --relative
186-
./test/src/monitor-tests.sh kill
187-
exit 1
188-
```
189-
190-
And then run `git commit`.
191-
192-
The `exit 1` status fails the commit, even if all the tasks succeed.
193-
194-
- Use `yarn` to run one of the lint or test scripts configured in
195-
`package.json`--for example:
196-
197-
```sh
198-
yarn run test
199-
```
200-
201-
- Run `lint-staged` directly and specify options:
202-
203-
```sh
204-
npx lint-staged --relative --verbose
205-
```
206-
207-
The pre-commit linting configuration checks for _error-level_ problems.
208-
An error-level rule violation fails the commit and you must do one of the following before you can commit your changes:
209-
210-
- fix the reported problem in the content
211-
212-
- edit the linter rules to permanently allow the content.
213-
See **Configure style rules**.
214-
215-
- temporarily override the hook (using `git commit --no-verify`)
164+
> [!Warning]
165+
>
166+
> - The database you configure in `.env.test` and any written data may
167+
be deleted during test runs.
168+
> - Don't add your `.env.test` files to Git. To prevent accidentally adding credentials to the docs-v2 repo,
169+
Git is configured to ignore `.env*` files. Consider backing them up on your local machine in case of accidental deletion.
216170

217171
#### Test shell and python code blocks
218172

@@ -259,7 +213,7 @@ You probably don't want to display this syntax in the docs, which unfortunately
259213
means you'd need to include the test block separately from the displayed code
260214
block.
261215
To hide it from users, wrap the code block inside an HTML comment.
262-
Pytest-codeblocks will still collect and run the code block.
216+
pytest-codeblocks will still collect and run the code block.
263217

264218
##### Mark tests to skip
265219

0 commit comments

Comments
 (0)