@kirill.konshin/lint 0.6.7 → 0.6.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirill.konshin/lint",
3
3
  "description": "ESLint + Prettier + lint-staged config and AI agent rules/skills for monorepos",
4
- "version": "0.6.7",
4
+ "version": "0.6.8",
5
5
  "type": "module",
6
6
  "skipGenerate": true,
7
7
  "bin": {
package/rules/github.md CHANGED
@@ -8,4 +8,6 @@ paths:
8
8
  ---
9
9
 
10
10
  - Agentic review MUST verify this effective CI order: checkout -> enable Corepack -> setup Node with Yarn cache -> restore build caches -> immutable install -> prepare -> verification (lint/test/build) -> publish; publishing MUST depend on successful verification.
11
- - In multi-job workflows, use job-specific build-cache keys with a same-run fallback so downstream jobs reuse upstream results without immutable-key collisions.
11
+ - Key build caches per commit when jobs run one after another: key `${{ runner.os }}-<tool>-${{ github.sha }}`, restore key `${{ runner.os }}-<tool>-`. A later job gets an exact hit and does not save again.
12
+ - Key build caches per job and commit when jobs run in parallel: key `${{ runner.os }}-<tool>-${{ github.job }}-${{ github.sha }}`, restore key `${{ runner.os }}-<tool>-${{ github.job }}-`. Only the first job that saves a key keeps its outputs. A downstream job restores the producing job's key and does not save.
13
+ - When caching Nx locally, cache its DB as `.nx/workspace-data/default-v*.db` next to `.nx/cache`: rename it to the runner's machine ID before install and back to `default-v*.db` before an explicit `actions/cache/save`, otherwise Nx ignores the restored `.nx/cache` (see `lint-github` skill).
package/rules/gitlab.md CHANGED
@@ -10,8 +10,5 @@ paths:
10
10
  - Always collect coverage from tests
11
11
  - Always publish important build stats as artifacts
12
12
  - Agentic review MUST verify this effective CI order: checkout and cache restore -> enable Corepack -> immutable install -> prepare -> verification (lint/test/build) -> publish; publishing MUST depend on successful verification.
13
- - Keep local build-cache keys job-specific in parallel pipelines; use a remote Nx or Turbo cache when results must be shared across jobs.
14
-
15
- # Example
16
-
17
- - Use Nx Cloud or Turbo Remote Cache when build results must be shared safely across parallel jobs.
13
+ - Keep local build-cache keys job-specific in parallel pipelines; a remote Nx or Turbo cache is needed only to share results between different jobs.
14
+ - When caching Nx locally, cache its DB as `.nx/workspace-data/default-v*.db` next to `.nx/cache`: rename it to the runner's machine ID in `before_script` (before install) and back to `default-v*.db` in `after_script`, otherwise Nx ignores the restored `.nx/cache` (see `lint-gitlab` skill).
package/rules/nx.md CHANGED
@@ -10,6 +10,7 @@ paths:
10
10
  # NX
11
11
 
12
12
  - If NX is used root `package.json` must have `nx show projects > /dev/null` in the `prepare`/`postinstall` script, so the project graph cache exists for tools that read it outside `nx` — e.g. `@nx/eslint-plugin` rules in a bare `eslint` run silently skip without it. With `prepare`, Yarn 2+ skips it on install — run `yarn prepare` explicitly (after cloning + as a CI step); with `postinstall` (private root) Yarn runs it on install, so no extra step
13
+ - Nx 20+ indexes `.nx/cache` in a SQLite DB in `.nx/workspace-data`, named after the machine ID. A CI cache must carry both, with the DB under the fixed name `default-v*.db`: rename it to the machine ID before install and back before saving (see `github.md` / `gitlab.md`). One cache entry holds one DB, so restoring several entries does not merge their outputs.
13
14
  - NX Release (v23+) with conventional commits silently demotes bumps for `0.x` packages (breaking → minor, `feat` → patch) while the log still claims `Applied semver relative bump "minor"`;
14
15
  - set `release.version.adjustSemverBumpsForZeroMajorVersion: false` in `nx.json` if `feat:` must bump minor before `1.0.0`
15
16
  - Root NX task-script convention: bare name = `nx run-many -t <target>` over all projects (`build`/`test`/`start`/`serve`), with concurrency flags set once here;
@@ -3,6 +3,147 @@ name: lint-github
3
3
  description: Describes how to work with Github & example workflow as a reference which essential jobs and concepts usual Github Workflow should have
4
4
  ---
5
5
 
6
+ Reference CI: two local composite actions and a workflow. Checks run as parallel jobs; publishing needs all of them.
7
+
8
+ `.github/actions/nx-cache/action.yml` — Nx 20+ ignores a restored `.nx/cache` without its DB:
9
+
10
+ ```yml
11
+ name: Nx cache
12
+ description: Caches .nx/cache with the Nx DB under the fixed name default-v*.db. Restore runs before install (./.github/actions/setup does it); save is the last step of a job that keeps its Nx outputs.
13
+
14
+ inputs:
15
+ mode:
16
+ description: restore | save
17
+ required: false
18
+ default: restore
19
+ job:
20
+ description: Job whose cache to use (defaults to this job); save only your own job's cache, parallel jobs must not share a key
21
+ required: false
22
+ default: ''
23
+
24
+ runs:
25
+ using: composite
26
+ steps:
27
+ - name: Check mode
28
+ if: inputs.mode != 'restore' && inputs.mode != 'save'
29
+ shell: bash
30
+ run: echo "::error::nx-cache mode must be restore or save, got '${{ inputs.mode }}'" && exit 1
31
+
32
+ # Nx indexes .nx/cache in a SQLite DB, cached next to it as default-v*.db.
33
+ # One key per job and commit: parallel jobs never race for a key.
34
+ - name: Restore Nx cache
35
+ if: inputs.mode == 'restore'
36
+ uses: actions/cache/restore@v6
37
+ with:
38
+ path: |
39
+ .nx/cache
40
+ .nx/workspace-data/default-v*.db
41
+ key: ${{ runner.os }}-nx-${{ inputs.job || github.job }}-${{ github.sha }}
42
+ restore-keys: |
43
+ ${{ runner.os }}-nx-${{ inputs.job || github.job }}-
44
+ ${{ runner.os }}-nx-
45
+
46
+ # Nx names the DB after the machine ID and ignores outputs it has no DB records for.
47
+ # Give the DB this runner's ID before install (postinstall runs Nx).
48
+ - name: Adopt Nx cache DB
49
+ if: inputs.mode == 'restore'
50
+ shell: bash
51
+ run: |
52
+ d=.nx/workspace-data
53
+ id=$(cat /var/lib/dbus/machine-id 2>/dev/null || cat /etc/machine-id 2>/dev/null || echo machine)
54
+ db=$(ls $d/default-v*.db 2>/dev/null | head -n 1 || true)
55
+ if [ -z "$db" ]; then
56
+ rm -rf .nx/cache # outputs without their DB are unusable
57
+ else
58
+ to=$d/$id-v${db##*-v}
59
+ rm -f "$to" "$to-wal" "$to-shm"
60
+ mv "$db" "$to"
61
+ fi
62
+ echo "Nx cache DB for machine ID $id: $(ls $d/*.db 2>/dev/null || echo none)"
63
+
64
+ # After the last Nx step: store the DB under the fixed name the cache holds
65
+ - name: Store Nx cache DB
66
+ if: inputs.mode == 'save'
67
+ shell: bash
68
+ run: |
69
+ d=.nx/workspace-data
70
+ db=$(ls -t $d/*-v*.db 2>/dev/null | head -n 1 || true)
71
+ to=$d/default-v${db##*-v}
72
+ [ -z "$db" ] || [ "$db" = "$to" ] || mv -f "$db" "$to"
73
+ echo "Nx cache DB to save: $(ls $d/default-v*.db 2>/dev/null || echo none)"
74
+
75
+ - name: Save Nx cache
76
+ if: inputs.mode == 'save'
77
+ uses: actions/cache/save@v6
78
+ with:
79
+ path: |
80
+ .nx/cache
81
+ .nx/workspace-data/default-v*.db
82
+ key: ${{ runner.os }}-nx-${{ inputs.job || github.job }}-${{ github.sha }}
83
+ ```
84
+
85
+ `.github/actions/setup/action.yml`:
86
+
87
+ ```yml
88
+ name: Setup
89
+ description: Node.js + Corepack + build cache restore + Yarn install. The repo must already be checked out (a local action cannot run before checkout). Jobs that keep their Nx outputs end with ./.github/actions/nx-cache (mode save).
90
+
91
+ inputs:
92
+ registry-url:
93
+ description: npm registry URL — set only on jobs that publish (configures .npmrc auth)
94
+ required: false
95
+ default: ''
96
+ nx-cache:
97
+ description: Job whose Nx cache to restore (defaults to this job); a job that does not save reuses another job's cache
98
+ required: false
99
+ default: ''
100
+
101
+ runs:
102
+ using: composite
103
+ steps:
104
+ - name: Enable Corepack
105
+ run: corepack enable
106
+ shell: bash
107
+
108
+ - name: Setup Node.js
109
+ uses: actions/setup-node@v6
110
+ with:
111
+ node-version: 24
112
+ registry-url: ${{ inputs.registry-url }}
113
+ cache: yarn
114
+ cache-dependency-path: yarn.lock
115
+
116
+ # If project uses Turbo
117
+ #TODO https://turbo.build/repo/docs/guides/ci-vendors/github-actions#remote-caching
118
+ #TODO https://turborepo.dev/docs/guides/ci-vendors/github-actions#remote-caching-with-github-actionscache
119
+ # One entry per commit when jobs run one after another; for parallel jobs add ${{ github.job }} to key and restore key (only the first job that saves a key keeps its outputs)
120
+ - name: Cache Turbo
121
+ uses: actions/cache@v6
122
+ with:
123
+ path: .turbo
124
+ key: ${{ runner.os }}-turbo-${{ github.job }}-${{ github.sha }}
125
+ restore-keys: |
126
+ ${{ runner.os }}-turbo-${{ github.job }}-
127
+ ${{ runner.os }}-turbo-
128
+
129
+ # If project uses Nx
130
+ - name: Restore Nx cache
131
+ uses: ./.github/actions/nx-cache
132
+ with:
133
+ job: ${{ inputs.nx-cache }}
134
+
135
+ - name: Install dependencies
136
+ run: yarn install --immutable
137
+ shell: bash
138
+
139
+ # Add this if Yarn 2+ is used and package is NOT private, otherwise postinstall should be configured, and this block skipped
140
+ - name: Prepare
141
+ run: yarn prepare
142
+ shell: bash
143
+ ```
144
+
145
+ `.github/workflows/release.yml`:
146
+
6
147
  ```yml
7
148
  name: Release
8
149
 
@@ -11,20 +152,76 @@ on:
11
152
  branches:
12
153
  - main
13
154
 
14
- # If project publishes to NPM
15
155
  permissions:
16
- id-token: write # Required for OIDC
17
156
  contents: read
18
157
 
19
158
  concurrency: ${{ github.workflow }}-${{ github.ref }}
20
159
 
160
+ env:
161
+ TURBO_CACHE_DIR: .turbo # if project uses Turbo
162
+ YARN_ENABLE_GLOBAL_CACHE: false # so that .yarn/cache is written
163
+
164
+ # Checks run as parallel jobs; release needs all of them. Only jobs with their own Nx cache save it.
21
165
  jobs:
166
+ lint:
167
+ name: Lint
168
+ runs-on: ubuntu-latest
169
+
170
+ steps:
171
+ - name: Checkout Repo
172
+ uses: actions/checkout@v7
173
+
174
+ - name: Setup
175
+ uses: ./.github/actions/setup
176
+ with:
177
+ nx-cache: build # reuses the build job's cache; this job does not save
178
+
179
+ - name: Lint
180
+ run: yarn lint
181
+
182
+ test:
183
+ name: Test
184
+ runs-on: ubuntu-latest
185
+
186
+ steps:
187
+ - name: Checkout Repo
188
+ uses: actions/checkout@v7
189
+
190
+ - name: Setup
191
+ uses: ./.github/actions/setup
192
+
193
+ - name: Test
194
+ run: yarn test
195
+
196
+ - name: Save Nx cache
197
+ uses: ./.github/actions/nx-cache
198
+ with:
199
+ mode: save
200
+
201
+ build:
202
+ name: Build
203
+ runs-on: ubuntu-latest
204
+
205
+ steps:
206
+ - name: Checkout Repo
207
+ uses: actions/checkout@v7
208
+
209
+ - name: Setup
210
+ uses: ./.github/actions/setup
211
+
212
+ - name: Build
213
+ run: yarn build
214
+
215
+ - name: Save Nx cache
216
+ uses: ./.github/actions/nx-cache
217
+ with:
218
+ mode: save
219
+
22
220
  release:
23
221
  name: Release
24
222
  runs-on: ubuntu-latest
25
- env:
26
- TURBO_CACHE_DIR: .turbo # if project uses Turbo
27
- YARN_ENABLE_GLOBAL_CACHE: false # so that .yarn/cache is written
223
+
224
+ needs: [lint, test, build]
28
225
 
29
226
  # If project publishes to NPM
30
227
  # https://davistobias.com/articles/adding-changeset/#2.1.b-adding-changeset-to-github-workflows
@@ -36,43 +233,18 @@ jobs:
36
233
 
37
234
  steps:
38
235
  - name: Checkout Repo
39
- uses: actions/checkout@v4
236
+ uses: actions/checkout@v7
40
237
 
41
- - name: Enable Corepack
42
- run: corepack enable
43
-
44
- - name: Setup Node.js
45
- uses: actions/setup-node@v6
46
- with:
47
- node-version: 24
48
- registry-url: 'https://registry.npmjs.org'
49
- cache: yarn
50
- cache-dependency-path: yarn.lock
51
-
52
- #TODO https://turbo.build/repo/docs/guides/ci-vendors/github-actions#remote-caching
53
- #TODO https://turborepo.dev/docs/guides/ci-vendors/github-actions#remote-caching-with-github-actionscache
54
- - name: Cache Turbo
55
- uses: actions/cache@v6
238
+ - name: Setup
239
+ uses: ./.github/actions/setup
56
240
  with:
57
- path: .turbo
58
- key: ${{ runner.os }}-turbo-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
59
- restore-keys: |
60
- ${{ runner.os }}-turbo-${{ github.run_id }}-${{ github.run_attempt }}-
61
- ${{ runner.os }}-turbo-
62
-
63
- - name: Cache Nx
64
- uses: actions/cache@v6
65
- with:
66
- path: .nx/cache
67
- key: ${{ runner.os }}-nx-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
68
- restore-keys: |
69
- ${{ runner.os }}-nx-${{ github.run_id }}-${{ github.run_attempt }}-
70
- ${{ runner.os }}-nx-
71
-
72
- - name: Install dependencies
73
- run: yarn install --immutable
74
-
75
- # Add this if Yarn 2+ is used and package is NOT private, otherwise postinstall should be configured, and this block skipped
76
- - name: Prepare
77
- run: yarn prepare
241
+ registry-url: 'https://registry.npmjs.org' # publish job needs .npmrc auth config
242
+ nx-cache: build # exact key of the build job's cache; this job does not save
243
+
244
+ # Different runner: outputs come from the build job's Nx cache, so nothing should rebuild
245
+ - name: Build
246
+ run: yarn build
247
+
248
+ - name: Release
249
+ run: yarn release # the project's publish command
78
250
  ```
@@ -24,6 +24,7 @@ cache:
24
24
  paths:
25
25
  - .turbo
26
26
  - .nx/cache
27
+ - .nx/workspace-data/default-v*.db # Nx indexes .nx/cache in a SQLite DB, cached under this fixed name
27
28
  - '**/.tscache'
28
29
  - '**/.tsbuildinfo'
29
30
  - '**/.next/cache'
@@ -37,9 +38,32 @@ stages:
37
38
  # separate so that cache can pre-populate if other steps would fail, it speeds things up
38
39
  before_script:
39
40
  - corepack enable
41
+ # Nx names the DB after the machine ID and ignores outputs it has no DB records for.
42
+ # Give the DB this runner's ID before install (postinstall may run Nx).
43
+ - |
44
+ d=.nx/workspace-data
45
+ id=$(cat /var/lib/dbus/machine-id 2>/dev/null || cat /etc/machine-id 2>/dev/null || echo machine)
46
+ db=$(ls $d/default-v*.db 2>/dev/null | head -n 1 || true)
47
+ if [ -z "$db" ]; then
48
+ rm -rf .nx/cache # outputs without their DB are unusable
49
+ else
50
+ to=$d/$id-v${db##*-v}
51
+ rm -f "$to" "$to-wal" "$to-shm"
52
+ mv "$db" "$to"
53
+ fi
54
+ echo "Nx cache DB for machine ID $id: $(ls $d/*.db 2>/dev/null || echo none)"
40
55
  - yarn install --immutable
41
56
  - yarn prepare # Add this if Yarn 2+ is used and package is NOT private, otherwise postinstall should be configured, and this line skipped
42
57
 
58
+ # GitLab saves the cache after after_script: store the DB under the fixed name the cache holds
59
+ after_script:
60
+ - |
61
+ d=.nx/workspace-data
62
+ db=$(ls -t $d/*-v*.db 2>/dev/null | head -n 1 || true)
63
+ to=$d/default-v${db##*-v}
64
+ [ -z "$db" ] || [ "$db" = "$to" ] || mv -f "$db" "$to"
65
+ echo "Nx cache DB to save: $(ls $d/default-v*.db 2>/dev/null || echo none)"
66
+
43
67
  install:
44
68
  stage: install
45
69
  script: