|
| 1 | +# `check.sh` (The custom checker script) |
| 2 | + |
| 3 | +A script that checks various aspects of the project to ensure that it is in a good state, including: |
| 4 | +- Type-checking, |
| 5 | +- Linting |
| 6 | +- Compilation |
| 7 | +- Enforcement of various project conventions. |
| 8 | + |
| 9 | +This script should be run, at the very least, before merging any changes into the main branch or releasing, but ideally, |
| 10 | +much more often than just that. |
| 11 | + |
| 12 | +## Contents |
| 13 | + |
| 14 | +- [Check script usage](#check-script-usage) |
| 15 | +- [Available checks](#available-checks) |
| 16 | +- [See also](#see-also) |
| 17 | + |
| 18 | +## Check script usage |
| 19 | + |
| 20 | +The API for the check script is as follows, where all checks are run by default if no arguments are provided: |
| 21 | + |
| 22 | +```fortran |
| 23 | +scripts/check.sh [tc] [lint] [licensing] [lib-check] [test-exts] [test-names] |
| 24 | +``` |
| 25 | + |
| 26 | +One or more of the above checks may be specified otherwise, to run only the specified checks in the order they are provided. |
| 27 | + |
| 28 | +The check script will return a non-zero exit code if any of the checks fail, and will print out the results of each check as it runs. |
| 29 | + |
| 30 | +## Available checks |
| 31 | + |
| 32 | +### Run type-checker (`tc`) |
| 33 | + |
| 34 | +If set, `tsc` will be run with `--noEmit` to ensure that the `src` and `test` folders type-check correctly. |
| 35 | + |
| 36 | +### Run linter (`lint`) |
| 37 | + |
| 38 | +If set, `eslint` will be run over the `src` and `test` folders to ensure that the code follows proper conventions. |
| 39 | + |
| 40 | +### Check licensing headers (`licensing`) |
| 41 | + |
| 42 | +If set, the script will check that all files in the `src` and `test` folders have the correct apache 2.0 licensing headers. |
| 43 | + |
| 44 | +``` |
| 45 | +// Copyright DataStax, Inc. |
| 46 | +// |
| 47 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 48 | +// you may not use this file except in compliance with the License. |
| 49 | +// You may obtain a copy of the License at |
| 50 | +// |
| 51 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 52 | +// |
| 53 | +// Unless required by applicable law or agreed to in writing, software |
| 54 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 55 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 56 | +// See the License for the specific language governing permissions and |
| 57 | +// limitations under the License. |
| 58 | +``` |
| 59 | + |
| 60 | +### Check library compilation (`lib-check`) |
| 61 | + |
| 62 | +If set, the script will build the library, and set it as the dependency of a newly created TS project with `skipLibCheck: false` |
| 63 | +to ensure that the library compiles correctly, and may be used in other projects without issue. |
| 64 | + |
| 65 | +### Check test extension conventions (`test-exts`) |
| 66 | + |
| 67 | +If set, the script will check that all test files in the `test` folder have the `.test.ts` extension. |
| 68 | + |
| 69 | +### Check test naming conventions (`test-names`) |
| 70 | + |
| 71 | +If set, the script will check that all file-level test suites in the `test` folder have the correct naming convention. |
| 72 | + |
| 73 | +It is expected that each file-level test suite will have a name that matches the file path relative to the `tests/` directory, |
| 74 | +with slashes replaced by dots, and the `.test.ts` extension removed. |
| 75 | + |
| 76 | +For example, the file `tests/unit/documents/cursor.test.ts` should have a file-level test suite named `unit.documents.cursor`. |
| 77 | + |
| 78 | +```ts |
| 79 | +describe('unit.documents.cursor', () => { |
| 80 | + // Tests here |
| 81 | +}); |
| 82 | +``` |
| 83 | + |
| 84 | +This works even if the root-level suite is a `parallel` or `background` block. |
| 85 | + |
| 86 | +## See also |
| 87 | + |
| 88 | +- [The custom test script](./test.sh.md) |
0 commit comments