@appland/appmap 3.146.0 → 3.147.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 (62) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/built/docs/CLA Instructions.pdf +0 -0
  3. package/built/docs/Code of Conduct for Contributors.pdf +0 -0
  4. package/built/docs/analysis/rules-reference.html +27 -0
  5. package/built/docs/appmap-docs.md +27 -0
  6. package/built/docs/community.md +28 -0
  7. package/built/docs/guides/exporting-appmap-diagrams.md +50 -0
  8. package/built/docs/guides/handling-large-appmap-diagrams.md +138 -0
  9. package/built/docs/guides/index.md +21 -0
  10. package/built/docs/guides/navigating-code-objects.md +67 -0
  11. package/built/docs/guides/openapi.md +105 -0
  12. package/built/docs/guides/reading-sql-in-appmap-diagrams.md +69 -0
  13. package/built/docs/guides/refine-appmap-data.md +186 -0
  14. package/built/docs/guides/reverse-engineering.md +377 -0
  15. package/built/docs/guides/runtime-code-review.md +111 -0
  16. package/built/docs/guides/using-appmap-analysis.md +206 -0
  17. package/built/docs/guides/using-appmap-diagrams.md +331 -0
  18. package/built/docs/integrations/atlassian-compass.md +25 -0
  19. package/built/docs/integrations/atlassian-confluence.md +51 -0
  20. package/built/docs/integrations/circle-ci.md +424 -0
  21. package/built/docs/integrations/docker.md +109 -0
  22. package/built/docs/integrations/github-actions.md +524 -0
  23. package/built/docs/integrations/index.md +20 -0
  24. package/built/docs/integrations/plantuml.md +66 -0
  25. package/built/docs/integrations/postman.md +30 -0
  26. package/built/docs/integrations/readme.md +39 -0
  27. package/built/docs/integrations/smartbear-swaggerhub.md +119 -0
  28. package/built/docs/reference/analysis-labels.md +49 -0
  29. package/built/docs/reference/analysis-rules.md +61 -0
  30. package/built/docs/reference/appmap-client-cli.md +628 -0
  31. package/built/docs/reference/appmap-gradle-plugin.md +141 -0
  32. package/built/docs/reference/appmap-java.md +311 -0
  33. package/built/docs/reference/appmap-maven-plugin.md +164 -0
  34. package/built/docs/reference/appmap-node.md +185 -0
  35. package/built/docs/reference/appmap-python.md +520 -0
  36. package/built/docs/reference/appmap-ruby.md +514 -0
  37. package/built/docs/reference/github-action.md +171 -0
  38. package/built/docs/reference/index.md +25 -0
  39. package/built/docs/reference/jetbrains.md +136 -0
  40. package/built/docs/reference/license-key-install.md +74 -0
  41. package/built/docs/reference/navie.md +261 -0
  42. package/built/docs/reference/remote-recording-api.md +97 -0
  43. package/built/docs/reference/uninstalling-appmap.md +119 -0
  44. package/built/docs/reference/vscode.md +122 -0
  45. package/built/docs/setup-appmap-in-ci/example-projects.md +21 -0
  46. package/built/docs/setup-appmap-in-ci/how-it-works.md +43 -0
  47. package/built/docs/setup-appmap-in-ci/in-circleci.md +423 -0
  48. package/built/docs/setup-appmap-in-ci/in-github-actions.md +177 -0
  49. package/built/docs/setup-appmap-in-ci/index.md +22 -0
  50. package/built/docs/setup-appmap-in-ci/matrix-builds.md +225 -0
  51. package/built/docs/setup-appmap-in-ci/troubleshooting.md +71 -0
  52. package/built/docs/setup-appmap-in-your-code-editor/add-appmap-to-your-code-editor.md +93 -0
  53. package/built/docs/setup-appmap-in-your-code-editor/appmap-analysis.md +77 -0
  54. package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-from-tests.md +93 -0
  55. package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-with-remote-recording.md +112 -0
  56. package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-with-request-recording.md +77 -0
  57. package/built/docs/setup-appmap-in-your-code-editor/how-appmap-works.md +166 -0
  58. package/built/docs/setup-appmap-in-your-code-editor/index.md +25 -0
  59. package/built/docs/setup-appmap-in-your-code-editor/navigating-appmap-diagrams.md +59 -0
  60. package/built/docs/setup-appmap-in-your-code-editor/navigating-code-objects.md +67 -0
  61. package/built/docs/unused_for_now_index.html +11 -0
  62. package/package.json +2 -2
