diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..def90fda9 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e +cd "$(git rev-parse --show-toplevel)" || exit 1 +npm run lint diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index 22714cacd..af96c1e02 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -8,6 +8,27 @@ Maintaining this project requires installing [Node.js](https://nodejs.org). All ## ✅ Tasks +### 🔧 Git hooks (optional) + +#### Pre-commit lint hook +We provide an opt-in Git hook that runs `npm run lint` from the repository root before a commit is created. + +Enable it once per clone: + +```sh +git config core.hooksPath .githooks +``` + +Disable it: + +```sh +git config --unset core.hooksPath +``` + +Notes: +- The hook runs `npm run lint` from the repository root. +- You can skip it with `git commit --no-verify` if needed. + ### ⚗️ Testing and Linting The Node SDK is made up of multiple, individual packages, each with their own tests. As such, tests are run on a per-package basis. However, the top-level directory contains some development dependencies applicable to all packages. As a result, to run tests for any package, first run `npm install` from the top-level directory. Then run `npm test --workspace packages/` to run that package's tests. To run linting across all packages, run `npm run lint` from the root directory. @@ -21,6 +42,7 @@ npm test --workspace packages/web-api This project has tests for individual packages as `*.test.ts` (or `*.test.js`) files inside of each package's `src` directory. Tests use `node:test` as the test runner and `node:assert/strict` for assertions. Also, for verifying the behavior with the real Slack server-side and developer experience with installed packages, you can run the tests and scripts under `prod-server-integration-tests`. Refer to the README file in the directory for details. These tests are supposed to be run in the project maintainers' manual execution. They are not part of CI builds for now. + Upon opening a PR, tests are executed by GitHub Actions, our continuous integration system. GitHub Actions runs several, more granular builds in order to report on success and failure in a more targeted way. - There is one build for each package on each supported version of Node, as well as one for the integration tests on each supported version of Node.