@verndale/ai-commit 2.4.4 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,87 @@ const rules = require("@verndale/ai-commit/rules");
|
|
|
193
193
|
|
|
194
194
|
---
|
|
195
195
|
|
|
196
|
+
## GitHub Actions (CI snippet)
|
|
197
|
+
|
|
198
|
+
Use **commitlint in your own workflow file** — nothing calls back to the `ai-commit` repository’s pipelines. After `pnpm add -D @verndale/ai-commit`, add a root **`commitlint.config.cjs`** (or `.js`) that **`extends: ["@verndale/ai-commit"]`** as in [commitlint without a second install](#commitlint-without-a-second-install). **`@commitlint/cli`** is already a dependency of this package, so `pnpm exec commitlint` works once dependencies are installed.
|
|
199
|
+
|
|
200
|
+
Save as **`.github/workflows/commitlint.yml`** (or merge the job into an existing workflow). Adjust **`branches`** / **`branches-ignore`** if your default branch is not **`main`**.
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
name: Commit message lint
|
|
204
|
+
|
|
205
|
+
on:
|
|
206
|
+
pull_request:
|
|
207
|
+
branches: [main]
|
|
208
|
+
types: [opened, synchronize, reopened, edited]
|
|
209
|
+
push:
|
|
210
|
+
branches-ignore:
|
|
211
|
+
- main
|
|
212
|
+
|
|
213
|
+
jobs:
|
|
214
|
+
commitlint:
|
|
215
|
+
runs-on: ubuntu-latest
|
|
216
|
+
steps:
|
|
217
|
+
- name: Checkout
|
|
218
|
+
uses: actions/checkout@v4
|
|
219
|
+
with:
|
|
220
|
+
fetch-depth: 0
|
|
221
|
+
|
|
222
|
+
- name: Setup Node
|
|
223
|
+
uses: actions/setup-node@v4
|
|
224
|
+
with:
|
|
225
|
+
node-version: "24.14.0"
|
|
226
|
+
|
|
227
|
+
- name: Enable pnpm via Corepack
|
|
228
|
+
run: corepack enable && corepack prepare pnpm@10.11.0 --activate
|
|
229
|
+
|
|
230
|
+
- name: Get pnpm store path
|
|
231
|
+
id: pnpm-cache
|
|
232
|
+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
233
|
+
|
|
234
|
+
- name: Cache pnpm store
|
|
235
|
+
uses: actions/cache@v4
|
|
236
|
+
with:
|
|
237
|
+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
238
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
239
|
+
restore-keys: |
|
|
240
|
+
${{ runner.os }}-pnpm-store-
|
|
241
|
+
|
|
242
|
+
- name: Install dependencies
|
|
243
|
+
run: pnpm install --frozen-lockfile
|
|
244
|
+
|
|
245
|
+
- name: Lint PR title (squash merge becomes the commit on main)
|
|
246
|
+
if: github.event_name == 'pull_request'
|
|
247
|
+
env:
|
|
248
|
+
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
249
|
+
run: |
|
|
250
|
+
printf '%s\n' "$PR_TITLE" | pnpm exec commitlint --verbose
|
|
251
|
+
|
|
252
|
+
- name: Lint commit messages (PR range)
|
|
253
|
+
if: github.event_name == 'pull_request'
|
|
254
|
+
run: |
|
|
255
|
+
pnpm exec commitlint \
|
|
256
|
+
--from "${{ github.event.pull_request.base.sha }}" \
|
|
257
|
+
--to "${{ github.event.pull_request.head.sha }}" \
|
|
258
|
+
--verbose
|
|
259
|
+
|
|
260
|
+
- name: Lint last commit (push)
|
|
261
|
+
if: github.event_name == 'push'
|
|
262
|
+
run: |
|
|
263
|
+
pnpm exec commitlint --from=HEAD~1 --to=HEAD --verbose
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Notes**
|
|
267
|
+
|
|
268
|
+
| Topic | Detail |
|
|
269
|
+
| --- | --- |
|
|
270
|
+
| **Node** | Use a version that satisfies this package’s **`engines.node`** (see [Requirements](#requirements)). |
|
|
271
|
+
| **npm or Yarn** | Replace the Corepack + pnpm steps with your install (`npm ci`, `yarn install --immutable`, etc.) and run **`npx --no commitlint`** or **`yarn exec commitlint`** instead of **`pnpm exec commitlint`**. |
|
|
272
|
+
| **Config path** | If commitlint does not find your config (non-root monorepo, unusual filename), add **`--config path/to/commitlint.config.cjs`** to each **`commitlint`** invocation. |
|
|
273
|
+
| **Alignment with hooks** | The same rules apply as for **`.husky/commit-msg`** when it runs **`ai-commit lint --edit`** — both use the **`@verndale/ai-commit`** preset. |
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
196
277
|
## Development (this repository)
|
|
197
278
|
|
|
198
279
|
```bash
|
|
@@ -204,6 +285,8 @@ Copy **`.env-example`** to `.env` / `.env.local` and set **`OPENAI_API_KEY`**. A
|
|
|
204
285
|
|
|
205
286
|
### Repository automation
|
|
206
287
|
|
|
288
|
+
To run the same style of checks in **another** repository, copy the workflow in [GitHub Actions (CI snippet)](#github-actions-ci-snippet) (self-contained YAML; no call into this repo’s Actions).
|
|
289
|
+
|
|
207
290
|
| Workflow | Trigger | Purpose |
|
|
208
291
|
| --- | --- | --- |
|
|
209
292
|
| [`.github/workflows/commitlint.yml`](./.github/workflows/commitlint.yml) | PRs to `main`, pushes to non-`main` | Commitlint on PR range or last push |
|