@@ -0,0 +1,514 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ description: "AppMap reference guide for Ruby. Record AppMap Data easily for improved code visibility and analysis."
5
+ toc: true
6
+ reference: true
7
+ name: AppMap Agent for Ruby
8
+ step: 4
9
+ ---
10
+
11
+ # AppMap Agent for Ruby <!-- omit in toc -->
12
+
13
+ - [About](#about)
14
+ - [Supported versions](#supported-versions)
15
+ - [Installation](#installation)
16
+ - [Configuration](#configuration)
17
+ - [Events that are always recorded](#events-that-are-always-recorded)
18
+ - [Labels](#labels)
19
+ - [Tests recording](#tests-recording)
20
+ - [RSpec](#rspec)
21
+ - [Minitest](#minitest)
22
+ - [Cucumber](#cucumber)
23
+ - [Requests recording](#requests-recording)
24
+ - [Requests recording in Rails](#requests-recording-in-rails)
25
+ - [Requests recording in non-Rails apps](#requests-recording-in-non-rails-apps)
26
+ - [Remote recording](#remote-recording)
27
+ - [Remote recording in Rails](#remote-recording-in-rails)
28
+ - [Remote recording in non-Rails apps](#remote-recording-in-non-rails-apps)
29
+ - [Code Block Recording](#code-block-recording)
30
+ - [Enable and disable AppMap Data creation](#enable-and-disable-appmap-data-creation)
31
+ - [Disabling AppMap Data creation using environment variables](#disabling-appmap-data-creation-using-environment-variables)
32
+ - [Disabling AppMap Data creation for specific RSpec tests](#disabling-appmap-data-creation-for-specific-rspec-tests)
33
+ - [Enabling and disabling instrumentation](#enabling-and-disabling-instrumentation)
34
+ - [Advanced runtime options](#advanced-runtime-options)
35
+ - [GitHub repository](#github-repository)
36
+
37
+ ## About
38
+
39
+ `appmap` is a Gem for recording [AppMap Data](https://github.com/getappmap/appmap) of your code.
40
+
41
+ {% include docs/what_is_appmap_snippet.md %}
42
+
43
+ ### Supported versions
44
+
45
+ {% include docs/ruby_support_matrix.html %}
46
+
47
+ Support for new versions is added frequently, please check back regularly for updates.
48
+
49
+ ## Installation
50
+
51
+ Add `gem 'appmap'` to the **beginning** of your Gemfile. It needs to be the *first gem* in the list, so that it can observe other gems loading and instrument them if you request it. Also, we recommend you add the `appmap` gem to the `:development, :test` group.
52
+
53
+ Your Gemfile should look something like this:
54
+
55
+ ```
56
+ source 'https://rubygems.org'
57
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
58
+
59
+ # Optional Ruby version
60
+ # ruby '2.7.2'
61
+
62
+ # The appmap gem is the first gem in the file
63
+ group :development, :test do
64
+ gem 'appmap'
65
+ end
66
+
67
+ # The rest of the gems follow
68
+ gem 'rails', '6.1.0'
69
+ ```
70
+
71
+ Install with `bundle install`, as usual.
72
+
73
+ {% include docs/install_appmap_extension.md %}
74
+
75
+ ## Configuration
76
+
77
+ When you run your program, the `appmap` gem reads configuration settings from _appmap.yml_. Here's an extensive example file for a Rails project:
78
+
79
+ ```
80
+ # 'name' should generally be the same as the code repo name.
81
+ name: my_project
82
+ packages:
83
+ - path: app
84
+ # Exclude sub-paths within the package path
85
+ exclude:
86
+ - concerns/accessor
87
+ - path :lib
88
+ # Include any gems that you want to record.
89
+ # These are just examples.
90
+ - gem: activerecord
91
+ - gem: aws-sdk
92
+ # Exclude a specific class or function from the map.
93
+ exclude:
94
+ - MyClass
95
+ - MyClass#my_instance_method
96
+ - MyClass.my_class_method
97
+ # Apply custom labels to gem code.
98
+ # (Use source annotations to label your own code).
99
+ functions:
100
+ - methods:
101
+ - Fluent::Logger::FluentLogger#post
102
+ - Fluent::Logger::FluentLogger#post_with_time
103
+ - Fluent::Logger.post
104
+ - Fluent::Logger.post_with_time
105
+ label: log
106
+ ```
107
+
108
+ * **name** Provides the project name (required)
109
+ * **packages** A list of source code directories which should be recorded.
110
+ * **exclude** A list of classes and/or methods to definitively exclude from recording.
111
+ * **functions** A list of specific functions, scoped by gem or path and fully qualified method name, to record.
112
+
113
+ **packages**
114
+
115
+ Each entry in the `packages` list is a YAML object which has the following keys:
116
+
117
+ * **path** The path to the source code directory. The path may be relative to the current working directory, or it may
118
+ be an absolute path.
119
+ * **gem** As an alternative to specifying the path, specify the name of a dependency gem. When using `gem`, don't specify `path`. In your `Gemfile`, the `appmap` gem **must** be listed **before** any gem that you specify in your _appmap.yml_.
120
+ * **exclude** A list of files and directories which will be ignored. By default, all modules, classes and public
121
+ functions are inspected. See also: global `exclude` list.
122
+ * **shallow** When set to `true`, only the first function call entry into a package will be recorded. Subsequent function calls within
123
+ the same package are not recorded unless code execution leaves the package and re-enters it. Default: `true` when using `gem`,
124
+ `false` when using `path`.
125
+
126
+ **exclude**
127
+
128
+ Optional list of fully qualified class and method names. Separate class and method names with period (`.`) for class methods and hash (`#`) for instance methods.
129
+
130
+ **functions**
131
+
132
+ Optional list of fully qualified `Class#instance_method` or `Class.class_method` method names. The primary use of `functions` is to apply specific labels to functions whose source code is not accessible (e.g., it's in a Gem).
133
+
134
+ - The `gem` or `path` name needs to match the actual location of the method(s)
135
+ - You can specify an individual `method` or multiple `methods` and a single `label` or multiple `labels`.
136
+
137
+ For functions which are part of the application code, use `@label` or `@labels` in code comments to apply labels.
138
+
139
+ ### Events that are always recorded
140
+
141
+ Certain events are always recorded whenever AppMap recording is enabled. These events are:
142
+
143
+ * HTTP server requests that are handled by Rails.
144
+ * SQL queries that sent to the `ActiveSupport::Notifications` handler `sql.sequel`.
145
+ * SQL queries that sent to the `ActiveSupport::Notifications` handler `sql.active_record`.
146
+ * Specific functions that are identified and labeled by [lib/appmap/builtin_hooks](https://github.com/getappmap/appmap-ruby/tree/master/lib/appmap/builtin_hooks) and [lib/appmap/gem_hooks](https://github.com/getappmap/appmap-ruby/tree/master/lib/appmap/gem_hooks).
147
+
148
+ So, even if your _appmap.yml_ is empty except for a `name` and `packages: []`, your AppMap Data will still contain the events listed above.
149
+
150
+ ## Labels
151
+
152
+ The AppMap Data specification provides for class and function `labels`, which can be used to enhance the AppMap Diagrams, and for code analysis.
153
+
154
+ You can apply function labels using source code comments in your Ruby code. To apply a labels to a function, add a `@label` or `@labels` line to the comment which immediately precedes a function.
155
+
156
+ For example, if you add this comment to your source code:
157
+
158
+ ```ruby
159
+ class ApiKey
160
+ # @labels provider.authentication security
161
+ def authenticate(key)
162
+ # logic to verify the key here...
163
+ end
164
+ end
165
+ ```
166
+ {: .example-code}
167
+
168
+ Then the AppMap metadata section for this function will include:
169
+
170
+ ```
171
+ {
172
+ "name": "authenticate",
173
+ "type": "function",
174
+ "labels": [ "provider.authentication", "security" ]
175
+ }
176
+ ```
177
+ ## Tests recording
178
+
179
+ ### RSpec
180
+
181
+ When you run your RSpec tests, AppMap Data will be recorded automatically (as long as the `appmap` gem is loaded).
182
+
183
+ If you **don't see this working automatically** for some reason, you can try requiring `appmap/rspec` in your `spec_helper.rb`:
184
+
185
+ ```ruby
186
+ require 'appmap/rspec'
187
+ ```
188
+ {: .example-code}
189
+
190
+ Note that `spec_helper.rb` in a Rails project typically loads the application's classes this way:
191
+
192
+ ```ruby
193
+ require File.expand_path("../../config/environment", __FILE__)
194
+ ```
195
+ {: .example-code}
196
+
197
+ and `appmap/rspec` should be required before this:
198
+
199
+ ```ruby
200
+ require 'appmap/rspec'
201
+ require File.expand_path("../../config/environment", __FILE__)
202
+ ```
203
+ {: .example-code}
204
+
205
+ &nbsp;
206
+
207
+ Run the tests:
208
+
209
+ ```
210
+ $ bundle exec rspec
211
+ ```
212
+ {: .example-code}
213
+
214
+ Each RSpec test will output an AppMap file into the directory `tmp/appmap/rspec`. For example:
215
+
216
+ ```
217
+ $ find tmp/appmap/rspec
218
+ Hello_says_hello_when_prompted.appmap.json
219
+ ```
220
+
221
+ You can disable AppMap recording for specific tests and examples groups using the tag `appmap: false`. See the section on [enable and disable AppMap Data creation](#enable-and-disable-appmap-data-creation).
222
+
223
+ ### Minitest
224
+
225
+ When you run your Minitest tests, AppMap Data will be recorded automatically (as long as the `appmap` gem is loaded).
226
+
227
+ If you **don't see this working automatically** for some reason, you can try requiring `appmap/minitest` in your `test_helper.rb`:
228
+
229
+ ```ruby
230
+ require 'appmap/minitest'
231
+ ```
232
+ {: .example-code}
233
+
234
+ Note that `test_helper.rb` in a Rails project typically loads the application's classes this way:
235
+
236
+ ```ruby
237
+ require_relative '../config/environment'
238
+ ```
239
+ {: .example-code}
240
+
241
+ and `appmap/minitest` must be required before this:
242
+
243
+ ```ruby
244
+ require 'appmap/minitest'
245
+ require_relative '../config/environment'
246
+ ```
247
+ {: .example-code}
248
+ &nbsp;
249
+
250
+ Run your tests as you normally would. For example:
251
+
252
+ ```
253
+ $ rails test
254
+ ```
255
+ {: .example-code}
256
+
257
+ or
258
+
259
+ ```
260
+ $ bundle exec rake test
261
+ ```
262
+ {: .example-code}
263
+
264
+ Each Minitest test will output an AppMap file into the directory `tmp/appmap/minitest`. For example:
265
+
266
+ ```
267
+ $ find tmp/appmap/minitest
268
+ Hello_says_hello_when_prompted.appmap.json
269
+ ```
270
+
271
+ ### Cucumber
272
+
273
+ To record Cucumber tests, follow these additional steps:
274
+
275
+ 1) Require `appmap/cucumber` in `support/env.rb`:
276
+
277
+ ```ruby
278
+ require 'appmap/cucumber'
279
+ ```
280
+ {: .example-code}
281
+
282
+ Be sure to require it before `config/environment` is required.
283
+
284
+ 2) Create an `Around` hook in `support/hooks.rb` to record the scenario:
285
+
286
+
287
+ ```ruby
288
+ if AppMap::Cucumber.enabled?
289
+ Around('not @appmap-disable') do |scenario, block|
290
+ appmap = AppMap.record do
291
+ block.call
292
+ end
293
+
294
+ AppMap::Cucumber.write_scenario(scenario, appmap)
295
+ end
296
+ end
297
+ ```
298
+ {: .example-code}
299
+
300
+ 3) Run the tests:
301
+
302
+ ```
303
+ $ bundle exec cucumber
304
+ ```
305
+ {: .example-code}
306
+
307
+ Each Cucumber test will output an AppMap file into the directory `tmp/appmap/cucumber`. For example:
308
+
309
+ ```
310
+ $ find tmp/appmap/cucumber
311
+ Hello_Says_hello_when_prompted.appmap.json
312
+ ```
313
+
314
+ ## Requests recording
315
+
316
+ `appmap-ruby` can automatically record and save an AppMap for each HTTP server request.
317
+ To do this, the AppMap agent hooks into the Rack middleware. It starts a recording when each new request is received,
318
+ records the execution thread into an AppMap, and saves in when the request is completed.
319
+
320
+ Requests recording is enabled by default when `RAILS_ENV=development`. You can enable it in any environment by setting `APPMAP_RECORD_REQUESTS=true`, and disable it for every environment by setting `APPMAP_RECORD_REQUESTS=false`.
321
+
322
+ ### Requests recording in Rails
323
+
324
+ The `appmap` middleware is injected automatically into the middleware stack of your Rails app by the AppMap Railtie.
325
+ To view the middleware stack of your app, and confirm that the AppMap middleware is configured and available,
326
+ run:
327
+
328
+ ```
329
+ rake middleware
330
+ ```
331
+ {: .example-code}
332
+
333
+ Start your Rails server in the normal way:
334
+
335
+ ```
336
+ $ rails server
337
+ ```
338
+ {: .example-code}
339
+
340
+ If you don't see a message indicating that "requests" recording is enabled, start the server with `APPMAP_RECORD_REQUESTS=true`, or ensure that `RAILS_ENV=development`.
341
+
342
+ ### Requests recording in non-Rails apps
343
+
344
+ For non-Rails apps, add the AppMap middleware using the method provided by the framework you're using. Run your application server in the usual way. If you don't see a message indicating that "requests" recording is enabled, start the server with `APPMAP_RECORD_REQUESTS=true`, or ensure that `APP_ENV=development`.
345
+
346
+ ## Remote recording
347
+
348
+ `appmap-ruby` supports the [AppMap remote recording API](./remote-recording-api). This functionality is provided by a Rack middleware.
349
+
350
+ Remote recording is enabled automatically when `Rails.env == 'development'` or `ENV['APP_ENV'] == 'development`. To enable remote recording in any other environment,
351
+ set `APPMAP_RECORD_REMOTE=true`.
352
+
353
+ To make a remote recording, follow the [Remote recording documentation](/docs/recording-methods.html#remote-recording).
354
+
355
+ ### Remote recording in Rails
356
+
357
+ The `appmap` middleware is injected automatically into the middleware stack of your Rails app by the AppMap Railtie.
358
+ To view the middleware stack of your app, and confirm that the AppMap middleware is configured and available,
359
+ run:
360
+
361
+ ```
362
+ rake middleware
363
+ ```
364
+ {: .example-code}
365
+
366
+ Start your Rails server in the normal way:
367
+
368
+ ```
369
+ $ rails server
370
+ ```
371
+ {: .example-code}
372
+
373
+ If you don't see a message indicating that "remote" recording is enabled, start the server with `APPMAP_RECORD_REMOTE=true`, or ensure that `RAILS_ENV=development`.
374
+
375
+ ### Remote recording in non-Rails apps
376
+
377
+ For non-Rails apps, add the AppMap middleware using the method provided by the framework you're using. Run your application server in the usual way.
378
+ If you don't see a message indicating that "remote" recording is enabled, start the server with `APPMAP_RECORD_REMOTE=true`, or ensure that `APP_ENV=development`.
379
+
380
+ ## Code Block Recording
381
+
382
+ You can use `AppMap.record` record a specific block of code. With this method, you can control exactly
383
+ what code is recorded, and where the recording is saved.
384
+
385
+ An [example program](https://github.com/getappmap/land-of-applets/blob/b9b3063e4356802c51dd4fbc7ac64a925f0ba577/how-to-properly-close-a-netssh-connection_62643718/main.rb#L38) contains the following code, which should be illustrative of the method:
386
+
387
+ ```ruby
388
+ require 'appmap'
389
+
390
+ # ... some other code
391
+
392
+ FileUtils.mkdir_p 'tmp/appmap/block'
393
+ appmap = AppMap.record do
394
+ demo.call
395
+ end
396
+
397
+ File.write('tmp/appmap/block/demo.appmap.json', JSON.generate(appmap))
398
+ ```
399
+ {: .example-code}
400
+
401
+ ## Enable and disable AppMap Data creation
402
+
403
+ ### Disabling AppMap Data creation using environment variables
404
+
405
+ To disable all AppMap recording, set the environment variable `APPMAP=false`.
406
+
407
+ To disable requests recording, set the environment variable `APPMAP_RECORD_REQUESTS=false`.
408
+
409
+ To disable remote recording, set the environment variable `APPMAP_RECORD_REMOTE=false`.
410
+
411
+ ### Disabling AppMap Data creation for specific RSpec tests
412
+
413
+ To disable recording of an RSpec test or example group, use the tag `appmap: false`.
414
+
415
+ For example:
416
+
417
+ ```ruby
418
+ describe 'Module 1', appmap: false do
419
+ # AppMap Data is disabled for all tests in this scope.
420
+ it 'does something'
421
+ it 'does something else'
422
+ end
423
+
424
+ describe 'Module 2' do
425
+ it 'does something', appmap: false do
426
+ # AppMap is disabled for this test.
427
+ end
428
+ it 'does something else' do
429
+ # AppMap is enabled for this test.
430
+ end
431
+ end
432
+ ```
433
+ {: .example-code}
434
+
435
+ ## Enabling and disabling instrumentation
436
+
437
+ Bundler loads the `appmap` code when you load a gemset it's defined in (by default, `test` and `development`). When the `appmap` code is loaded,
438
+ it will instrument the other Ruby code according to the settings in your _appmap.yml_ file.
439
+
440
+ If you don't want `appmap` code to be loaded automatically by Bundler, you can conditionally disable it like this:
441
+
442
+ ```
443
+ # The appmap gem is the first gem in the file
444
+ gem 'appmap', groups: %i[development test], require: ENV['APPMAP'] == 'true'
445
+ ```
446
+
447
+ In this example, the `appmap` code will only be loaded when environment variable `APPMAP=true`.
448
+ If you prevent bundler from loading `appmap`, you can load it later on by using `require` in the usual way.
449
+ For example, in Rails `application.rb`:
450
+
451
+ ```
452
+ require 'appmap'
453
+ ```
454
+
455
+ Of course, if instrumentation is disabled in this way, then no AppMap Data will be recorded.
456
+
457
+ ## Advanced runtime options
458
+
459
+ **`APPMAP_PROFILE_HOOK`**
460
+
461
+ `appmap-ruby` inspects and instruments code as it's loaded by the Ruby virtual machine.
462
+ Start your program with `APPMAP_PROFILE_HOOK=true` to see diagnostic information about how much time
463
+ it's taking `appmap-ruby` to instrument each Gem in your _appmap.yml_.
464
+
465
+ **`APPMAP_LOG_HOOK`**
466
+
467
+ Emit detailed logging about the instrumentation hooks that `appmap-ruby` adds to the code. By default,
468
+ this information is logged to *appmap_hook.log*. See also: `APPMAP_LOG_HOOK_FILE`.
469
+
470
+ **`APPMAP_LOG_HOOK_FILE`**
471
+
472
+ Direct the hook logs to a different file. Specify a file name, or `APPMAP_LOG_HOOK_FILE=stderr`.
473
+
474
+ **`APPMAP_PROFILE_DISPLAY_STRING`**
475
+
476
+ `appmap-ruby` tries to include a useful string representation of each parameter and return value in the
477
+ AppMap. In some cases, there are pathological classes that take a long time to stringify.
478
+ Start your program with `APPMAP_PROFILE_DISPLAY_STRING=true` to see diagnostic information about how much time
479
+ it's taking `appmap-ruby` to stringify different object classes.
480
+
481
+ **`APPMAP_GEM_HOOKS_PATH`**
482
+
483
+ `appmap-ruby` ships with a default set of hooks that instrument and label popular Gems. The default list of hooks
484
+ can be extended with custom configuration so that Gems used in your application do not have to be explicitly
485
+ included and labeled in each _appmap.yml_. Set `APPMAP_GEM_HOOKS_PATH` to a folder with your custom hooks configuration `yaml`
486
+ files that use the _appmap.yml_ `functions` syntax. See the [AppMap default hooks configuration](https://github.com/getappmap/appmap-ruby/blob/8080222ce5b61d9824eaf20410d7b9b94b679890/lib/appmap/gem_hooks) example (note: Gem names can be inferred from configuration file names if the `gem` property is missing).
487
+
488
+ **`APPMAP_RECORD_<CUCUMBER|MINITEST|RSPEC>`**
489
+
490
+ You can enable or disable recording for individual test frameworks using these environment variables.
491
+ For example, to manage recording when using `minitest`, use the variable APPMAP_RECORD_MINITEST`.
492
+
493
+ When `true` (the default), recording for the test type is always enabled.
494
+ When `false`, it's always disabled.
495
+
496
+ **`APPMAP_RECORD_REQUESTS`**
497
+
498
+ When `true` (the default), requests recording is always enabled.
499
+ When `false`, it's always disabled.
500
+
501
+ **`APPMAP_RECORD_REMOTE`**
502
+
503
+ When `true` (the default), remote recording is always enabled.
504
+ When `false`, it's always disabled.
505
+
506
+ **`APPMAP`**
507
+
508
+ When `true` (the default), all recording is enabled.
509
+ When `false`, all recording is disabled.
510
+
511
+ ## GitHub repository
512
+
513
+ [https://github.com/getappmap/appmap-ruby](https://github.com/getappmap/appmap-ruby)
514
+
@@ -0,0 +1,171 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ description: "Learn how to use AppMap GitHub Actions to analyze code changes efficiently. Setup and configure AppMap tools, archive, and analyze AppMap Data for each pull request."
5
+ reference: true
6
+ toc: true
7
+ name: GitHub Action
8
+ step: 16
9
+ ---
10
+
11
+ # GitHub Action Reference <!-- omit in toc -->
12
+
13
+ - [Actions Reference](#actions-reference)
14
+ - [Install AppMap Tools](#install-appmap-tools)
15
+ - [Archive AppMap Data](#archive-appmap-data)
16
+ - [Analyze AppMap Data](#analyze-appmap-data)
17
+ - [Reusable Workflows](#reusable-workflows)
18
+ - [Permissions](#permissions)
19
+
20
+
21
+ <p class="alert alert-info">
22
+ To get started with the AppMap GitHub Action, <a href="/docs/integrations/github-actions">refer to the setup documentation</a>
23
+ </p>
24
+
25
+ ## Actions Reference
26
+
27
+ AppMap uses 3 separate GitHub Actions to analyze your code on each pull request. Find the reference documentation below for each of these actions.
28
+
29
+ ### Install AppMap Tools
30
+ [getappmap/install-action](https://github.com/getappmap/install-action)
31
+ Prepares a repository to record AppMap Data and to run AppMap CLI commands.
32
+
33
+ This Action will run on commits to the main branch and whenever pull requests are created. The Action will install the AppMap binary into the GitHub Action environment in the `/usr/local/bin/` directory.
34
+
35
+ [Configuration Options](https://github.com/getappmap/install-action/blob/main/action.yml)
36
+
37
+ ### Archive AppMap Data
38
+ [getappmap/archive-action](https://github.com/getappmap/archive-action)
39
+ Archives AppMap Data built in the current project.
40
+
41
+ This Action runs when a new branch or Pull Request is merged to the main branch. It will generate a `.tar.gz` archive of the AppMap Data created by your test cases and store it as a GitHub artifact. The stored file includes the archive JSON and the AppMap Data archive.
42
+
43
+ [Configuration Options](https://github.com/getappmap/archive-action/blob/main/action.yml)
44
+
45
+ ### Analyze AppMap Data
46
+ [getappmap/analyze-action](https://github.com/getappmap/analyze-action)
47
+
48
+ This Action runs when a Pull Request (or draft) is opened, reopened, or a new commit is added. This Action generates the AppMap analysis report for the head revision, compared to the base branch. A report in Markdown format is generated and is stored as a GitHub artifact within the GitHub Action. This report can optionally be pushed to the active Pull Request as a comment.
49
+
50
+ [Configuration Options](https://github.com/getappmap/analyze-action/blob/main/action.yml)
51
+
52
+ ## Reusable Workflows
53
+
54
+ GitHub supports calling a [reusable workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows) in another project to simplify configuration. AppMap provides two reusable workflows for single runner and full matrix builds.
55
+
56
+ For single runner builds: [appmap-analysis.yml@v1](https://github.com/getappmap/analyze-action/blob/v1/.github/workflows/appmap-analysis.yml)
57
+
58
+ **Inputs**
59
+ ```yaml
60
+ inputs:
61
+ archive-retention-days:
62
+ required: false
63
+ type: number
64
+ default: 7
65
+ runner-name:
66
+ required: false
67
+ type: string
68
+ default: ubuntu-latest
69
+ directory:
70
+ required: false
71
+ type: string
72
+ default: .
73
+ ```
74
+ {: .example-code}
75
+
76
+ For example you can customize your runner with:
77
+ ```yaml
78
+ appmap-analysis:
79
+ if: always()
80
+ needs: [record-appmaps]
81
+ uses: getappmap/analyze-action/.github/workflows/appmap-analysis.yml@v1
82
+ with:
83
+ runner-name: My-Custom-4-Core-Runner
84
+ permissions:
85
+ actions: read
86
+ contents: read
87
+ checks: write
88
+ pull-requests: write
89
+ ```
90
+ {: .example-code}
91
+
92
+ [appmap-analysis-matrix.yml@v1](https://github.com/getappmap/analyze-action/blob/v1/.github/workflows/appmap-analysis-matrix.yml)
93
+
94
+ ```yaml
95
+ inputs:
96
+ archive-retention-days:
97
+ required: false
98
+ type: number
99
+ default: 7
100
+ archive-count:
101
+ required: true
102
+ type: number
103
+ runner-name:
104
+ required: false
105
+ type: string
106
+ default: ubuntu-latest
107
+ directory:
108
+ required: false
109
+ type: string
110
+ default: .
111
+ ```
112
+ {: .example-code}
113
+
114
+ The matrix runner supports a custom runner name and requires an `archive-count` which needs to be equal to the total number of runners in your matrix build.
115
+
116
+ **Example:** `4` or `15`
117
+
118
+ **Example inside reusable workflow.**
119
+ ```yaml
120
+ appmap-analysis:
121
+ if: always()
122
+ needs: [record-appmaps]
123
+ uses: getappmap/analyze-action/.github/workflows/appmap-analysis-matrix.yml@v1
124
+ with:
125
+ archive-count: 2
126
+ permissions:
127
+ actions: read
128
+ contents: read
129
+ checks: write
130
+ pull-requests: write
131
+ ```
132
+ {: .example-code}
133
+
134
+ Multiple options can be passed to the reusable workflows.
135
+
136
+ ```yaml
137
+ appmap-analysis:
138
+ if: always()
139
+ needs: [record-appmaps]
140
+ uses: getappmap/analyze-action/.github/workflows/appmap-analysis-matrix.yml@v1
141
+ with:
142
+ archive-count: 2
143
+ runner-name: My-Custom-4-Core-Runner
144
+ permissions:
145
+ actions: read
146
+ contents: read
147
+ checks: write
148
+ pull-requests: write
149
+ ```
150
+ {: .example-code}
151
+
152
+ ## Permissions
153
+
154
+ ```yaml
155
+ permissions:
156
+ actions: read
157
+ contents: write
158
+ checks: write
159
+ pull-requests: write
160
+ ```
161
+ {: .example-code}
162
+
163
+ Configures the permissions granted to the `$GITHUB_TOKEN`. This is the minimum required level of permissions that will allow the GitHub Action to execute. Refer to the [GitHub documentation](https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs) for more details about Action permission levels.
164
+
165
+ `actions: read` Grants the GitHub Action permission to interact with the artifacts and caches of the job to read the baseline artifact and perform the AppMap comparison.
166
+
167
+ `contents: write` Grants the Action permission to commit the AppMap library and configuration file to the project during installation. Also grants permission to read the artifacts created by the GitHub Action, such as the AppMap archive tarballs. This is used to fetch the "base" and "head" archive data for comparing changes between a mainline branch and changes in a Pull Request.
168
+
169
+ `checks: write` Allows the Action to annotate code inline in a Pull Request workflow.
170
+
171
+ `pull-requests: write` Grants the Action permission to comment on the Pull Request with a detailed report of code behavior changes.