You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/02-developer-guide.adoc
+59-28Lines changed: 59 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Automated testing is setup using GraalVM v21 JDK11.
20
20
* NodeJs v12 or above
21
21
* Clojure v1.10.1.697 or above for `clojure` command
22
22
** Note that rewrite-clj v1 itself supports Clojure v1.9 and above
23
-
* Babashka v0.3.2 or above
23
+
* Babashka v0.3.7 or above
24
24
* GraalVM v21.1.0 JDK 11 (if you want to run GraalVM native image tests)
25
25
26
26
=== Windows Notes
@@ -77,9 +77,30 @@ npm install
77
77
3. Initialize cache for clj-kondo so it can lint against your dependencies
78
78
+
79
79
----
80
-
bb ./script/lint.clj
80
+
bb lint
81
81
----
82
82
83
+
== Babashka Tasks
84
+
85
+
We make use of babashka tasks for development related commands.
86
+
87
+
To see all available tasks with a short description run:
88
+
----
89
+
bb tasks
90
+
----
91
+
92
+
To run a task, for example, the `lint` task:
93
+
----
94
+
bb lint
95
+
----
96
+
97
+
Usage help for a task is requested via `--help`, for example:
98
+
----
99
+
bb lint --help
100
+
----
101
+
102
+
Tasks are described throughout this document.
103
+
83
104
== Code Generation
84
105
Rewrite-clj v0 used a version of potemkin import-vars.
85
106
Potemkin import-vars copies specified vars from a specified namespace to the current namespace at load time.
@@ -121,15 +142,15 @@ At this time, we don't handle destructuring in arglists, and will throw unless a
121
142
To generate target source from templates run:
122
143
[source,shell]
123
144
----
124
-
bb script/apply_import_vars.clj gen-code
145
+
bb apply-import-vars gen-code
125
146
----
126
147
You are expected to review the generated changes and commit the generated source to version control.
127
148
We don't link:#linting[lint] templates, but we do lint the generated code.
128
149
129
150
To perform a read-only check, run:
130
151
[source,shell]
131
152
----
132
-
bb script/apply_import_vars.clj check
153
+
bb apply-import-vars check
133
154
----
134
155
The check command will exit with 0 if no changes are required, otherwise it will exit with 1.
135
156
Our build script will run the check command and fail the build if there are any pending changes that have not been applied.
@@ -141,7 +162,7 @@ Your personal preference will likely be different, but during maintenance and re
141
162
For Clojure, I open a shell terminal window and run:
142
163
143
164
----
144
-
bb ./script/clj_watch.clj
165
+
bb test-clj-watch
145
166
----
146
167
147
168
This launches https://github.com/lambdaisland/kaocha[kaocha] in watch mode.
@@ -150,7 +171,7 @@ This launches https://github.com/lambdaisland/kaocha[kaocha] in watch mode.
150
171
For ClojureScript, I open a shell terminal window and run:
151
172
152
173
----
153
-
bb ./script/cljs_watch.clj
174
+
bb test-cljs-watch
154
175
----
155
176
156
177
This launches https://figwheel.org/[fighweel main].
@@ -169,7 +190,7 @@ At the time of this writing draw.io does not remember export settings, so you'll
169
190
We use https://github.com/lread/test-doc-blocks[test-doc-blocks] to verify that code blocks in our documentation are in good working order.
170
191
171
192
----
172
-
bb ./script/doc_tests.clj
193
+
bb test-doc
173
194
----
174
195
175
196
This generates tests for doc code blocks and then runs them under Clojure and ClojureScript.
@@ -180,7 +201,7 @@ Before pushing, you likely want to mimic what is run on each push via GitHub Act
180
201
=== Unit tests
181
202
Unit tests are run via:
182
203
----
183
-
bb ./script/ci_tests.clj
204
+
bb ci-unit-tests
184
205
----
185
206
186
207
=== Native image tests
@@ -189,45 +210,49 @@ We also verify that rewrite-clj functions as expected when compiled via Graal's
189
210
1. Tests and library natively compiled:
190
211
+
191
212
----
192
-
bb ./script/pure_native_test.clj
213
+
bb test-native
193
214
----
194
215
2. Library natively compiled and tests interpreted via sci
195
216
+
196
217
----
197
-
bb ./script/sci_native_test.clj
218
+
bb test-native-sci
198
219
----
199
220
200
221
[#libs-test]
201
222
=== Libs test
202
223
To try to ensure our changes to rewrite-clj do not inadvertently break existing popular libraries, we run their tests, or a portion thereof, against rewrite-clj.
203
-
204
224
----
205
-
bb ./script/libs_tests.clj run
225
+
bb test-libs run
206
226
----
207
227
208
228
See link:../README.adoc#used-in[README] for current libs we test against.
209
229
210
230
Additional libs are welcome.
211
231
232
+
To see a list of available libs we currently test against:
233
+
----
234
+
bb test-libs list
235
+
----
236
+
212
237
If you are troubleshooting locally, and want to only run specific tests, you can specify which ones you'd like to run.
213
238
For example:
214
239
215
240
----
216
-
bb ./script/libs_tests.clj run cljfmt zprint
241
+
bb test-libs run cljfmt zprint
217
242
----
218
243
219
-
Running current versions of libs is recommended, but care must be taken when updating.
244
+
Updating the test-libs script to run against current versions of libs is recommended, but care must be taken when updating.
220
245
We want to make sure we are patching correctly to use rewrite-clj v1 and running a lib's tests as intended.
221
246
222
247
To check for outdated libs:
223
248
224
249
----
225
-
bb ./script/libs_test.clj outdated
250
+
bb test-libs outdated
226
251
----
227
252
228
253
Notes:
229
254
230
-
* `libs_tests.clj` was developed on macOS and is run on CI under Linux only under JDK 11 only.
255
+
* The `test-libs` task was developed on macOS and is run on CI under Linux only under JDK 11 only.
231
256
We can expand variations at some later date if there is any value to it.
232
257
* We test the current HEAD of rewrite-clj v1 against specific versions (latest at the time of this writing) of libs.
233
258
* We patch lib deps and sometimes code (ex. `require` for `rewrite-cljc` becomes `rewrite-clj`).
@@ -238,7 +263,7 @@ We can expand variations at some later date if there is any value to it.
238
263
239
264
To see what new dependencies are available, run:
240
265
----
241
-
bb ./script/outdated.clj
266
+
bb outdated
242
267
----
243
268
244
269
We use https://github.com/liquidz/antq[antq] which also checks `pom.xml`.
@@ -258,12 +283,12 @@ We use https://github.com/borkdude/clj-kondo[clj-kondo] for linting rewrite-clj
258
283
We fail the build on any lint violations.
259
284
The CI server runs:
260
285
----
261
-
bb ./script/lint.clj
286
+
bb lint
262
287
----
263
288
and you can too. The lint script will build the clj-kondo cache when it is missing or stale.
264
289
If you want to force a rebuild of the cache run:
265
290
----
266
-
bb ./script/lint.clj --rebuild-cache
291
+
bb lint --rebuild-cache
267
292
----
268
293
269
294
https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md[Integrate clj-kondo into your editor] to catch mistakes as they happen.
@@ -275,9 +300,11 @@ To generate reports on differences between rewrite-clj v0, rewrite-cljs and
275
300
rewrite-clj v1 APIs, run:
276
301
277
302
----
278
-
bb ./script/gen_api_diffs.clj
303
+
bb doc-api-diffs
279
304
----
280
305
306
+
WARNING: This task currently needs love, see https://github.com/clj-commons/rewrite-clj/issues/132[#132].
307
+
281
308
Run this script manually on an as-needed basis, and certainly before any official release.
282
309
Generated reports are to be checked in to version control.
283
310
@@ -294,7 +321,7 @@ Before a release, it can be comforting to preview what docs will look like on ht
294
321
295
322
Limitations
296
323
297
-
* This script should be considered experimental, I have only tested running on macOS, but am fairly confident it will work on Linux.
324
+
* This task should be considered experimental, I have only tested running on macOS, but am fairly confident it will work on Linux.
298
325
Not sure about Windows at this time.
299
326
* You have to push your changes to GitHub to preview them.
300
327
This allows for a full preview that includes any links (source, images, etc) to GitHub.
@@ -304,7 +331,7 @@ This works fine from branches and forks - in case you don't want to affect your
304
331
305
332
To start the local cljdoc docker container:
306
333
----
307
-
bb ./script/cljdoc_preview.clj start
334
+
bb cljdoc-preview start
308
335
----
309
336
310
337
The local cljdoc server allows your ingested docs to be viewed in your web browser.
@@ -315,7 +342,7 @@ The start command also automatically checks docker hub for any updates so that o
315
342
316
343
To ingest rewrite-clj API and docs into the local cljdoc database:
317
344
----
318
-
bb ./script/cljdoc_preview.clj ingest
345
+
bb cljdoc-preview ingest
319
346
----
320
347
321
348
The ingest command automatically publishes rewrite-clj to your local maven repository (cljdoc only works with published jars).
@@ -327,7 +354,7 @@ Repeat these steps any time you want to preview changes.
327
354
328
355
To open a view to the ingested docs in your default web browser:
329
356
----
330
-
bb ./script/cljdoc_preview.clj view
357
+
bb cljdoc-preview view
331
358
----
332
359
333
360
If you have just run the start command, be a bit patient, the cljdoc server can take a few moments to start up - especially on macOS due to poor file sharing performance.
@@ -336,7 +363,7 @@ If you have just run the start command, be a bit patient, the cljdoc server can
336
363
337
364
When you are done, you'll want to stop your docker container:
338
365
----
339
-
bb ./script/cljdoc_preview.clj stop
366
+
bb cljdoc-preview stop
340
367
----
341
368
342
369
This will also delete temporary files created to support your preview session, most notably the local cljdoc database.
@@ -347,12 +374,16 @@ Note that NO cleanup is done for any rewrite-clj artifacts published to your loc
347
374
348
375
If you forget where you are at with your docker containers, run:
349
376
----
350
-
bb ./script/cljdoc_preview.clj status
377
+
bb cljdoc-preview status
351
378
----
352
379
353
380
== Code Coverage
354
381
355
-
We use https://github.com/cloverage/cloverage[cloverage] via https://github.com/lambdaisland/kaocha[kaocha] to generate code coverage reports.
382
+
We use https://github.com/cloverage/cloverage[cloverage] via https://github.com/lambdaisland/kaocha[kaocha] to generate code coverage reports via:
383
+
----
384
+
bb test-coverage
385
+
----
386
+
356
387
Our CI service is setup to automatically generate then upload reports to https://codecov.io[CodeCov].
357
388
358
389
We have no specific goals for code coverage, but new code is generally expected to have tests.
@@ -365,5 +396,5 @@ We honor current and past contributors to rewrite-clj in our README file.
365
396
To update contributors, update `doc/contributors.edn` then run:
0 commit comments