nukadoko 0.5.0 → 0.7.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.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +553 -3
  3. data/README.ja.md +22 -6
  4. data/README.md +13 -7
  5. data/docs/ci.ja.md +542 -0
  6. data/docs/ci.md +635 -0
  7. data/docs/commands.ja.md +1524 -0
  8. data/docs/commands.md +1281 -0
  9. data/docs/engines.json +19 -0
  10. data/docs/execution-events.ja.md +336 -0
  11. data/docs/execution-events.md +423 -0
  12. data/docs/glossary.json +1348 -0
  13. data/docs/guide.ja.md +733 -0
  14. data/docs/guide.md +815 -0
  15. data/docs/intent.ja.md +133 -0
  16. data/docs/intent.md +156 -0
  17. data/docs/layout.ja.md +442 -0
  18. data/docs/layout.md +399 -0
  19. data/docs/releasing.ja.md +186 -0
  20. data/docs/releasing.md +237 -0
  21. data/docs/ruby/reference.ja.md +302 -0
  22. data/docs/ruby/reference.md +368 -0
  23. data/docs/spec.ja.md +8916 -0
  24. data/docs/spec.md +11250 -0
  25. data/docs/tutorial.ja.md +451 -0
  26. data/docs/tutorial.md +458 -0
  27. data/docs/typescript/adopting.ja.md +231 -0
  28. data/docs/typescript/adopting.md +251 -0
  29. data/docs/typescript/doors.ja.md +301 -0
  30. data/docs/typescript/doors.md +329 -0
  31. data/docs/typescript/migration-playwright-test.ja.md +189 -0
  32. data/docs/typescript/migration-playwright-test.md +212 -0
  33. data/docs/typescript/migration.ja.md +391 -0
  34. data/docs/typescript/migration.md +505 -0
  35. data/docs/typescript/reference.ja.md +176 -0
  36. data/docs/typescript/reference.md +197 -0
  37. data/docs/typescript/upgrading.ja.md +1774 -0
  38. data/docs/typescript/upgrading.md +2224 -0
  39. data/docs/web-app.ja.md +627 -0
  40. data/docs/web-app.md +659 -0
  41. data/docs/writing-scenarios.ja.md +544 -0
  42. data/docs/writing-scenarios.md +563 -0
  43. data/lib/nukadoko/base.rb +12 -5
  44. data/lib/nukadoko/changed_files.rb +95 -0
  45. data/lib/nukadoko/check.rb +459 -51
  46. data/lib/nukadoko/claim_drops.rb +271 -0
  47. data/lib/nukadoko/claim_line.rb +24 -4
  48. data/lib/nukadoko/claim_rules.rb +143 -1
  49. data/lib/nukadoko/claim_sides.rb +157 -9
  50. data/lib/nukadoko/cli.rb +403 -50
  51. data/lib/nukadoko/codes.json +246 -21
  52. data/lib/nukadoko/codes.rb +21 -4
  53. data/lib/nukadoko/command.rb +120 -13
  54. data/lib/nukadoko/command_help.rb +128 -0
  55. data/lib/nukadoko/compat.rb +469 -0
  56. data/lib/nukadoko/criteria.rb +1 -1
  57. data/lib/nukadoko/definition.rb +157 -7
  58. data/lib/nukadoko/error_frames.rb +6 -3
  59. data/lib/nukadoko/events/count.rb +146 -0
  60. data/lib/nukadoko/events/counted.rb +114 -0
  61. data/lib/nukadoko/events/format.rb +257 -0
  62. data/lib/nukadoko/events/lists.rb +154 -0
  63. data/lib/nukadoko/events/path.rb +285 -0
  64. data/lib/nukadoko/events/read.rb +284 -0
  65. data/lib/nukadoko/events/reader.rb +490 -0
  66. data/lib/nukadoko/events/selection.rb +252 -0
  67. data/lib/nukadoko/events/tally.rb +438 -0
  68. data/lib/nukadoko/features.rb +2 -2
  69. data/lib/nukadoko/fixtures.rb +160 -35
  70. data/lib/nukadoko/http_recording.rb +6 -2
  71. data/lib/nukadoko/intent.rb +364 -0
  72. data/lib/nukadoko/intent_file.rb +81 -0
  73. data/lib/nukadoko/intent_view.rb +190 -0
  74. data/lib/nukadoko/js_json.rb +2 -1
  75. data/lib/nukadoko/judge.rb +2 -2
  76. data/lib/nukadoko/judgment_file.rb +22 -1
  77. data/lib/nukadoko/judgments.rb +33 -3
  78. data/lib/nukadoko/measure_mcp.rb +202 -0
  79. data/lib/nukadoko/parts.rb +8 -2
  80. data/lib/nukadoko/path_view.rb +252 -0
  81. data/lib/nukadoko/place_rows.rb +161 -0
  82. data/lib/nukadoko/program.rb +1265 -51
  83. data/lib/nukadoko/program_log.rb +122 -0
  84. data/lib/nukadoko/program_shape.rb +385 -0
  85. data/lib/nukadoko/project_fixtures.rb +43 -10
  86. data/lib/nukadoko/project_program.rb +5 -4
  87. data/lib/nukadoko/repeated_prefix.rb +310 -0
  88. data/lib/nukadoko/report_run.rb +3 -3
  89. data/lib/nukadoko/run.rb +1156 -159
  90. data/lib/nukadoko/run_record.rb +70 -46
  91. data/lib/nukadoko/scaffold.rb +24 -6
  92. data/lib/nukadoko/schema.rb +15 -2
  93. data/lib/nukadoko/secrets.rb +55 -5
  94. data/lib/nukadoko/states.rb +478 -0
  95. data/lib/nukadoko/step.rb +71 -2
  96. data/lib/nukadoko/step_fixtures.rb +52 -3
  97. data/lib/nukadoko/summary.rb +803 -30
  98. data/lib/nukadoko/table.rb +4 -2
  99. data/lib/nukadoko/text_fit.rb +20 -7
  100. data/lib/nukadoko/trace.rb +152 -45
  101. data/lib/nukadoko/tree_passes.rb +95 -33
  102. data/lib/nukadoko/underneath.rb +311 -0
  103. data/lib/nukadoko/verdict.rb +18 -1
  104. data/lib/nukadoko/version.rb +1 -1
  105. data/lib/nukadoko/vocabulary.rb +166 -23
  106. data/lib/nukadoko/walk.rb +2 -2
  107. data/lib/nukadoko/walk_step.rb +1 -1
  108. data/lib/nukadoko.rb +23 -0
  109. data/llms.txt +42 -35
  110. data/sig/generated/nukadoko/base.rbs +4 -4
  111. data/sig/generated/nukadoko/changed_files.rbs +42 -0
  112. data/sig/generated/nukadoko/check.rbs +147 -10
  113. data/sig/generated/nukadoko/claim_drops.rbs +135 -0
  114. data/sig/generated/nukadoko/claim_line.rbs +11 -0
  115. data/sig/generated/nukadoko/claim_rules.rbs +49 -4
  116. data/sig/generated/nukadoko/claim_sides.rbs +63 -12
  117. data/sig/generated/nukadoko/cli.rbs +80 -7
  118. data/sig/generated/nukadoko/codes.rbs +19 -4
  119. data/sig/generated/nukadoko/command.rbs +68 -1
  120. data/sig/generated/nukadoko/command_help.rbs +18 -0
  121. data/sig/generated/nukadoko/compat.rbs +392 -0
  122. data/sig/generated/nukadoko/criteria.rbs +1 -1
  123. data/sig/generated/nukadoko/definition.rbs +50 -0
  124. data/sig/generated/nukadoko/error_frames.rbs +1 -1
  125. data/sig/generated/nukadoko/events/count.rbs +69 -0
  126. data/sig/generated/nukadoko/events/counted.rbs +70 -0
  127. data/sig/generated/nukadoko/events/format.rbs +163 -0
  128. data/sig/generated/nukadoko/events/lists.rbs +47 -0
  129. data/sig/generated/nukadoko/events/path.rbs +161 -0
  130. data/sig/generated/nukadoko/events/read.rbs +109 -0
  131. data/sig/generated/nukadoko/events/reader.rbs +226 -0
  132. data/sig/generated/nukadoko/events/selection.rbs +100 -0
  133. data/sig/generated/nukadoko/events/tally.rbs +227 -0
  134. data/sig/generated/nukadoko/features.rbs +6 -4
  135. data/sig/generated/nukadoko/fixtures.rbs +67 -11
  136. data/sig/generated/nukadoko/http_recording.rbs +1 -1
  137. data/sig/generated/nukadoko/intent.rbs +132 -0
  138. data/sig/generated/nukadoko/intent_file.rbs +46 -0
  139. data/sig/generated/nukadoko/intent_view.rbs +69 -0
  140. data/sig/generated/nukadoko/judgment_file.rbs +7 -1
  141. data/sig/generated/nukadoko/judgments.rbs +10 -0
  142. data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
  143. data/sig/generated/nukadoko/parts.rbs +2 -2
  144. data/sig/generated/nukadoko/path_view.rbs +105 -0
  145. data/sig/generated/nukadoko/place_rows.rbs +43 -0
  146. data/sig/generated/nukadoko/program.rbs +627 -23
  147. data/sig/generated/nukadoko/program_log.rbs +67 -0
  148. data/sig/generated/nukadoko/program_shape.rbs +147 -0
  149. data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
  150. data/sig/generated/nukadoko/project_program.rbs +2 -1
  151. data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
  152. data/sig/generated/nukadoko/report_run.rbs +1 -1
  153. data/sig/generated/nukadoko/run.rbs +286 -41
  154. data/sig/generated/nukadoko/run_record.rbs +20 -12
  155. data/sig/generated/nukadoko/scaffold.rbs +3 -0
  156. data/sig/generated/nukadoko/schema.rbs +5 -0
  157. data/sig/generated/nukadoko/secrets.rbs +26 -3
  158. data/sig/generated/nukadoko/states.rbs +214 -0
  159. data/sig/generated/nukadoko/step.rbs +58 -1
  160. data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
  161. data/sig/generated/nukadoko/summary.rbs +256 -2
  162. data/sig/generated/nukadoko/table.rbs +3 -2
  163. data/sig/generated/nukadoko/trace.rbs +108 -33
  164. data/sig/generated/nukadoko/tree_passes.rbs +36 -8
  165. data/sig/generated/nukadoko/underneath.rbs +141 -0
  166. data/sig/generated/nukadoko/verdict.rbs +8 -0
  167. data/sig/generated/nukadoko/vocabulary.rbs +45 -6
  168. data/skills/nukadoko/SKILL.md +18 -18
  169. data/skills/nukadoko/references/checking-steps.md +16 -83
  170. data/skills/nukadoko/references/diagnosing.md +6 -6
  171. data/skills/nukadoko/references/done.md +22 -0
  172. data/skills/nukadoko/references/evidence.md +19 -6
  173. data/skills/nukadoko/references/exploring.md +22 -7
  174. data/skills/nukadoko/references/fixtures.md +12 -32
  175. data/skills/nukadoko/references/judgments.md +18 -0
  176. data/skills/nukadoko/references/maintenance.md +1 -1
  177. data/skills/nukadoko/references/merge-risk.md +1 -1
  178. data/skills/nukadoko/references/parts.md +46 -23
  179. data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
  180. data/skills/nukadoko/references/program.md +168 -169
  181. data/skills/nukadoko/references/reviewing.md +20 -20
  182. data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
  183. data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
  184. data/skills/nukadoko/references/ruby/fixtures.md +34 -0
  185. data/skills/nukadoko/references/ruby/program.md +112 -0
  186. data/skills/nukadoko/references/ruby/step-files.md +115 -0
  187. data/skills/nukadoko/references/running.md +34 -34
  188. data/skills/nukadoko/references/scenario-rules.md +7 -6
  189. data/skills/nukadoko/references/states.md +7 -1
  190. data/skills/nukadoko/references/step-files.md +41 -120
  191. data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
  192. data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
  193. data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
  194. data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
  195. data/skills/nukadoko/references/typescript/fixtures.md +56 -0
  196. data/skills/nukadoko/references/typescript/program.md +111 -0
  197. data/skills/nukadoko/references/typescript/step-files.md +104 -0
  198. data/skills/nukadoko/references/verdicts.md +10 -10
  199. data/skills/nukadoko/references/writing-steps.md +67 -67
  200. data/skills/nukadoko/references/writing-the-feature.md +1 -1
  201. data/skills/nukadoko-verification/SKILL.md +13 -8
  202. metadata +103 -7
  203. data/skills/nukadoko/references/ruby.md +0 -80
