metanorma-cli 1.16.4 → 1.16.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbf7c76fc0597e5829f5abd6f076334f5cd750fbdecb6b17e98a29ff038e0d6e
4
- data.tar.gz: 40c5b5f7b6bcc3eab6fa010e937cb711e1c92eeee66954497bb7b2aa3ce4b2e8
3
+ metadata.gz: c0a53a754776e569091e1b9311196c7981651098eb6a7c0add1a44d11e93b127
4
+ data.tar.gz: 91c87751dc666c8e691ff14bc9a5251894e5690927dfcddcf102cc2dbaa6aecc
5
5
  SHA512:
6
- metadata.gz: 189f44e361d625494d4169346d3426b22ea95f7b5c2754a2ed746a748fea440c04d562a1d17ca34ead364496d9fcfd5cb3d7edbfe0384db8dbcfe5fb6543c23d
7
- data.tar.gz: e115f84be420250c35811a6a815b22fd2120c5bbe33fb1fee127f252c504d8e1e4ada9d6078e9e37baa304ff921cd6f64d62b07465d567151bc3f6eda599d426
6
+ metadata.gz: c9dcc6876d000cdd70debfe29d24a99d1b4af74e680bd90f372bef6c62ba88fe6863a366ad190cca1a28a8facd94bc25bbf2b4366c8f8099bf9fab744a5810c8
7
+ data.tar.gz: 275d15fe27f5e4b6663dc3aead1b7a767e162430a55b2e1a8692ad7fb1839db7abe60c3fb7fcef5ae1cabbcda700c0d4924e28ee82124c73f6c856020af1de69
data/docs/testing.adoc ADDED
@@ -0,0 +1,379 @@
1
+ = Testing PRs with Gemfile.devel
2
+ :toc:
3
+ :toclevels: 3
4
+
5
+ == Overview
6
+
7
+ The `Gemfile.devel` mechanism allows you to test Pull Requests (PRs) of dependent gems against the full set of document samples and templates in metanorma-cli's CI workflow. This is critical for verifying that infrastructure changes to base gems don't break downstream flavors before releasing them.
8
+
9
+ == The Problem
10
+
11
+ Metanorma's architecture consists of a layered dependency tree of gems:
12
+
13
+ * **Base layer**: `isodoc` provides core document processing
14
+ * **Middle layer**: `metanorma-standoc` builds on isodoc, and flavor gems build on standoc
15
+ * **Top layer**: Specialized flavors that depend on middle-layer flavors
16
+
17
+ When you make a change to a base gem like `isodoc` or `metanorma-standoc`, the gem's own test suite may pass, but the change could break any of the 20+ downstream flavor gems. Without integration testing, these breaks only get discovered after release when users report crashes.
18
+
19
+ == The Solution
20
+
21
+ The CI workflow for metanorma-cli tests against sample documents from all metanorma flavor repositories. By creating a `Gemfile.devel` file in your metanorma-cli PR, you can specify which gem PRs/branches to use during these tests, enabling full integration testing before any releases.
22
+
23
+ == How It Works
24
+
25
+ === Workflow Integration
26
+
27
+ The reusable workflow at `metanorma/ci/.github/workflows/mn-processor-rake.yml` includes special handling for `Gemfile.devel`:
28
+
29
+ 1. When testing samples/templates, the workflow checks out the metanorma-cli repository (with your PR)
30
+ 2. It checks out each sample repository (e.g., `mn-samples-iso`, `mn-samples-ogc`)
31
+ 3. In the sample's directory, it modifies the Gemfile to:
32
+ - Add metanorma-cli from the local path (`../`)
33
+ - Append `eval_gemfile("../Gemfile.devel") rescue nil`
34
+ 4. When `bundle install` runs, it loads your gem overrides from Gemfile.devel
35
+ 5. The tests run using your specified gem versions
36
+
37
+ === Local Gemfile Support
38
+
39
+ The main `Gemfile` in metanorma-cli also loads `Gemfile.devel` if it exists:
40
+
41
+ [source,ruby]
42
+ ----
43
+ begin
44
+ eval_gemfile("Gemfile.devel")
45
+ rescue StandardError
46
+ nil
47
+ end
48
+ ----
49
+
50
+ This means `Gemfile.devel` works both in CI and in local development.
51
+
52
+ == Usage Guide
53
+
54
+ === Basic Workflow
55
+
56
+ 1. **Create your Gemfile.devel**:
57
+ +
58
+ [source,bash]
59
+ ----
60
+ cp Gemfile.devel.example Gemfile.devel
61
+ ----
62
+
63
+ 2. **Edit the file to specify gem overrides**:
64
+ +
65
+ [source,ruby]
66
+ ----
67
+ # Test a PR branch of isodoc
68
+ gem "isodoc", github: "metanorma/isodoc", branch: "feature/svg-conform"
69
+
70
+ # Test main branch of metanorma-standoc
71
+ gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "main"
72
+ ----
73
+
74
+ 3. **Commit and push your PR**:
75
+ +
76
+ [source,bash]
77
+ ----
78
+ git add Gemfile.devel
79
+ git commit -m "Test isodoc PR #123 against samples"
80
+ git push origin your-branch
81
+ ----
82
+
83
+ 4. **Monitor the CI workflow**:
84
+ - The `test-samples` and `test-templates` jobs will use your gem specifications
85
+ - Check the logs to verify the correct gems are being loaded
86
+ - Review any test failures to ensure compatibility
87
+
88
+ === Verifying Gem Loading
89
+
90
+ To confirm that your gem override is being used, you can add diagnostic output to your gem PR. For example, in an isodoc PR:
91
+
92
+ [source,ruby]
93
+ ----
94
+ # In lib/isodoc.rb or similar initialization file
95
+ warn "DEBUG: Loading isodoc from CUSTOM BRANCH for testing"
96
+ ----
97
+
98
+ When the CI runs, this message will appear in the GitHub Actions logs, confirming the override worked.
99
+
100
+ == Dependency Tree Reference
101
+
102
+ Understanding the dependency tree helps you determine which gems need to be overridden:
103
+
104
+ ----
105
+ isodoc (base layer)
106
+ └─ metanorma-standoc
107
+ ├─ metanorma-generic
108
+ │ ├─ metanorma-csa
109
+ │ ├─ metanorma-cc
110
+ │ ├─ metanorma-iho
111
+ │ └─ metanorma-ribose
112
+ ├─ metanorma-iso
113
+ │ ├─ metanorma-jis
114
+ │ ├─ metanorma-iec
115
+ │ └─ metanorma-bsi
116
+ ├─ metanorma-ieee
117
+ ├─ metanorma-itu
118
+ ├─ metanorma-nist
119
+ └─ metanorma-ogc
120
+
121
+ Special cases:
122
+ - metanorma-bipm depends on: isodoc, standoc, generic, AND iso
123
+ - metanorma-plateau depends on: isodoc, standoc, iso, AND jis
124
+ ----
125
+
126
+ == Common Testing Scenarios
127
+
128
+ === Scenario 1: Testing a Base Infrastructure Change
129
+
130
+ You've made a change to `isodoc` that affects all downstream gems:
131
+
132
+ [source,ruby]
133
+ ----
134
+ # Gemfile.devel
135
+ gem "isodoc", github: "metanorma/isodoc", branch: "feature/new-rendering"
136
+ ----
137
+
138
+ This tests your isodoc PR against ALL flavor samples (ISO, ITU, OGC, BSI, etc.).
139
+
140
+ === Scenario 2: Testing Related PRs Together
141
+
142
+ You have PRs in both `isodoc` and `metanorma-standoc` that work together:
143
+
144
+ [source,ruby]
145
+ ----
146
+ # Gemfile.devel
147
+ gem "isodoc", github: "metanorma/isodoc", branch: "feature/base-api"
148
+ gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "feature/use-base-api"
149
+ ----
150
+
151
+ This ensures the two PRs are compatible before merging either.
152
+
153
+ === Scenario 3: Testing a Flavor-Specific Change
154
+
155
+ You're fixing a bug in `metanorma-bsi` that also requires changes to `metanorma-iso`:
156
+
157
+ [source,ruby]
158
+ ----
159
+ # Gemfile.devel
160
+ gem "metanorma-iso", github: "metanorma/metanorma-iso", branch: "fix/bsi-compatibility"
161
+ gem "metanorma-bsi", github: "metanorma/metanorma-bsi", branch: "fix/rendering-issue"
162
+ ----
163
+
164
+ === Scenario 4: Testing Against main Branches (Pre-release Testing)
165
+
166
+ Before releasing `isodoc`, verify that the main branch works with all samples:
167
+
168
+ [source,ruby]
169
+ ----
170
+ # Gemfile.devel
171
+ gem "isodoc", github: "metanorma/isodoc", branch: "main"
172
+ gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "main"
173
+ ----
174
+
175
+ This is the "hotfix test" scenario from issue #370: test unreleased changes across the entire stack.
176
+
177
+ === Scenario 5: Local Development Testing
178
+
179
+ When working across multiple repositories locally:
180
+
181
+ [source,ruby]
182
+ ----
183
+ # Gemfile.devel
184
+ gem "isodoc", path: "../isodoc"
185
+ gem "metanorma-standoc", path: "../metanorma-standoc"
186
+ gem "metanorma-iso", path: "../metanorma-iso"
187
+ ----
188
+
189
+ Run `bundle exec metanorma` locally to test your changes.
190
+
191
+ == Advanced Usage
192
+
193
+ === Testing Specific PR Numbers
194
+
195
+ You can reference pull requests directly using GitHub refs:
196
+
197
+ [source,ruby]
198
+ ----
199
+ # Test PR #123 from metanorma/isodoc
200
+ gem "isodoc", github: "metanorma/isodoc", ref: "refs/pull/123/head"
201
+ ----
202
+
203
+ === Testing Forks
204
+
205
+ If the PR is from a fork:
206
+
207
+ [source,ruby]
208
+ ----
209
+ gem "isodoc", github: "username/isodoc", branch: "feature-name"
210
+ ----
211
+
212
+ === Overriding Private Gems
213
+
214
+ For gems hosted in private repositories (assuming you have access):
215
+
216
+ [source,ruby]
217
+ ----
218
+ gem "metanorma-bsi", github: "metanorma/metanorma-bsi", branch: "private-feature"
219
+ gem "metanorma-nist", github: "metanorma/metanorma-nist", branch: "main"
220
+ ----
221
+
222
+ The CI workflow uses `METANORMA_CI_PAT_TOKEN` for authentication to private repos.
223
+
224
+ == Troubleshooting
225
+
226
+ === Bundle Install Fails
227
+
228
+ **Symptom**: The CI job fails during `bundle install` with dependency resolution errors.
229
+
230
+ **Solutions**:
231
+
232
+ 1. Verify branch names are correct
233
+ 2. Check that the specified branches exist and are accessible
234
+ 3. Ensure gem versions are compatible (check each gem's dependencies)
235
+ 4. Try running `bundle install` locally with the same Gemfile.devel
236
+
237
+ === Gems Aren't Being Overridden
238
+
239
+ **Symptom**: Tests run but appear to use released gem versions instead of your PR.
240
+
241
+ **Solutions**:
242
+
243
+ 1. Add diagnostic `warn` statements to your gem PR to confirm loading
244
+ 2. Check the CI logs for the `bundle install` output to see which gems were installed
245
+ 3. Verify the Gemfile.devel syntax is correct
246
+ 4. Ensure the file is committed to your PR branch
247
+
248
+ === Tests Fail Unexpectedly
249
+
250
+ **Symptom**: Sample compilation fails with errors that don't appear in the gem's own tests.
251
+
252
+ **This is the desired behavior!** The purpose of this mechanism is to catch integration issues.
253
+
254
+ **Next Steps**:
255
+
256
+ 1. Download the error logs artifact from the GitHub Actions run
257
+ 2. Identify which sample(s) are failing
258
+ 3. Check if the failure is due to:
259
+ - An incompatible change in your PR (fix the PR)
260
+ - A bug in the sample document (fix the sample)
261
+ - A known limitation (document it)
262
+ 4. Consider whether your change needs coordination with other gem updates
263
+
264
+ === Private Repository Access
265
+
266
+ **Symptom**: Can't access private sample repositories or gems.
267
+
268
+ **Solutions**:
269
+
270
+ 1. Ensure you have the appropriate GitHub permissions
271
+ 2. For local testing, set up GitHub CLI authentication: `gh auth login`
272
+ 3. For CI, the workflow uses the `METANORMA_CI_PAT_TOKEN` secret automatically
273
+
274
+ == Best Practices
275
+
276
+ === 1. Test Before Releasing Infrastructure Changes
277
+
278
+ Always create a Gemfile.devel test before releasing changes to:
279
+
280
+ * `isodoc`
281
+ * `metanorma-standoc`
282
+ * `metanorma-generic`
283
+ * `metanorma-iso`
284
+
285
+ These gems affect many downstream dependencies.
286
+
287
+ === 2. Test the Full Chain for Related PRs
288
+
289
+ If you have PRs across multiple gems that work together, test them all simultaneously using Gemfile.devel before merging any of them.
290
+
291
+ === 3. Add Diagnostic Output During Testing
292
+
293
+ Temporarily add `warn` statements to confirm gem loading:
294
+
295
+ [source,ruby]
296
+ ----
297
+ warn "DEBUG: isodoc #{Isodoc::VERSION} from PR #123"
298
+ ----
299
+
300
+ Remove these before final merge.
301
+
302
+ === 4. Keep Gemfile.devel Out of Main Branch
303
+
304
+ The `Gemfile.devel` file should only exist in feature branches for testing. Never commit it to `main` or `master`. (It's git-ignored, but be careful if you override this.)
305
+
306
+ === 5. Document Breaking Changes
307
+
308
+ If your test reveals that a change will break compatibility, document this clearly in:
309
+
310
+ * The PR description
311
+ * The gem's CHANGELOG
312
+ * Any related issue discussions
313
+
314
+ === 6. Coordinate Release Timing
315
+
316
+ When multiple PRs need to be released together:
317
+
318
+ 1. Test all PRs together with Gemfile.devel
319
+ 2. Merge all PRs to their respective main branches
320
+ 3. Release gems in dependency order (base to top layer)
321
+ 4. Update dependent gems immediately after base releases
322
+
323
+ == Git Configuration
324
+
325
+ The `.gitignore` file includes:
326
+
327
+ ----
328
+ /Gemfile.devel
329
+ ----
330
+
331
+ This prevents accidental commits of `Gemfile.devel` to the main branch. The `.example` file is tracked to serve as documentation and a template.
332
+
333
+ == Examples from Real Scenarios
334
+
335
+ === Example 1: svg_conform Integration Testing
336
+
337
+ When `svg_conform` was added to the Metanorma stack, it should have been tested with Gemfile.devel:
338
+
339
+ [source,ruby]
340
+ ----
341
+ # Gemfile.devel
342
+ gem "isodoc", github: "metanorma/isodoc", branch: "feature/svg-conform"
343
+ gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "feature/svg-conform"
344
+ ----
345
+
346
+ This would have caught compatibility issues across all samples before release.
347
+
348
+ === Example 2: Fontist Performance Testing
349
+
350
+ Before releasing a Fontist upgrade:
351
+
352
+ [source,ruby]
353
+ ----
354
+ # Gemfile.devel
355
+ gem "isodoc", github: "metanorma/isodoc", branch: "main"
356
+ gem "fontist", github: "fontist/fontist", branch: "performance-improvements"
357
+ ----
358
+
359
+ Performance impacts could be measured across the full sample set.
360
+
361
+ === Example 3: BSI Private Font Testing
362
+
363
+ Testing BSI-specific changes with private fonts:
364
+
365
+ [source,ruby]
366
+ ----
367
+ # Gemfile.devel
368
+ gem "metanorma-iso", github: "metanorma/metanorma-iso", branch: "main"
369
+ gem "metanorma-bsi", github: "metanorma/metanorma-bsi", branch: "fix/font-handling"
370
+ ----
371
+
372
+ The CI automatically sets up private fonts for BSI samples.
373
+
374
+ == See Also
375
+
376
+ * link:https://github.com/metanorma/metanorma-cli/issues/370[Issue #370: Hotfix test job]
377
+ * link:https://github.com/metanorma/ci[metanorma/ci repository] - Shared CI workflows
378
+ * `Gemfile.devel.example` - Template with examples
379
+ * `.github/workflows/rake.yml` - Local workflow configuration