data/docs/layout.md ADDED
@@ -0,0 +1,399 @@
1
+ # Project layout
2
+
3
+ This page lists the files of a nukadoko project in each engine, and says what to write in each file.
4
+ The examples come from two projects, one for each engine.
5
+ Each project tests two programs: `greet`, a command line program, and a todo server.
6
+
7
+ ## The tree
8
+
9
+ You start a project with `nuka init`.
10
+ The command has a launcher in front of it, and the launcher is different in each engine:
11
+
12
+ <!-- engine: ruby -->
13
+ ```sh
14
+ bundle exec nuka init
15
+ ```
16
+
17
+ <!-- engine: typescript -->
18
+ ```sh
19
+ npx nuka init
20
+ ```
21
+
22
+ In the rest of this page, `nuka` stands for the command with the launcher of your engine in front of it.
23
+
24
+ `nuka init` writes the config file and the `features/steps/` directory.
25
+ It also adds lines to `.gitignore`: `.nukadoko/`, `.env`, `.env.*`, and `!.env.example`.
26
+ It also changes one project file in each engine:
27
+
28
+ | Engine | What `nuka init` also changes |
29
+ | --- | --- |
30
+ | Ruby | When the project has a `Rakefile`, `init` adds a `scenarios` task that runs `nuka run`. A project with no `Rakefile` gets no task. |
31
+ | TypeScript | `init` adds the `test:scenarios` script (`nuka run`) to `package.json`. When `tsconfig.json` has an `include` list, `init` adds `features/**/*` and the config file to it. `init` also sets `rewriteRelativeImportExtensions` in `compilerOptions`. It does not set it when the file already chose this option or `allowImportingTsExtensions`, directly or through `extends`. |
32
+
33
+ In a TypeScript project, `package.json` can say `"type": "commonjs"`, or have no `type`.
34
+ Then `init` writes `nukadoko.config.mts`, and `nuka scaffold` writes `.mts` step files.
35
+
36
+ The two trees show each project after these actions: `init`, two feature files, eleven step files, one helper, one judgment, and one run.
37
+ A judgment is the recorded decision of a reviewer on a value that a step cannot compare by itself ([Judgments](spec.md#judgments)).
38
+ Nine of the step files are the steps of the greet and todo cases that CI runs.
39
+ The other two are `todo-count-is`, which uses the `todos` project fixture of [the config file](#the-config-file), and `greeting-reads-as`, which a reviewer judges.
40
+ A fixture is a value that nukadoko gives to a step, and a project fixture is a fixture that the config adds ([Fixtures a step can ask for](writing-scenarios.md#fixtures-a-step-can-ask-for)).
41
+ The comment on each line says who wrote the file.
42
+ [What to commit](#what-to-commit) says which files go into git.
43
+
44
+ <!-- engine: ruby -->
45
+ ```text
46
+ .env you (secrets; not committed)
47
+ .gitignore you, and nuka init adds lines
48
+ Gemfile you
49
+ Gemfile.lock Bundler
50
+ Rakefile you, and nuka init adds a task
51
+ nukadoko.config.rb nuka init, then you
52
+ app/server.ts the todo server under test (TypeScript; not part of nukadoko)
53
+ src/greet.rb greet, the program under test
54
+ features/greet.feature you
55
+ features/todo.feature you
56
+ features/steps/add_todo.rb you, or nuka scaffold
57
+ features/steps/exits_with.rb
58
+ features/steps/run_greet.rb
59
+ features/steps/... (eight more step files)
60
+ features/steps/lib/todos.rb you (a helper, not a step)
61
+ judgments/features/greet.feature.json nuka judge
62
+ sig/nukadoko/steps.rbs nuka sig
63
+ .nukadoko/runs/run-20261203-230707-urk6/ nuka run
64
+ ```
65
+
66
+ <!-- engine: typescript -->
67
+ ```text
68
+ .env you (secrets; not committed)
69
+ .gitignore you, and nuka init adds lines
70
+ package.json you, and nuka init adds a script
71
+ package-lock.json npm
72
+ nukadoko.config.ts nuka init, then you
73
+ app/server.ts the todo server under test (not part of nukadoko)
74
+ src/greet.ts greet, the program under test
75
+ features/greet.feature you
76
+ features/todo.feature you
77
+ features/steps/add-todo.ts you, or nuka scaffold
78
+ features/steps/exits-with.ts
79
+ features/steps/run-greet.ts
80
+ features/steps/... (eight more step files)
81
+ features/steps/lib/todos.ts you (a helper, not a step)
82
+ judgments/features/greet.feature.json nuka judge
83
+ .nukadoko/runs/run-20261203-230451-w48l/ nuka run
84
+ ```
85
+
86
+ In the Ruby engine, the gem depends on `playwright-ruby-client`.
87
+ A step that uses `page` needs a browser that this client can launch ([Install and command](ruby/reference.md#install-and-command)).
88
+ The Ruby `request` fixture sends its requests without Playwright.
89
+
90
+ In a TypeScript project, a step that uses `page` or `request` needs `playwright` in `devDependencies`.
91
+ Without it, `nuka check` reports `playwright-missing` and names the command that installs the correct version:
92
+
93
+ <!-- engine: typescript -->
94
+ ```sh
95
+ npm install -D -E playwright@1.63.0
96
+ ```
97
+
98
+ ## The config file
99
+
100
+ One file holds the config and the program under test: `nukadoko.config.rb` or `nukadoko.config.ts`.
101
+ `nuka` reads it from the directory where it runs, never from a parent directory.
102
+ This config starts the todo server for each run and loads `.env`.
103
+ It also adds one project fixture, `todos`, which uses a helper from `features/steps/lib/`.
104
+ No case that CI runs holds this fixture or its helper, but both ran in both engines for this page.
105
+
106
+ The program under test is the todo server.
107
+ It is a Node program in both projects, so `command` starts it with `node`.
108
+ A Rails app uses `bin/rails server -p {port}` instead ([In a Rails app](web-app.md#in-a-rails-app)).
109
+ nukadoko gives each system a free port and puts it in place of `{port}` ([serve](spec.md#serve)).
110
+ A system is one pass of a run against one program ([Systems](spec.md#systems)).
111
+
112
+ ```ruby
113
+ Nukadoko.config(
114
+ envFiles: [".env"],
115
+ program: -> { { serve: { command: "node app/server.ts --port {port}", ready: "/todos" } } },
116
+ )
117
+
118
+ Nukadoko.fixture(:todos) do |use, request:|
119
+ use.(Todos::Reader.new(request))
120
+ end
121
+ ```
122
+
123
+ ```ts
124
+ import { defineConfig, defineFixtures } from "nukadoko";
125
+ import { todoTitles } from "./features/steps/lib/todos.ts";
126
+
127
+ export default defineConfig({
128
+ envFiles: [".env"],
129
+ program: () => ({
130
+ serve: { command: "node app/server.ts --port {port}", ready: "/todos" },
131
+ }),
132
+ fixtures: defineFixtures({
133
+ todos: async ({ request }, use) => {
134
+ await use({ titles: () => todoTitles(request) });
135
+ },
136
+ }),
137
+ });
138
+ ```
139
+
140
+ This is the helper that the fixture uses.
141
+ It reads the titles of the todos from `GET /todos`:
142
+
143
+ ```ruby
144
+ # Reads the todo list through the request fixture. Not a step: it defines no Nukadoko::Step class.
145
+ module Todos
146
+ Reader = Struct.new(:request) do
147
+ def titles = request.get("/todos").json.map { _1["title"] }
148
+ end
149
+ end
150
+ ```
151
+
152
+ ```ts
153
+ // Reads the titles from GET /todos. Not a step: it has no default export.
154
+ export interface TodoReader {
155
+ get(url: string): Promise<{ json(): Promise<unknown> }>;
156
+ }
157
+
158
+ export async function todoTitles(request: TodoReader): Promise<string[]> {
159
+ const res = await request.get("/todos");
160
+ const todos = (await res.json()) as Array<{ title: string }>;
161
+ return todos.map((todo) => todo.title);
162
+ }
163
+ ```
164
+
165
+ A step gets the fixture when it asks for `todos` by name ([Fixtures a step can ask for](writing-scenarios.md#fixtures-a-step-can-ask-for)).
166
+ In these projects, the step `todo-count-is` asks for it.
167
+ When no step asks for a fixture, `nuka check` reports a note.
168
+
169
+ The table lists each top-level key of the config.
170
+ A "yes" in an engine column means that the engine reads the key.
171
+ A key that both engines read has the same spelling in both.
172
+ The Ruby engine adds project fixtures with `Nukadoko.fixture` calls, not with a `fixtures` key.
173
+ The "Configuration" section of each reference lists the keys that its engine reads: [Ruby](ruby/reference.md#configuration) and [TypeScript](typescript/reference.md#configuration).
174
+ The spec describes every key in [Environments and secrets](spec.md#environments-and-secrets).
175
+
176
+ | Key | What it holds | Ruby | TypeScript |
177
+ | --- | --- | --- | --- |
178
+ | `program` | how the program under test starts or where it runs, and its environments ([Program](spec.md#program)) | yes | yes |
179
+ | `envFiles` | the env files that every environment loads | yes | yes |
180
+ | `secrets` | the `public` and `redact` lists, which change how a key is redacted | yes | yes |
181
+ | `fixtures` | project fixtures ([Fixtures](spec.md#fixtures)) | no, use `Nukadoko.fixture` calls | yes |
182
+ | `parameterTypes` | custom parameter types for patterns | yes | yes |
183
+ | `browser` | Playwright launch options | yes | yes |
184
+ | `stepTimeout` | how long the `run` of one step can take, in ms | yes | yes |
185
+ | `featuresDir` | the feature files and the step code (default `features`) | no, always `features` | yes |
186
+ | `additionalFeatureDirs` | more feature directories that `nuka check` reads and `nuka run` does not run | no | yes |
187
+ | `stateDir` | where `nuka` writes at run time (default `.nukadoko`) | no, always `.nukadoko` | yes |
188
+ | `retention` | how many runs, and how many days of `nuka do` records, stay | no | yes |
189
+ | `browserType` | `chromium`, `firefox`, or `webkit` | no | yes |
190
+ | `browserContext`, `requestContext` | options for the browser context and for the `request` fixture | no | yes |
191
+ | `showRequests` | experimental: draw each request that a step sends on a traced page | no | yes |
192
+ | `judgedView` | keep a view of each open page after a judged reading | no | yes |
193
+ | `worldParameters` | the `parameters` of a compat World | no | yes |
194
+ | `fixtureTimeout` | the default setup and teardown timeout of a fixture | no | yes |
195
+
196
+ An engine checks the keys in two places:
197
+
198
+ - At the top level of the config, the TypeScript engine refuses an unknown key with `config-invalid`, in `nuka check` and in `nuka run`. The Ruby engine ignores an unknown top-level key and gives no message. A misspelled key and a key with "no" in the Ruby column are both ignored.
199
+ - Inside `program`, both engines refuse an unknown key with `config-invalid`, in `nuka check` and in `nuka run` ([Program](ruby/reference.md#program) in the Ruby reference).
200
+
201
+ ## Feature files
202
+
203
+ Feature files go in `features/`, the default `featuresDir`.
204
+ A feature file holds one `Feature:`, and its scenarios are your acceptance criteria.
205
+ `nuka run` with no target runs each feature file under `featuresDir`.
206
+ It skips `node_modules` and each directory whose name starts with `.`.
207
+ In the Ruby engine, `nuka check` still reads the feature files under `node_modules`.
208
+
209
+ A feature file is the unit that `nuka run --concurrency <n>` gives to a worker.
210
+ All the scenarios of one file run in one worker, in order.
211
+ Some files share something with other files that nukadoko cannot see, such as one test account or one queue.
212
+ Put `@nukadoko:serial` on the `Feature:` line of such a file:
213
+
214
+ ```gherkin
215
+ @nukadoko:serial
216
+ Feature: Todo list
217
+ ```
218
+
219
+ That file then runs while no other file runs ([Scenarios (the scripted path)](spec.md#scenarios-the-scripted-path)).
220
+
221
+ ## Step files
222
+
223
+ A step file holds one step, and the file name is the step name.
224
+ `exits_with.rb` and `exits-with.ts` both define the step `exits-with`.
225
+ The Ruby file defines a class whose name is the CamelCase form of the file name: `exits_with.rb` holds `ExitsWith`.
226
+ The TypeScript file has the step as its default export.
227
+
228
+ These two files define the step `exits-with`.
229
+ They come from the greet case that CI runs.
230
+ The `from` line reads the `exitCode` result of the step `run-greet`, and the claim compares it with the number in the sentence.
231
+ [A step's contract](writing-scenarios.md#a-steps-contract) and [Claims](writing-scenarios.md#claims) explain each part.
232
+
233
+ ```ruby
234
+ class ExitsWith < Nukadoko::Step
235
+ description "The exit code of the greet run is exactly this"
236
+ pattern "it exits with {code:int}"
237
+ args do
238
+ number :code, "The expected exit code"
239
+ field :exitCode, RunGreet.returns[:exitCode]
240
+ end
241
+ from exitCode: [RunGreet, :exitCode]
242
+ claims [{ actual: "exitCode", compare: "equal", expected: "code" }]
243
+ end
244
+ ```
245
+
246
+ ```ts
247
+ import { defineStep, z } from "nukadoko";
248
+ import runGreet from "./run-greet.ts";
249
+
250
+ export default defineStep({
251
+ description: "The exit code of the greet run is exactly this",
252
+ pattern: "it exits with {code:int}",
253
+ args: z.object({
254
+ code: z.number().describe("The expected exit code"),
255
+ exitCode: runGreet.returns.shape.exitCode,
256
+ }),
257
+ from: {
258
+ exitCode: [runGreet, "exitCode"],
259
+ },
260
+ claims: [{ actual: "exitCode", compare: "equal", expected: "code" }],
261
+ });
262
+ ```
263
+
264
+ Code that is not a step, such as a client or a parser, goes in `features/steps/lib/`.
265
+ Each engine loads the files in a different way.
266
+
267
+ In the Ruby engine:
268
+
269
+ - `nuka` loads each `.rb` file under `features/`, helpers in `features/steps/lib/` too.
270
+ - A step can use another step class by name (`RunGreet`), in any file order.
271
+ - Give a helper module the CamelCase name of its file: `todos.rb` holds `Todos`. Then the config can also use the module by name.
272
+
273
+ In the TypeScript engine:
274
+
275
+ - `nuka` imports each `.ts`, `.mts`, `.js`, and `.mjs` file under `featuresDir`.
276
+ - A file that has no step as its default export is not a step. `nuka` skips it with no message, so a helper needs no mark.
277
+ - A default export that is a copy of a step (not the value that the step definition returned) is refused with a message.
278
+ - A step file or the config imports another file by its relative path, with the `.ts` extension.
279
+
280
+ `nuka scaffold` writes a new step file with the correct name.
281
+ `nuka steps` lists the steps that `nuka` found, so a step file that `nuka` skipped is missing from that list.
282
+ In the Ruby engine, `nuka sig` writes `sig/nukadoko/steps.rbs` for Steep ([Types and tooling](ruby/reference.md#types-and-tooling)).
283
+
284
+ ## The state directory
285
+
286
+ `nuka` writes all run-time data in `.nukadoko/`.
287
+ `nuka run` runs the scenarios.
288
+ `nuka do` runs one step by hand, outside a run.
289
+ `nuka report` writes a report of a run, such as Allure results.
290
+ This listing is from the Ruby project after one `nuka run`, one `nuka do`, and one `nuka report --format allure`.
291
+ The TypeScript project, after the same three commands, has the same files, with other ids.
292
+
293
+ ```text
294
+ .nukadoko/do/step-20261203-230708-b08b/record.json
295
+ .nukadoko/do/step-20261203-230708-b08b/process-1.stdout.txt
296
+ .nukadoko/do/step-20261203-230708-b08b/system/main/program.log
297
+ .nukadoko/export/allure-results/
298
+ .nukadoko/runs/run-20261203-230707-urk6/exports
299
+ .nukadoko/runs/run-20261203-230707-urk6/run.json
300
+ .nukadoko/runs/run-20261203-230707-urk6/sources.json
301
+ .nukadoko/runs/run-20261203-230707-urk6/summary.md
302
+ .nukadoko/runs/run-20261203-230707-urk6/steps/step-20261203-230707-b621/
303
+ .nukadoko/runs/run-20261203-230707-urk6/systems/default/main/program.log
304
+ ```
305
+
306
+ In the TypeScript engine, the `stateDir` key moves the directory.
307
+ The Ruby engine always uses `.nukadoko/`.
308
+ The directory holds these entries:
309
+
310
+ - `runs/<run_id>/` holds one run: `run.json` (the result), `summary.md` (the run summary), and `sources.json` (the text of each feature file that the run read). `nuka report` can draw a run from this directory alone.
311
+ - `runs/<run_id>/steps/<id>/` holds one step record: what the tool measured for one step ([Records](spec.md#records)). The directory holds `record.json` and its evidence, such as `http.jsonl`, `program-log.main.txt`, a trace, or the output of a process.
312
+ - `runs/<run_id>/scenarios/<id>/` holds evidence of one scenario: its last screenshot, and a trace of each hook that used the browser. A scenario that writes no evidence of its own has no directory, so the first listing has none.
313
+ - `runs/<run_id>/systems/<environment>/<service>/` holds `program.log`, the log of one service of the program that the run started, `main` for a program of one ([Services](spec.md#services)). A run starts one system for each environment that it selects ([Environments](spec.md#environments)). When that service writes execution events, its redacted `events.jsonl` is there too ([Execution events](execution-events.md)).
314
+ - `runs/<run_id>/exports` lists each file that `nuka report` wrote for the run under the state directory. In the TypeScript engine, retention and `nuka clean` remove these files together with the run. The Ruby engine has no retention, and its `nuka clean` does not read this file (see the table below).
315
+ - `runs/<run_id>/pauses/<n>/` and `runs/<run_id>/answers/<n>.json` are in a run of `nuka run --step` only. `pauses/<n>/` holds the views of the open pages at pause n, and the requests that these pages sent while the walk was paused. With no open page, the directory is empty. `answers/<n>.json` is the answer that `nuka step` gave to pause n.
316
+ - `do/<id>/` holds the record of one `nuka do` call, in the same shape as `steps/<id>/`, plus `system/<service>/program.log`, the log of each service of the program that the call started. It is outside every run directory, because a `nuka do` call is not part of a run.
317
+ - `export/` holds what `nuka report` writes. `export/allure-results/` is the default output of `nuka report --format allure`. `export/allure-history.jsonl` is the only file in the state directory that a new run cannot make again.
318
+ - `walk.json` and `walk.lock/<n>` hold the state of the newest walk of `nuka run --step`. The next walk replaces them.
319
+ - `walks-reported/<n>` is a file for each walk whose end `nuka step` reported. These files stay, so the walk numbers keep counting up.
320
+
321
+ This listing is from the Ruby project after one walk of the first todo scenario, `nuka run features/todo.feature:3 --step`.
322
+ The two answers were `nuka step next 1 --walk 1` and `nuka step next 2 --walk 1`.
323
+ The TypeScript project, after the same walk, has the same files, with other ids.
324
+
325
+ ```text
326
+ .nukadoko/runs/run-20261204-002030-9s07/answers/1.json
327
+ .nukadoko/runs/run-20261204-002030-9s07/answers/2.json
328
+ .nukadoko/runs/run-20261204-002030-9s07/pauses/1/
329
+ .nukadoko/runs/run-20261204-002030-9s07/pauses/2/
330
+ .nukadoko/runs/run-20261204-002030-9s07/run.json
331
+ .nukadoko/runs/run-20261204-002030-9s07/sources.json
332
+ .nukadoko/runs/run-20261204-002030-9s07/steps/step-20261204-002030-dd9w/
333
+ .nukadoko/runs/run-20261204-002030-9s07/steps/step-20261204-002034-gkrj/
334
+ .nukadoko/runs/run-20261204-002030-9s07/summary.md
335
+ .nukadoko/runs/run-20261204-002030-9s07/systems/default/main/program.log
336
+ .nukadoko/walk.json
337
+ .nukadoko/walk.lock/1
338
+ .nukadoko/walks-reported/1
339
+ ```
340
+
341
+ The directory is in `.gitignore`, and it is not for commits.
342
+ It is sensitive: traces, and screenshots that a step saves, are not redacted.
343
+
344
+ The engines remove old data in different ways:
345
+
346
+ | Engine | After `nuka run` | `nuka clean` |
347
+ | --- | --- | --- |
348
+ | Ruby | removes nothing; runs and `do/` records stay until you remove them | removes all runs, all `do/` records, and the contents of `export/allure-results/`; keeps every other file under `export/` |
349
+ | TypeScript | keeps the newest 20 runs and `nuka do` records of the last 7 days (`retention`), and removes the rest | removes all runs, all `do/` records, the contents of `export/allure-results/`, and each file under `export/` that a run's `exports` file names |
350
+
351
+ In both engines, `nuka clean --dry-run` shows the list first, and `nuka clean` keeps these entries:
352
+
353
+ - `export/allure-history.jsonl`, and each file that a person put under `export/`.
354
+ - The run directory of a walk that is live. `nuka clean` reports the note `walk-run-kept` for it.
355
+ - `walk.json`, `walk.lock/`, and `walks-reported/`.
356
+
357
+ `nuka clean` also removes the `cache/` and `records/` directories that an earlier release wrote, because nothing reads them now.
358
+
359
+ Judgments are not in the state directory.
360
+ `nuka judge` writes them to `judgments/<feature path>.json` at the project root, so retention and `nuka clean` never remove one ([Judgments](spec.md#judgments)).
361
+ The spec also describes the directory in [The state directory](spec.md#the-state-directory).
362
+
363
+ ## What to commit
364
+
365
+ | Path | Written by | Commit? |
366
+ | --- | --- | --- |
367
+ | `features/*.feature` | you | yes |
368
+ | `features/steps/*` | you, or `nuka scaffold` | yes |
369
+ | `features/steps/lib/` | you | yes |
370
+ | `nukadoko.config.rb`, `nukadoko.config.ts` | `nuka init`, then you | yes |
371
+ | `Gemfile`, `Gemfile.lock` | you and Bundler | yes |
372
+ | `package.json`, `package-lock.json` | you and npm; `nuka init` adds `test:scenarios` | yes |
373
+ | `Rakefile` | you; `nuka init` adds the `scenarios` task | yes |
374
+ | `tsconfig.json` | you; `nuka init` adds to an `include` list and to `compilerOptions` | yes |
375
+ | `.gitignore` | you; `nuka init` adds its lines | yes |
376
+ | `judgments/` | `nuka judge` | yes, so that review records who judged |
377
+ | `sig/nukadoko/steps.rbs` | `nuka sig` | yes, when Steep checks the steps |
378
+ | `.env.example` | you | yes |
379
+ | `.env`, `.env.*` | you | no |
380
+ | `.nukadoko/` | `nuka run`, `nuka do`, `nuka report` | no |
381
+
382
+ ## What goes where
383
+
384
+ | I want to ... | Write it in |
385
+ | --- | --- |
386
+ | state a new acceptance criterion | a `Scenario:` in a feature file |
387
+ | use a sentence that no step matches yet | a new step file in `features/steps/` (`nuka scaffold` writes one) |
388
+ | start my app before the scenarios | `program` in the config ([Program](spec.md#program)) |
389
+ | test an app that already runs | `url` in `program` ([A program nukadoko does not start](spec.md#a-program-nukadoko-does-not-start)) |
390
+ | read a secret | an env file in `envFiles`, read with the `requireEnv` fixture ([Environments and secrets](spec.md#environments-and-secrets)); in Ruby its name is `require_env`, and `requireEnv` also works ([Context](ruby/reference.md#context)) |
391
+ | keep a secret out of git | `.env`, which is gitignored; put the key names in `.env.example` |
392
+ | share a client or a login between steps | a project fixture in the config ([Fixtures](spec.md#fixtures)) |
393
+ | share code that is not a step | a helper in `features/steps/lib/` |
394
+ | run a feature file while no other file runs | `@nukadoko:serial` on its `Feature:` line |
395
+ | keep a reviewer's decision on a value | `nuka judge`, which writes `judgments/` ([Judgments](spec.md#judgments)) |
396
+ | check the step types with a type checker | `nuka sig`, which writes `sig/nukadoko/steps.rbs` (Ruby only) |
397
+ | start the scenarios from Rake or npm | the `scenarios` task or the `test:scenarios` script that `nuka init` adds |
398
+
399
+ [Japanese](layout.ja.md)
@@ -0,0 +1,186 @@
1
+ # リリースする
2
+
3
+ npm パッケージはディレクトリ `typescript/` です。
4
+ このページの `package.json` はすべて `typescript/package.json` で、`npm` のコマンドはすべてそこで実行します。
5
+ gem は `ruby/` で、その節は最後にあります。
6
+
7
+ nukadoko はすでに npm にあります。
8
+ リリースは npm パッケージと、`package.json` の version に `v` を付けた git tag です。
9
+ `package.json` を変える `main` への push が [`.github/workflows/publish.yml`](../.github/workflows/publish.yml) を走らせます。
10
+ その `check` ジョブは `package.json` の version を読み、tag `v<version>` を探します。
11
+ 依存の更新のあとのように、その tag が既にあれば、その実行は何もリリースしません。
12
+ 無ければ publish ジョブが push された commit をインストールし、`dist/` をビルドし、このリポジトリ自身の CI と同じチェック(`npm run archstrict` を含む)を実行し、`npm run pack-check` と skill の作業例を実行してから `npm publish` します。
13
+ npm は GitHub Actions の OIDC で認証します。
14
+ リポジトリとパッケージがどちらも公開されているので、npm の provenance は自動で付きます。
15
+ GitHub の Environment `publish` が人のゲートです。
16
+ publish ジョブは承認されるまでそこで待ちます。
17
+
18
+ `npm publish` が成功したあと、3 つめのジョブがそのバージョンの tag と GitHub release を作ります。
19
+ そのジョブは publish ジョブが checkout したのと同じ commit を checkout し、`typescript/CHANGELOG.md` からそのバージョンの節だけを取り出し、publish した commit を指定して `gh release create --target` を実行します。
20
+ その呼び出しが、その commit に tag `v<version>` を作ります。
21
+ その tag を手で push する人はいません。
22
+ release が既にあれば、そのまま残します。
23
+ ジョブを再実行しても失敗しません。
24
+ publish ジョブの権限は `id-token: write` と `contents: read` です。
25
+ release ジョブの権限は `contents: write` です。
26
+ そのジョブは npm の OIDC トークンを持ちません。
27
+
28
+ パッケージが載せるのは、`dist/` にコンパイルした JavaScript(`nuka` の bin は `dist/cli.js`)、それに `src/`、`docs/`、`skills/`、`CHANGELOG.md`(`typescript/` のもの)、`llms.txt` です。
29
+ `dist/` は `.gitignore` に入っています。
30
+ workflow が push された commit からそれをビルドします。
31
+ `README.md`、`README.ja.md`、`LICENSE`、`package.json` は npm が常に tarball へ入れるので、それらも入ります。
32
+
33
+ `package.json` は `prepublishOnly` を宣言していますが、`.npmrc` が `ignore-scripts=true` なので、`npm publish` のあいだその hook は走りません。
34
+ workflow が自分で `npm run build` を実行します。
35
+ そのビルド無しに publish すると、そこにあった `dist/` が何であれ、それが載ります。
36
+ `src/` より古いことも、そもそも無いこともあります。
37
+
38
+ workflow は `NPM_TOKEN` を読みません。
39
+ リポジトリの secrets にも置きません。
40
+ 最初の 1 回をトークンで publish する手順はありません。
41
+ パッケージは既にあり、その Trusted Publisher も登録済みです。
42
+
43
+ ## 一度だけの準備
44
+
45
+ Environment と trusted publisher は、2026-09-23 の時点で既に設定済みです。
46
+ どちらも、無くなったときだけ作り直します。
47
+ これは人の手順です。
48
+ このリポジトリの中の何も、Environment を作ったり trusted publisher を登録したりはしません。
49
+
50
+ 1. GitHub リポジトリ `meganemura/nukadoko` には、名前が `publish` で承認する人を必須にした Environment があります。
51
+ workflow のジョブは `environment: publish` を指定しているので、リリースの実行は承認されるまでそこで待ちます。
52
+
53
+ その実行は tag からではなく、`main` ブランチから来ます。
54
+ Environment が deployment の対象にできるブランチと tag を絞っているなら、その一覧で `main` を許可しなければなりません。
55
+ `v*` の tag だけを許可する一覧は、その実行を拒否します。
56
+ これはオーナーが、リポジトリ設定の Environments で変えます。
57
+
58
+ trusted publisher を登録しても、承認待ちは開きません。
59
+ 承認待ちが現れるのは、リリースの実行が Environment `publish` に入ったときだけです。
60
+
61
+ Environment が無ければ、次のリリースより前にそれを作り、承認する人を必須にします。
62
+ そうしないと GitHub は最初の実行時に、承認する人が必須でない Environment を作り、チェックが通った瞬間に publish します。
63
+
64
+ 2. npmjs.com の `nukadoko` パッケージには、`npm publish` を許可した GitHub Actions の trusted publisher が 1 つあります。
65
+ フィールドは大文字小文字を区別します。
66
+ publisher が無ければ、次の値で足します。
67
+
68
+ - Organization or user: `meganemura`
69
+ - Repository: `nukadoko`
70
+ - Workflow filename: `publish.yml` (ファイル名。`.yml` を含む)
71
+ - Environment name: `publish`
72
+ - Allowed action: `npm publish`
73
+
74
+ 2026-09-03 より後に作った trusted publisher は、最初から `npm stage publish` が許可されています。
75
+ `npm publish` も選びます。
76
+ `publish.yml` が実行するのは `npm publish` です。
77
+
78
+ `package.json` の `repository.url` は既に `git+https://github.com/meganemura/nukadoko.git` です。
79
+ npm はその URL を workflow のリポジトリと突き合わせます。
80
+
81
+ 3. Actions からの OIDC による publish が動いたあと、パッケージ設定で二要素認証を必須にし、トークンによる publish を禁止できます。
82
+ これは任意の強化です。
83
+ trusted publisher はそのまま動きます。
84
+
85
+ ## 各バージョン
86
+
87
+ 1. `## Unreleased` の下にあるノートを新しいバージョンの見出しへ移し、`## Unreleased` は空にします。
88
+ 見出しの形は `typescript/CHANGELOG.md` に既にあるものを保ちます。
89
+ release ジョブは、見出しが `##` とそのバージョンと空白で始まる節を取り出すからです。
90
+ `package.json` と `package-lock.json` に同じ version を書きます。
91
+ workflow はその version から tag を作ります。
92
+ `docs/typescript/upgrading.md` と `docs/typescript/upgrading.ja.md` では、「to the next release」(日本語では「から次のリリースへ」)で終わる見出しを、このバージョンを名指すように書き換えます。
93
+ たとえば `0.14.1 to 0.15.0` です。
94
+ 次に、英語と日本語の古い見出しの文言それぞれで `git grep -n "<古い見出しの文言>"` を実行し、その見出しの引用をすべて新しい見出しに書き換えます。
95
+ その節を参照する箇条書きは見出しを引用しています。
96
+ `tests/docs-cli-names.test.ts` は、そのファイルにもうない見出しの引用があると失敗します。
97
+
98
+ 2. `npm run archstrict && npm run typecheck && npm test && npm run selftest && npm run pack-check && npm run skill-examples` を実行します。
99
+ `pack-check` は本物の tarball を、このリポジトリの外の捨てプロジェクトへインストールし、そこで CLI を動かします。
100
+ これが捕まえるのは、このリポジトリが devDependency にしか挙げていないパッケージへ `bin` が依存していることと、`dist/` が `src/` と一致していないことです。
101
+ `skill-examples` は同じ tarball を `examples/acceptance/` の各プロジェクトのコピーへインストールし、そこで `nuka check` と `nuka run` を実行して、出力を `skills/nukadoko/references/typescript/examples/` にある実行記録と比べます。
102
+
103
+ 3. 前回の tag から `skills/` が変わっているとき(`git diff --stat v<previous>..HEAD -- skills/` が行を出すとき)は、skill の評価を手で 1 回行います。
104
+ `skills/nukadoko/references/typescript/examples/` の作業例を 1 つ選びます。
105
+ 捨てプロジェクトに、その例のプログラム(`examples/acceptance/` にあるそのプロジェクトの `src/`)を置き、この checkout の tarball をインストールします。
106
+ インストールされた skill から、その例の Markdown ファイルを `node_modules/nukadoko/skills/nukadoko/references/typescript/examples/` で削除し、エージェントにはほかの写しも渡しません。
107
+ エージェントにその例の「The ticket」の節を渡し、scenario を書いて実行するよう頼みます。
108
+ エージェントが書いた feature を、`skills/nukadoko/references/scenario-rules.md` の各ルール S1 から S12 について、満たす、満たさない、該当しない、で採点します。
109
+ その表と、例の名前と、モデルを `typescript/CHANGELOG.md` のこのバージョンの見出しの下に書き、release notes に載るようにします。
110
+ 満たさないルールは skill への指摘であって、このリリースを止める条件ではありません。
111
+ この評価は 1 つのモデルの 1 回の実行で、もう 1 回実行すれば採点は変わりえます。
112
+
113
+ 4. version の更新、changelog、upgrading の見出しを 1 つにまとめ、`chore: release <version>` として commit します。
114
+ その commit を `queue` ブランチ経由で `main` に入れます。
115
+ それが `main` に届くと workflow が始まります。
116
+ `v*` の tag を手で push しません。
117
+ tag は workflow が作ります。
118
+ この publish は `publish.yml` だけです。
119
+ checkout から `npm publish` を実行しません。
120
+
121
+ 5. その Actions の実行で Environment `publish` を承認します。
122
+ 承認待ちは、その実行が Environment に入ったことです。
123
+ workflow は `ubuntu-latest` の Node 24 を使い、npm の registry URL を設定します。
124
+ npm 11.5.1 以上を要求します。
125
+ その版が、GitHub の OIDC トークンを publish 用の資格情報に交換できる版だからです。
126
+ `npm ci --ignore-scripts` と `npm run archstrict` を実行します(そのチェックはソースを読むので、ビルドもブラウザも要りません)。
127
+ Playwright の Chromium をインストールし(`npm ci` はブラウザを入れず、スイートはそれを起動します)、`npm run build`、`npm run typecheck`、`npm test`、`npm run selftest`、`npm run pack-check`、`node scripts/skill-examples.ts` を実行し、追跡されているファイルが変わっていれば拒否します。
128
+ `dist/` は `.gitignore` に入っているので、新しいビルド出力は想定どおりであり、pack されるのもそれです。
129
+ そのあと `npm publish` を実行します。
130
+ action は commit id にピンされ、`ci.yml` と同じです。
131
+ このリポジトリは設定でそのピンを要求していて、tag は実行前に拒否されます。
132
+ パッケージの `engines` は `^22.18.0 || >=23.6.0` のままです。
133
+ Node 24 は publish ジョブであって、`nuka` を動かす人への新しい要件ではありません。
134
+
135
+ 6. workflow の `release` ジョブが、`npm publish` のあとに GitHub release を作ります。
136
+ `typescript/CHANGELOG.md` は、publish ジョブが checkout した commit から読みます。
137
+ `--notes-file CHANGELOG.md` はすべてのバージョンのノートを貼るので、ジョブは見出しが `##` とそのバージョンと空白で始まる節だけを取り出してから、publish した commit を `--target` に指定して `gh release create` を実行します。
138
+ その呼び出しが tag `v<version>` と release を作ります。
139
+ 両方を作るのはそのジョブです。
140
+
141
+ ## Ruby の gem
142
+
143
+ `ruby/` は gem `nukadoko` で、独立したパッケージです。
144
+ バージョンは `ruby/lib/nukadoko/version.rb`、変更履歴は `ruby/CHANGELOG.md` にあります。
145
+ 2 つのパッケージは別々にリリースします。
146
+ どちらのエンジンも同じ `conformance/` のケースを通るので、バージョンをそろえる必要はありません。
147
+ `ruby/lib/nukadoko/version.rb` を変える `main` への push が [`.github/workflows/release-gem.yml`](../.github/workflows/release-gem.yml) を動かします。
148
+ `package.json` は変わらないので、`publish.yml` は動きません。
149
+
150
+ workflow の形は `publish.yml` と同じです。
151
+ `check` ジョブは gem のバージョンを読み、tag `ruby-v<version>` を探し、`ruby/CHANGELOG.md` の見出しが `## [<version>]` で始まる節を読みます。
152
+ `test` ジョブは `ci.yml` の `ruby-engine` ジョブと同じチェックを実行します。
153
+ `publish` ジョブは GitHub Environment `rubygems` を待ち、gem をビルドし、GitHub の OIDC トークンを RubyGems の資格情報に交換し、`gem push` を実行します。
154
+ そのあと `release` ジョブが tag `ruby-v<version>` と、latest にしない GitHub release を作ります。
155
+ npm パッケージの release が latest のまま残ります。
156
+ `ruby-` の接頭辞で、gem の tag と npm パッケージの `v*` の tag を分けます。
157
+ どちらの tag も手で push しません。
158
+
159
+ ### gem の最初の設定
160
+
161
+ 一度だけ人が行う手順です。
162
+
163
+ 0. Ruby のワークフローが使う、GitHub 自身のものでない action `ruby/setup-ruby@*` を、Settings、Actions、General の Actions permissions で許します。
164
+ このリポジトリは名前を挙げた action だけを許していて、ほかの action を使うワークフローは最初のジョブの前に失敗します(`startup_failure`)。
165
+ その失敗は再実行では直らず、新しい push でもう一度始まります。
166
+ 1. `meganemura/nukadoko` に GitHub Environment `rubygems` を作り、required reviewers を付け、`main` からのデプロイを許します。
167
+ 2. rubygems.org の https://rubygems.org/profile/oidc/pending_trusted_publishers で、pending trusted publisher を足します(gem はまだありません)。
168
+ - Gem name: `nukadoko`
169
+ - Repository owner: `meganemura`
170
+ - Repository name: `nukadoko`
171
+ - Workflow filename: `release-gem.yml`
172
+ - Environment: `rubygems`
173
+ - Workflow repository owner と name: 両方とも空にします(workflow はこのリポジトリにあり、ほかの場所の reusable workflow ではありません)。
174
+
175
+ 最初の push のあと、pending publisher はその gem の trusted publisher になります。
176
+ 3. 最初のバージョンは push ではなく Actions から出します。
177
+ `main` で `release-gem.yml` を実行し、入力 `rubygems-owner` に Pending Trusted Publishers のページに出る数字のアカウント ID を入れます(meganemura は `70209`)。
178
+ RubyGems は、トークンの交換で持ち主のアカウントを名乗ったときだけ新しい gem を作ります。
179
+ 2 つ目からのバージョンは push で出し、入力は要りません。
180
+
181
+ ### gem の各バージョン
182
+
183
+ 1. `ruby/CHANGELOG.md` で、`## [Unreleased]` の下のノートを新しい `## [<version>]` の見出しへ移します。
184
+ 同じバージョンを `ruby/lib/nukadoko/version.rb` に書き、`ruby/` で `bundle install` を実行して `Gemfile.lock` にそのバージョンを載せます。
185
+ 2. 両方を `chore: release the gem <version>` としてコミットし、`queue` を通して `main` に載せます。
186
+ 3. run が求めたら、Environment `rubygems` を承認します。