@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.
- package/CHANGELOG.md +7 -0
- package/built/docs/CLA Instructions.pdf +0 -0
- package/built/docs/Code of Conduct for Contributors.pdf +0 -0
- package/built/docs/analysis/rules-reference.html +27 -0
- package/built/docs/appmap-docs.md +27 -0
- package/built/docs/community.md +28 -0
- package/built/docs/guides/exporting-appmap-diagrams.md +50 -0
- package/built/docs/guides/handling-large-appmap-diagrams.md +138 -0
- package/built/docs/guides/index.md +21 -0
- package/built/docs/guides/navigating-code-objects.md +67 -0
- package/built/docs/guides/openapi.md +105 -0
- package/built/docs/guides/reading-sql-in-appmap-diagrams.md +69 -0
- package/built/docs/guides/refine-appmap-data.md +186 -0
- package/built/docs/guides/reverse-engineering.md +377 -0
- package/built/docs/guides/runtime-code-review.md +111 -0
- package/built/docs/guides/using-appmap-analysis.md +206 -0
- package/built/docs/guides/using-appmap-diagrams.md +331 -0
- package/built/docs/integrations/atlassian-compass.md +25 -0
- package/built/docs/integrations/atlassian-confluence.md +51 -0
- package/built/docs/integrations/circle-ci.md +424 -0
- package/built/docs/integrations/docker.md +109 -0
- package/built/docs/integrations/github-actions.md +524 -0
- package/built/docs/integrations/index.md +20 -0
- package/built/docs/integrations/plantuml.md +66 -0
- package/built/docs/integrations/postman.md +30 -0
- package/built/docs/integrations/readme.md +39 -0
- package/built/docs/integrations/smartbear-swaggerhub.md +119 -0
- package/built/docs/reference/analysis-labels.md +49 -0
- package/built/docs/reference/analysis-rules.md +61 -0
- package/built/docs/reference/appmap-client-cli.md +628 -0
- package/built/docs/reference/appmap-gradle-plugin.md +141 -0
- package/built/docs/reference/appmap-java.md +311 -0
- package/built/docs/reference/appmap-maven-plugin.md +164 -0
- package/built/docs/reference/appmap-node.md +185 -0
- package/built/docs/reference/appmap-python.md +520 -0
- package/built/docs/reference/appmap-ruby.md +514 -0
- package/built/docs/reference/github-action.md +171 -0
- package/built/docs/reference/index.md +25 -0
- package/built/docs/reference/jetbrains.md +136 -0
- package/built/docs/reference/license-key-install.md +74 -0
- package/built/docs/reference/navie.md +261 -0
- package/built/docs/reference/remote-recording-api.md +97 -0
- package/built/docs/reference/uninstalling-appmap.md +119 -0
- package/built/docs/reference/vscode.md +122 -0
- package/built/docs/setup-appmap-in-ci/example-projects.md +21 -0
- package/built/docs/setup-appmap-in-ci/how-it-works.md +43 -0
- package/built/docs/setup-appmap-in-ci/in-circleci.md +423 -0
- package/built/docs/setup-appmap-in-ci/in-github-actions.md +177 -0
- package/built/docs/setup-appmap-in-ci/index.md +22 -0
- package/built/docs/setup-appmap-in-ci/matrix-builds.md +225 -0
- package/built/docs/setup-appmap-in-ci/troubleshooting.md +71 -0
- package/built/docs/setup-appmap-in-your-code-editor/add-appmap-to-your-code-editor.md +93 -0
- package/built/docs/setup-appmap-in-your-code-editor/appmap-analysis.md +77 -0
- package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-from-tests.md +93 -0
- package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-with-remote-recording.md +112 -0
- package/built/docs/setup-appmap-in-your-code-editor/generate-appmap-data-with-request-recording.md +77 -0
- package/built/docs/setup-appmap-in-your-code-editor/how-appmap-works.md +166 -0
- package/built/docs/setup-appmap-in-your-code-editor/index.md +25 -0
- package/built/docs/setup-appmap-in-your-code-editor/navigating-appmap-diagrams.md +59 -0
- package/built/docs/setup-appmap-in-your-code-editor/navigating-code-objects.md +67 -0
- package/built/docs/unused_for_now_index.html +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: docs
|
|
3
|
+
title: Set up AppMap in CI
|
|
4
|
+
description: "Get started with AppMap and CircleCI for behavioral analysis in your test cases. Follow steps to sync files, set up GitHub Action, and analyze runtime code changes."
|
|
5
|
+
name: Getting Started with CircleCI
|
|
6
|
+
setup-appmap-ci: true
|
|
7
|
+
step: 3
|
|
8
|
+
render_with_liquid: false
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Getting Started with CircleCI <!-- omit in toc -->
|
|
12
|
+
|
|
13
|
+
<p class="alert alert-info">
|
|
14
|
+
If at any point you would like some help, <a href="/slack">join us in Slack</a>!
|
|
15
|
+
You'll find the AppMap team there, along with other AppMap users.
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
- [How it works](#how-it-works)
|
|
19
|
+
- [Step-by-step walkthrough](#step-by-step-walkthrough)
|
|
20
|
+
- [Prerequisites](#prerequisites)
|
|
21
|
+
- [Step 1: Setup AppMap file sync in existing CircleCI Project](#step-1-setup-appmap-file-sync-in-existing-circleci-project)
|
|
22
|
+
- [Step 2: Setup AppMap GitHub Action for baseline](#step-2-setup-appmap-github-action-for-baseline)
|
|
23
|
+
- [Step 3: Add AppMap to compare HEAD revision](#step-3-add-appmap-to-compare-head-revision)
|
|
24
|
+
- [Step 4: Merge Pull Request to enable AppMap](#step-4-merge-pull-request-to-enable-appmap)
|
|
25
|
+
- [Example Project Files](#example-project-files)
|
|
26
|
+
- [Advanced Configuration Options](#advanced-configuration-options)
|
|
27
|
+
- [Prerequisites](#prerequisites-1)
|
|
28
|
+
- [Step 1: Add or Update AppMap action to use `repository_dispatch` trigger](#step-1-add-or-update-appmap-action-to-use-repository_dispatch-trigger)
|
|
29
|
+
- [Step 2: Update your CircleCI build to trigger the GitHub API on a successfully build completion.](#step-2-update-your-circleci-build-to-trigger-the-github-api-on-a-successfully-build-completion)
|
|
30
|
+
- [Next Steps](#next-steps)
|
|
31
|
+
|
|
32
|
+
## Overview <!-- omit in toc -->
|
|
33
|
+
AppMap works with your test cases in CircleCI and a GitHub Action to collect, store, analyze, and report on the behavioral changes within each Pull Request. Tests can execute within your existing CircleCI build job, and AppMaps can be retrieved by a GitHub Action to analyze the code behavior changes.
|
|
34
|
+
|
|
35
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/analysis-github-action.webp"/>
|
|
36
|
+
|
|
37
|
+
## How it works
|
|
38
|
+
|
|
39
|
+
AppMap records the behavior of your test cases when they run in CircleCI and produces AppMap data that can be copied to a centralized storage repository. An additional step is added in your CircleCI build job to create a tarball of that data and push the resulting file to a centralized object storage or file storage of your control. From there, the AppMap GitHub Action will download those maps and analyze them. AppMap will add comments to your Pull Request with deep insights into the runtime code changes.
|
|
40
|
+
|
|
41
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/circleci-github-arch-diagram.webp"/>
|
|
42
|
+
|
|
43
|
+
In this example, the following events will happen:
|
|
44
|
+
|
|
45
|
+
<b>1) CircleCI builds your application and runs automated test cases run with AppMaps created in `tmp/appmap` on the CircleCI runner.</b>
|
|
46
|
+
- A tarball (`tar`) file of the `tmp/appmap` directory is created in the CircleCI runner.
|
|
47
|
+
- This tarball is copied to your chosen centralized location (such as AWS S3 or Azure Blob Storage) for secure storage and retrieval by the AppMap GitHub Action.
|
|
48
|
+
|
|
49
|
+
<b>2) While the CircleCI build is running, the AppMap GitHub Action will also trigger, looking for a baseline archive for comparison.</b>
|
|
50
|
+
- The AppMap GitHub Action waits until all the AppMaps exist on the central storage location before continuing.
|
|
51
|
+
- This will download the raw AppMaps created by CircleCI in your previous step to generate a baseline archive for comparison.
|
|
52
|
+
|
|
53
|
+
<b>3) The GitHub Action will analyze the latest maps against the baseline for the pull request.
|
|
54
|
+
- The AppMap GitHub Action will provide a full runtime code analysis diff report as a comment in your pull request.</b>
|
|
55
|
+
|
|
56
|
+
## Step-by-step walkthrough
|
|
57
|
+
|
|
58
|
+
### Prerequisites
|
|
59
|
+
|
|
60
|
+
1) AppMap only supports project that have automated test cases. To add AppMap to your project, use either the [AppMap installer CLI](/docs/reference/appmap-client-cli.html#install) or manually add with the [AppMap libraries](/docs/reference).
|
|
61
|
+
|
|
62
|
+
2) A centralized storage location (such as Amazon S3 or Azure Blob Storage) for storing raw AppMaps generated from the test cases. This storage needs write access from CircleCI and read access from GitHub Actions. In this example below we will use Amazon S3.
|
|
63
|
+
|
|
64
|
+
### Step 1: Setup AppMap file sync in existing CircleCI Project
|
|
65
|
+
|
|
66
|
+
First, create a branch called `appmap-ci` in your project. Next, in your CircleCI configuration (generally found at `.circle/config.yml`), add a run action that will create a (`tar`) of your AppMaps after your test cases are completed.
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- run:
|
|
70
|
+
name: Create archive of AppMaps
|
|
71
|
+
command: tar --remove-files -cvzf <<pipeline.git.revision>>.tar tmp/appmap/
|
|
72
|
+
```
|
|
73
|
+
{: .example-code}
|
|
74
|
+
|
|
75
|
+
Using the CircleCI pipeline value of `<<pipeline.git.revision>>` will give this archive tarball a unique file name based on the SHA the AppMaps are based on.
|
|
76
|
+
|
|
77
|
+
After the archive step, add the necessary steps to authenticate and copy this archive file to your centralized storage location. In our example below, we will authenticate with Amazon AWS to generate temporary credentials and then we will copy this file to the configured bucket. In this example, copying the tarball to the `s3://circleci-appmaps/` bucket.
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
- aws-cli/setup:
|
|
81
|
+
profile_name: Circle-CI-Write-to-S3
|
|
82
|
+
role_arn: arn:aws:iam::12345678900:role/Circle-CI-Write-to-S3
|
|
83
|
+
|
|
84
|
+
- aws-s3/copy:
|
|
85
|
+
from: <<pipeline.git.revision>>.tar
|
|
86
|
+
profile_name: Circle-CI-Write-to-S3
|
|
87
|
+
to: s3://circleci-appmap/
|
|
88
|
+
arguments: --region us-west-2
|
|
89
|
+
```
|
|
90
|
+
{: .example-code}
|
|
91
|
+
|
|
92
|
+
[**Example Code Commit**](https://github.com/land-of-apps/circle-ci-example/commit/1b1f2e886c8ca0a166296147b083d3eb500a8c5f)
|
|
93
|
+
|
|
94
|
+
After you push this commit to your branch, CircleCI will trigger a workflow and you can confirm that the steps all completed successfully.
|
|
95
|
+
|
|
96
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/circle-ci-example-storage.webp"/>
|
|
97
|
+
|
|
98
|
+
Once you have confirmed your AppMaps have successfully copied to your centralized file repository, merge this branch and continue to the next step.
|
|
99
|
+
|
|
100
|
+
### Step 2: Setup AppMap GitHub Action for baseline
|
|
101
|
+
|
|
102
|
+
To setup the GitHub Action, create a new branch called `appmap-action` in your repository.
|
|
103
|
+
|
|
104
|
+
Create a new file with the name `.github/workflows/appmap-analysis.yml`
|
|
105
|
+
|
|
106
|
+
In this file you can use [this default action example](https://github.com/land-of-apps/rails-7-app/blob/c70b48891f38f92223ec06a654406cb7a6886890/.github/workflows/appmap-analysis.yml#L1-L77). **NOTE** Right now you will only use the first job that is listed in lines 1-77, after we create the baseline archive we'll add the AppMap job below this section.
|
|
107
|
+
|
|
108
|
+
- Download the AppMap tooling into the runner.
|
|
109
|
+
- Check for an existing baseline AppMap archive stored in your GitHub artifact store.
|
|
110
|
+
- (If no baseline AppMap archive exists) Locate and download the tarball of AppMaps for the base revision from your chosen centralized data store.
|
|
111
|
+
- (If no baseline AppMap archive exists) Create an AppMap archive of the baseline AppMaps and store to your GitHub artifact store.
|
|
112
|
+
|
|
113
|
+
Commit your GitHub Action workflow file to your branch and open a new Pull Request which will trigger the action.
|
|
114
|
+
|
|
115
|
+
After the action completes running successfully, check the action summary and confirm a build artifact has been created like the following screenshot.
|
|
116
|
+
|
|
117
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/github-artifact-example.webp"/>
|
|
118
|
+
|
|
119
|
+
### Step 3: Add AppMap to compare HEAD revision
|
|
120
|
+
|
|
121
|
+
After the previous step succeeds and the baseline AppMap data is created, [update the GitHub Action](https://github.com/land-of-apps/rails-7-app/blob/c70b48891f38f92223ec06a654406cb7a6886890/.github/workflows/appmap-analysis.yml#L79-L125) to include a similar job to fetch the AppMaps for the HEAD revision and additionally analyze the code changes for code quality problems and provide a detailed report into the pull request comments.
|
|
122
|
+
|
|
123
|
+
[Review this example commit](https://github.com/land-of-apps/circle-ci-example/pull/2/commits/4ea72bb9c930960dafd38698749a0b1dbc2e9db8) for an example of the additional steps to add to your GitHub Action.
|
|
124
|
+
|
|
125
|
+
When the build completes successfully, you will see a comment from the GitHub Action. After merging this Pull Request you will see a similar analysis on each new Pull Request.
|
|
126
|
+
|
|
127
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/initial-report.webp"/>
|
|
128
|
+
|
|
129
|
+
Your completed installation should now look like the following [Pull Request Example.](https://github.com/land-of-apps/circle-ci-example/pull/2)
|
|
130
|
+
|
|
131
|
+
### Step 4: Merge Pull Request to enable AppMap
|
|
132
|
+
|
|
133
|
+
After you merge this Pull Request, AppMap will execute on each subsequent Pull Request.
|
|
134
|
+
|
|
135
|
+
With AppMap deployed in your project, AppMap will execute on each Pull Request and provide a detailed runtime code analysis on each new commit. AppMap performs a thorough analysis of the runtime differences, giving you:
|
|
136
|
+
|
|
137
|
+
- Root cause analysis of failed tests.
|
|
138
|
+
- Web service API changes, both breaking and non-breaking.
|
|
139
|
+
- New and resolved security findings.
|
|
140
|
+
- New and resolved performance findings.
|
|
141
|
+
- New and resolved findings in other categories: maintainability, reliability, and user-defined rules.
|
|
142
|
+
- "Behavioral diffs" as sequence diagrams showing changed runtime behavior within the PR.
|
|
143
|
+
|
|
144
|
+
[Example Pull Request with Runtime Code Diff](https://github.com/land-of-apps/rails-7-app/pull/14)
|
|
145
|
+
|
|
146
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/analysis-pull-request.webp"/>
|
|
147
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/analysis-checks-with-circleci.webp"/>
|
|
148
|
+
|
|
149
|
+
## Example Project Files
|
|
150
|
+
|
|
151
|
+
- [Example Ruby on Rails Project](https://github.com/land-of-apps/rails-7-app/)
|
|
152
|
+
- [Pull Request with Runtime Code Diff](https://github.com/land-of-apps/rails-7-app/pull/14)
|
|
153
|
+
- [CircleCI Example copying AppMaps to Amazon S3](https://github.com/land-of-apps/rails-7-app/blob/c70b48891f38f92223ec06a654406cb7a6886890/.circleci/config.yml#L34-L46)
|
|
154
|
+
- [GitHub Action Workflow File](https://github.com/land-of-apps/rails-7-app/blob/c70b48891f38f92223ec06a654406cb7a6886890/.github/workflows/appmap-analysis.yml)
|
|
155
|
+
|
|
156
|
+
## Advanced Configuration Options
|
|
157
|
+
|
|
158
|
+
In our basic CircleCI example above, both the CircleCI test runner and the AppMap action will start running at the same time. The GitHub Action will check your central storage location every 10 seconds until your baseline maps and HEAD revision maps exist. For many projects where your test cases can complete in a short amount of time, this additional wait time in the AppMap GitHub Action is worth the cost for the simpler configuration to get started.
|
|
159
|
+
|
|
160
|
+
But if your test cases on CircleCi take longer to run, it can be inefficient and expensive to have a GitHub Action running and waiting for files to become available. You can use the GitHub API to trigger a webhook event called `repository_dispatch` when you want to trigger a workflow for activity that happens outside of GitHub. In our case after CircleCI has successfully finished running test and pushed the AppMap archive to the central file storage location.
|
|
161
|
+
|
|
162
|
+
Refer to the [GitHub Action documentation](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatch) for more details about how the `repository_dispatch` action trigger works.
|
|
163
|
+
|
|
164
|
+
The overall architecture largely stays the same as the basic example from above. You can see in the diagram below we've added a new step #2 where a CircleCI job will make a call to the GitHub API to trigger a webhook and start our updated GitHub Action.
|
|
165
|
+
|
|
166
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/advanced-circleci-github-arch-diagram.webp"/>
|
|
167
|
+
|
|
168
|
+
### Prerequisites
|
|
169
|
+
|
|
170
|
+
- [Create a GitHub Personal Access Token](https://docs.github.com/en/enterprise-server@3.8/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with the `repo` scope. This needs to be stored in your CircleCI account as an environment variable.
|
|
171
|
+
- The `repository_dispatch` trigger will only run if your workflow file is on your main branch. As such, you'll need the ability to commit to your project main branch.
|
|
172
|
+
- Centralized storage setup and configured for access. As the example above, you'll need write access from CircleCI and read access from GitHub Actions. In our example we'll be using Amazon S3.
|
|
173
|
+
- This walkthrough assumes you have already completed the basic setup steps in the previous example. At the very least you need to ensure you've [completed Step 2](/docs/setup-appmap-in-ci/in-circleci.html#step-2-setup-appmap-github-action-for-baseline) and have a baseline AppMap archive ready for analysis.
|
|
174
|
+
|
|
175
|
+
### Step 1: Add or Update AppMap action to use `repository_dispatch` trigger
|
|
176
|
+
|
|
177
|
+
For this updated GitHub Action to work you'll need to commit a software utility to your project that will locate which Pull Request your commit is associated with. Normally when a Pull Request is opened, the AppMap Action will trigger and the action payload will include details about which Pull Request the AppMap report will be associated with. But since our action will be triggered via a webhook, it will lack information about what Pull Request is associated with the commit.
|
|
178
|
+
|
|
179
|
+
#### Add `searchPullRequest.js` to your project <!-- omit in toc -->
|
|
180
|
+
|
|
181
|
+
You can use this JavaScript function to locate the Pull Request for your commits, and pass the relevant pull request number to the AppMap GitHub Action. [Copy the latest version from the sample project](https://github.com/land-of-apps/rails-7-app/blob/d098acdc0b3d327ebf8c9d062bedb5c779d18008/searchPullRequest.js) and add to your project.
|
|
182
|
+
|
|
183
|
+
Add the following as a new file named `package.json` or add these project dependencies to your existing `package.json`
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"dependencies": {
|
|
188
|
+
"@octokit/rest": "^20.0.2",
|
|
189
|
+
"yargs": "^17.7.2"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
{: .example-code}
|
|
194
|
+
|
|
195
|
+
#### Add/Update the AppMap Action to your project <!-- omit in toc -->
|
|
196
|
+
|
|
197
|
+
The most recent version of the AppMap GitHub Action that can be triggered via a [webhook is located in our sample project.](https://github.com/land-of-apps/rails-7-app/blob/cca7f276cf7c32b4b7a5af218ccf19399084777a/.github/workflows/analyze-maps-from-circleci.yml) You'll need to commit this file (configured for your environment) and the files above into the main branch of your repository. As with the above example you'll need to save this file into the `.github/workflows/` folder.
|
|
198
|
+
|
|
199
|
+
**Commit these files to your main branch and then continue to Step 2.**
|
|
200
|
+
|
|
201
|
+
This action has many steps to process the files and analyze your pull requests, below are details of what each step is doing.
|
|
202
|
+
|
|
203
|
+
* Reconfigure this environment variable to point to your specific central file location.
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
env:
|
|
207
|
+
appmap_storage_bucket: circleci-appmaps
|
|
208
|
+
```
|
|
209
|
+
{: .example-code}
|
|
210
|
+
|
|
211
|
+
* Use this action to set the status of your Pull Request as "pending" for the commit being built.
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
- name: Set commit status as pending
|
|
215
|
+
uses: myrotvorets/set-commit-status-action@f8a3f50eca0d32f3e12dc3a98792bb588bf29626
|
|
216
|
+
with:
|
|
217
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
218
|
+
status: pending
|
|
219
|
+
context: AppMap Analysis
|
|
220
|
+
sha: ${{ github.event.client_payload.head_sha }}
|
|
221
|
+
```
|
|
222
|
+
{: .example-code}
|
|
223
|
+
|
|
224
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/appmap-analysis-status.webp"/>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
* Install the AppMap command line tools, but do not install the libraries.
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
- name: Install AppMap tools
|
|
231
|
+
uses: getappmap/install-action@v1
|
|
232
|
+
with:
|
|
233
|
+
install-appmap-library: false
|
|
234
|
+
```
|
|
235
|
+
{: .example-code}
|
|
236
|
+
|
|
237
|
+
* Check and see if the baseline AppMap archive exists in the GitHub artifact store. This will fail if an archive is not found so we enable `continue-on-error: true`
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
- name: Check for existing baseline archive
|
|
241
|
+
id: check_for_baseline
|
|
242
|
+
env:
|
|
243
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
244
|
+
continue-on-error: true
|
|
245
|
+
run: |
|
|
246
|
+
appmap restore --check --revision ${base_sha} --github-repo ${GITHUB_REPOSITORY} --exact
|
|
247
|
+
```
|
|
248
|
+
{: .example-code}
|
|
249
|
+
|
|
250
|
+
* If the previous step "fails" (i.e. no baseline archive exists) run these steps to download raw AppMaps and archive them for analysis.
|
|
251
|
+
|
|
252
|
+
```yaml
|
|
253
|
+
- name: Download and extract appmaps
|
|
254
|
+
if: steps.check_for_baseline.outcome == 'failure'
|
|
255
|
+
run: |
|
|
256
|
+
aws s3 cp s3://${appmap_storage_bucket}/${base_sha}.tar ${base_sha}.tar
|
|
257
|
+
tar xvf ${base_sha}.tar
|
|
258
|
+
|
|
259
|
+
- name: Archive AppMaps
|
|
260
|
+
if: steps.check_for_baseline.outcome == 'failure'
|
|
261
|
+
uses: getappmap/archive-action@v1
|
|
262
|
+
with:
|
|
263
|
+
revision: ${base_sha}
|
|
264
|
+
```
|
|
265
|
+
{: .example-code}
|
|
266
|
+
|
|
267
|
+
The 2nd section in the GitHub AppMap Action will trigger when the above steps are successful. Below is an explanation of what each of those steps is used for.
|
|
268
|
+
|
|
269
|
+
* As in the previous example, reconfigure the storage bucket location based on where your AppMaps are located.
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
env:
|
|
273
|
+
appmap_storage_bucket: circleci-appmaps
|
|
274
|
+
```
|
|
275
|
+
{: .example-code}
|
|
276
|
+
|
|
277
|
+
* Install Node.js and the packages required to run the `searchPullRequest.js` application.
|
|
278
|
+
|
|
279
|
+
```yaml
|
|
280
|
+
- name: Use Node.js
|
|
281
|
+
uses: actions/setup-node@v2
|
|
282
|
+
with:
|
|
283
|
+
node-version: '18'
|
|
284
|
+
|
|
285
|
+
- name: Install dependencies
|
|
286
|
+
run: npm ci
|
|
287
|
+
```
|
|
288
|
+
{: .example-code}
|
|
289
|
+
|
|
290
|
+
* Download and extract the HEAD revision AppMaps sent from CircleCI
|
|
291
|
+
|
|
292
|
+
```yaml
|
|
293
|
+
- name: Download and extract appmaps
|
|
294
|
+
run: |
|
|
295
|
+
aws s3 cp s3://${appmap_storage_bucket}/${head_sha}.tar ${head_sha}.tar
|
|
296
|
+
tar xvf ${head_sha}.tar
|
|
297
|
+
```
|
|
298
|
+
{: .example-code}
|
|
299
|
+
|
|
300
|
+
* Run `searchPullRequest.js` and locate the most recent Pull Request with the HEAD sha associated. This value will be stored in $LATESTPR.
|
|
301
|
+
|
|
302
|
+
```yaml
|
|
303
|
+
- name: Get only the most recent issue with this head commit
|
|
304
|
+
run: echo LATESTPR=$(node searchPullRequest.js --ownerRepo=${GITHUB_REPOSITORY} --commit=${head_sha}) >> "$GITHUB_ENV"
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
{: .example-code}
|
|
308
|
+
|
|
309
|
+
* Analyze the AppMaps and compare the changes between the base and head revisions, passing the `issue-number` to the analyze-action.
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
- name: Analyze AppMaps
|
|
313
|
+
uses: getappmap/analyze-action@v1
|
|
314
|
+
with:
|
|
315
|
+
issue-number: ${{env.LATESTPR}}
|
|
316
|
+
directory: .
|
|
317
|
+
base-revision: ${{ github.event.client_payload.base_sha }}
|
|
318
|
+
head-revision: ${{ github.event.client_payload.head_sha }}
|
|
319
|
+
```
|
|
320
|
+
{: .example-code}
|
|
321
|
+
|
|
322
|
+
* Update the commit status for this repository_dispatch build.
|
|
323
|
+
|
|
324
|
+
```yaml
|
|
325
|
+
- name: Update Commit Status
|
|
326
|
+
uses: myrotvorets/set-commit-status-action@v2.0.0
|
|
327
|
+
if: always()
|
|
328
|
+
with:
|
|
329
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
330
|
+
status: ${{ job.status }}
|
|
331
|
+
context: AppMap Analysis
|
|
332
|
+
sha: ${{ github.event.client_payload.head_sha }}
|
|
333
|
+
```
|
|
334
|
+
{: .example-code}
|
|
335
|
+
|
|
336
|
+
The commit status update will look like the following in a sucessful pull request.
|
|
337
|
+
|
|
338
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/appmap-analysis-status-complete.webp"/>
|
|
339
|
+
|
|
340
|
+
Make sure to commit the [searchPullRequest.js](https://github.com/land-of-apps/rails-7-app/blob/d098acdc0b3d327ebf8c9d062bedb5c779d18008/searchPullRequest.js), the [package.json](https://github.com/land-of-apps/rails-7-app/blob/d098acdc0b3d327ebf8c9d062bedb5c779d18008/package.json), and the Webhook AppMap GitHub Action before continuing to step 2.
|
|
341
|
+
|
|
342
|
+
[Here is an example commit with the changes files in an example test project.](https://github.com/land-of-apps/circle-ci-example/commit/44bcfafbaf978484fc0d29e826d28161ded89ef6)
|
|
343
|
+
|
|
344
|
+
### Step 2: Update your CircleCI build to trigger the GitHub API on a successfully build completion.
|
|
345
|
+
|
|
346
|
+
For an example of a full CircleCI workflow, [refer to the latest version from our sample project.](https://github.com/land-of-apps/rails-7-app/blob/235f97aa4225f4e6e43715b404182f1df7d5c6f5/.circleci/config.yml)
|
|
347
|
+
|
|
348
|
+
In our example, we'll modify the CircleCI build runner from our basic example, and add a new build job called `run_appmap_analysis` which will only trigger on non-mainline code commits after the normal build succeeds.
|
|
349
|
+
|
|
350
|
+
We don't need to trigger the Webhook based AppMap Action on a mainline branch build because analysis only happens inside of an existing Pull Request.
|
|
351
|
+
|
|
352
|
+
First we can create a new job in our existing `.circleci/config.yml` file.
|
|
353
|
+
|
|
354
|
+
You'll need to update the following items according to your project:
|
|
355
|
+
|
|
356
|
+
- Ensure your GitHub Personal Access Token is saved as a CircleCI secure environment variable at `$GITHUB_PAT`
|
|
357
|
+
- Update the URL for triggering the `repository_dispatch` project. The format is: `https://api.github.com/repos/{ORGNAME}/{REPONAME}/dispatches`
|
|
358
|
+
- [Confirm the name of your `repository_dispatch`](https://github.com/land-of-apps/rails-7-app/blob/235f97aa4225f4e6e43715b404182f1df7d5c6f5/.github/workflows/analyze-maps-from-circleci.yml#L3-L7) action and update the `"event_type": "run_appmap_analysis",` accordingly.
|
|
359
|
+
|
|
360
|
+
```yaml
|
|
361
|
+
run_appmap_analysis:
|
|
362
|
+
docker:
|
|
363
|
+
- image: cimg/ruby:3.1.2
|
|
364
|
+
|
|
365
|
+
steps:
|
|
366
|
+
- checkout
|
|
367
|
+
|
|
368
|
+
- run:
|
|
369
|
+
name: Get base Git SHA
|
|
370
|
+
command: echo 'export BASE_SHA=$(git merge-base origin/main $CIRCLE_BRANCH)' >> $BASH_ENV
|
|
371
|
+
|
|
372
|
+
- run:
|
|
373
|
+
name: Run AppMap Analysis
|
|
374
|
+
command: |
|
|
375
|
+
curl -L \
|
|
376
|
+
-X POST \
|
|
377
|
+
-H "Accept: application/vnd.github.v3+json" \
|
|
378
|
+
-H "Authorization: token $GITHUB_PAT" \
|
|
379
|
+
-H "Content-Type: application/json" \
|
|
380
|
+
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
381
|
+
https://api.github.com/repos/land-of-apps/rails-7-app/dispatches \
|
|
382
|
+
-d @- \<<EOF
|
|
383
|
+
{
|
|
384
|
+
"event_type": "run_appmap_analysis",
|
|
385
|
+
"client_payload": {
|
|
386
|
+
"base_sha": "$BASE_SHA",
|
|
387
|
+
"head_sha": "<< pipeline.git.revision >>"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
EOF
|
|
391
|
+
```
|
|
392
|
+
{: .example-code}
|
|
393
|
+
|
|
394
|
+
In your CircleCI workflow declaration section. Update the jobs so that the GitHub webhook job will only run after the build job and excluding your mainline branch.
|
|
395
|
+
|
|
396
|
+
```yaml
|
|
397
|
+
workflows:
|
|
398
|
+
build:
|
|
399
|
+
jobs:
|
|
400
|
+
- build
|
|
401
|
+
- run_appmap_analysis:
|
|
402
|
+
requires:
|
|
403
|
+
- build
|
|
404
|
+
filters:
|
|
405
|
+
branches:
|
|
406
|
+
ignore:
|
|
407
|
+
- main
|
|
408
|
+
```
|
|
409
|
+
{: .example-code}
|
|
410
|
+
|
|
411
|
+
Now, create a new Pull Request with these changes and on your next CircleCI build, you'll see that the `run_appmap_analysis` job will execute after your normal build step.
|
|
412
|
+
|
|
413
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/circleci-build-example.webp"/>
|
|
414
|
+
|
|
415
|
+
For more details refer to this [example Pull Request](https://github.com/land-of-apps/circle-ci-example/pull/3) and [commit changes](https://github.com/land-of-apps/circle-ci-example/pull/3/commits/8c328130e0572a0eee9b9a0e0b1b2d73e3909ebc) for this sample project.
|
|
416
|
+
|
|
417
|
+
When you view your project's GitHub Actions page, you'll see the `workflow_dispatch` action trigger after CircleCI completes its build after it has uploaded the AppMaps to your centralized data store.
|
|
418
|
+
|
|
419
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/github-action-webhook-example.webp"/>
|
|
420
|
+
|
|
421
|
+
## Next Steps
|
|
422
|
+
|
|
423
|
+
AppMap comes with a comprehensive set of rules that are categorized by their impact on applications: Performance, Reliability, Maintainability, Stability, and Security. [Refer to the AppMap documentation](/docs/setup-appmap-in-ci/in-github-actions.html#configure-additional-appmap-analysis-rules) to learn how to configure these rules for your project.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: docs
|
|
3
|
+
title: Set up AppMap in CI
|
|
4
|
+
description: "Learn how to leverage AppMap within GitHub Actions to analyze behavioral changes in Pull Requests. Install AppMap and configure rules for enhanced performance and security."
|
|
5
|
+
name: Getting Started with GitHub Actions
|
|
6
|
+
setup-appmap-ci: true
|
|
7
|
+
step: 2
|
|
8
|
+
render_with_liquid: false
|
|
9
|
+
redirect_from: [/docs/early-access/in-github-actions,/docs/analysis/in-github-actions]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Getting Started with GitHub Actions <!-- omit in toc -->
|
|
13
|
+
|
|
14
|
+
<p class="alert alert-info">
|
|
15
|
+
If at any point you would like some help, <a href="/slack">join us in Slack</a>!
|
|
16
|
+
You'll find the AppMap team there, along with other AppMap users.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p class="alert alert-success">
|
|
20
|
+
Make sure to <a href="https://github.com/marketplace/get-appmap">install the AppMap App from the GitHub Marketplace</a> before you start the installation process.
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<a class="btn btn-primary btn-lg" href="https://getappmap.com/setup/">Install AppMap for GitHub Actions</a>
|
|
24
|
+
|
|
25
|
+
## Overview <!-- omit in toc -->
|
|
26
|
+
AppMap can work within GitHub Actions to collect, store, analyze, and report on the behavioral changes within each Pull Request. AppMap will analyze the changes in your application on each pushed commit or pull request. AppMap performs a thorough analysis of the runtime differences, giving you:
|
|
27
|
+
|
|
28
|
+
- Root cause analysis of failed tests.
|
|
29
|
+
- Web service API changes, both breaking and non-breaking.
|
|
30
|
+
- New and resolved security findings.
|
|
31
|
+
- New and resolved performance findings.
|
|
32
|
+
- New and resolved findings in other categories: maintainability, reliability, and user-defined rules.
|
|
33
|
+
- "Behavioral diffs" as sequence diagrams showing changed runtime behavior within the PR.
|
|
34
|
+
|
|
35
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/analysis-github-action.webp"/>
|
|
36
|
+
|
|
37
|
+
## Step-by-step walkthrough
|
|
38
|
+
|
|
39
|
+
- [Step 1: Install the AppMap GitHub App from the GitHub Marketplace.](#step-1-install-the-appmap-github-app-from-the-github-marketplace)
|
|
40
|
+
- [Step 2: Choose an Installation Method](#step-2-choose-an-installation-method)
|
|
41
|
+
- [Step 3: Grant Access to your repositories.](#step-3-grant-access-to-your-repositories)
|
|
42
|
+
- [Step 4: Complete the Installation Process](#step-4-complete-the-installation-process)
|
|
43
|
+
- [Step 5: Merge this PR to deploy AppMap](#step-5-merge-this-pr-to-deploy-appmap)
|
|
44
|
+
- [Optional Post-Install Configuration](#optional-post-install-configuration)
|
|
45
|
+
- [Configure Additional AppMap analysis rules](#configure-additional-appmap-analysis-rules)
|
|
46
|
+
|
|
47
|
+
Configuration of the AppMap GitHub Action happens inside a branch and can be easily tested in a Pull Request before merging any code changes to the mainline branch. This allows users to easily test AppMap in the environment before deploying across the repository.
|
|
48
|
+
|
|
49
|
+
Follow the steps below for your project. If you need additional assistance contact AppMap at [support@appmap.io](mailto:support@appmap.io) or join us in our [Community Slack](https://appmap.io/slack)
|
|
50
|
+
|
|
51
|
+
### Step 1: Install the AppMap GitHub App from the GitHub Marketplace.
|
|
52
|
+
|
|
53
|
+
<a class="btn btn-primary btn-lg" href="https://github.com/marketplace/get-appmap">Click to install the AppMap GitHub Action</a>
|
|
54
|
+
|
|
55
|
+
Installing the AppMap GitHub App into your repository will allow the AppMap installer to properly detect your repositories for installation. Your data is your data, AppMap does not store your code or any AppMaps that are generated. For more details about AppMap security controls, review the [Security FAQ](https://appmap.io/security).
|
|
56
|
+
|
|
57
|
+
### Step 2: Choose an Installation Method
|
|
58
|
+
|
|
59
|
+
AppMap runs as a GitHub Action in your project. Add AppMap to a project with an existing GitHub workflow that runs tests successfully. Choose if you would like to install AppMap manually into your project or use the automated AI assisted installation.
|
|
60
|
+
|
|
61
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/manual-or-ai-installer.webp"/>
|
|
62
|
+
|
|
63
|
+
### Step 3: Grant Access to your repositories.
|
|
64
|
+
Granting AppMap access to your repositories allows AppMap to complete an automated installation for your project. For the automated installation to be successful you'll need an existing GitHub workflow which builds and tests your application successfully.
|
|
65
|
+
|
|
66
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/authorize-appmap.webp"/>
|
|
67
|
+
|
|
68
|
+
*Note*: If you do not currently have a GitHub Action that can run your test cases, refer to the [GitHub documentation](https://docs.github.com/en/actions/quickstart) to build an Action that will execute your test cases.
|
|
69
|
+
|
|
70
|
+
### Step 4: Complete the Installation Process
|
|
71
|
+
|
|
72
|
+
Follow the steps in the AppMap installation process to complete the AppMap Installation. AppMap will add a Configuration Report as a comment in the initial pull request.
|
|
73
|
+
|
|
74
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/config-report.webp"/>
|
|
75
|
+
|
|
76
|
+
The initial AppMap report will give you details about:
|
|
77
|
+
|
|
78
|
+
- **AppMap data sources** shows how many AppMaps were recorded, and which test frameworks were used.
|
|
79
|
+
- **Code profile** indicates which packages and modules were recorded.
|
|
80
|
+
- **Web service API profile** summarizes the HTTP requests observed while your tests ran. AppMap uses this information to automatically generate OpenAPI definitions.
|
|
81
|
+
- **SQL profile** summarizes the SQL queries executed in your tests.
|
|
82
|
+
|
|
83
|
+
After completing the initial configuration report, AppMap will analyze your entire source code repository. In this report AppMap will display recently introduced code flaws and problems. A sample of all the problems that were found in the AppMaps are listed in order of when they were most likely introduced, with most recent first.
|
|
84
|
+
|
|
85
|
+
<img class="video-screenshot" src="/assets/img/docs/gh-action/appmap-project-summary.webp"/>
|
|
86
|
+
|
|
87
|
+
### Step 5: Merge this PR to deploy AppMap
|
|
88
|
+
Congratulations! You’ve successfully set up the AppMap GitHub Action and can now merge this into your project to make it available for every other developer to use on each of their subsequent pull requests.
|
|
89
|
+
|
|
90
|
+
To see AppMap in action, create a draft pull request with some changes that you don't plan to merge. Some suggested changes include:
|
|
91
|
+
|
|
92
|
+
- Add a new test
|
|
93
|
+
- Add, change, or remove an API route
|
|
94
|
+
- Change how your application interacts with its database
|
|
95
|
+
|
|
96
|
+
AppMap will execute runtime code analysis on every pull request in this repository.
|
|
97
|
+
|
|
98
|
+
<div class="video-container">
|
|
99
|
+
<video playsinline loop autoplay muted>
|
|
100
|
+
<source src="/assets/img/docs/gh-action/action-report-summary.mp4" type="video/mp4">
|
|
101
|
+
</video>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
## Optional Post-Install Configuration
|
|
105
|
+
|
|
106
|
+
### Configure Additional AppMap analysis rules
|
|
107
|
+
|
|
108
|
+
AppMap comes with a comprehensive set of rules that are categorized by their impact on applications: Performance, Reliability, Maintainability, Stability, and Security.
|
|
109
|
+
|
|
110
|
+
You can refer to the [AppMap Documentation](/docs/reference/analysis-rules) for more information about all the rules that are available within AppMap.
|
|
111
|
+
|
|
112
|
+
To enable additional rules simply add them to an `appmap-scanner.yml` file in the root of your project directory and commit it to your project.
|
|
113
|
+
|
|
114
|
+
This is a sample `appmap-scanner.yml` file which you can use to enable or disable certain AppMap analysis rules. Rules can be disabled by commenting them out with the `#` character.
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
checks:
|
|
118
|
+
- rule: authz-before-authn
|
|
119
|
+
# - rule: circular-dependency
|
|
120
|
+
- rule: deprecated-crypto-algorithm
|
|
121
|
+
- rule: deserialization-of-untrusted-data
|
|
122
|
+
- rule: exec-of-untrusted-command
|
|
123
|
+
- rule: http-500
|
|
124
|
+
# - rule: illegal-package-dependency
|
|
125
|
+
# properties:
|
|
126
|
+
# callerPackages:
|
|
127
|
+
# - equal: actionpack
|
|
128
|
+
# calleePackage:
|
|
129
|
+
# equal: app/controllers
|
|
130
|
+
# - rule: incompatible-http-client-request
|
|
131
|
+
# - rule: insecure-compare
|
|
132
|
+
# - rule: job-not-cancelled
|
|
133
|
+
- rule: logout-without-session-reset
|
|
134
|
+
# - rule: missing-authentication
|
|
135
|
+
- rule: missing-content-type
|
|
136
|
+
- rule: n-plus-one-query
|
|
137
|
+
# - rule: query-from-invalid-package
|
|
138
|
+
# - rule: query-from-view
|
|
139
|
+
# - rule: rpc-without-circuit-breaker
|
|
140
|
+
# - rule: save-without-validation
|
|
141
|
+
- rule: secret-in-log
|
|
142
|
+
# - rule: slow-function-call
|
|
143
|
+
# properties:
|
|
144
|
+
# timeAllowed: 0.2
|
|
145
|
+
# functions:
|
|
146
|
+
# - match: Controller#create$
|
|
147
|
+
# - rule: slow-http-server-request
|
|
148
|
+
# properties:
|
|
149
|
+
# timeAllowed: 0.5
|
|
150
|
+
# - rule: slow-query
|
|
151
|
+
# properties:
|
|
152
|
+
# timeAllowed: 0.05
|
|
153
|
+
- rule: too-many-joins
|
|
154
|
+
- rule: too-many-updates
|
|
155
|
+
# - rule: unbatched-materialized-query
|
|
156
|
+
- rule: unauthenticated-encryption
|
|
157
|
+
- rule: update-in-get-request
|
|
158
|
+
```
|
|
159
|
+
{: .example-code}
|
|
160
|
+
|
|
161
|
+
Add these changes to Git and commit and put them into the PR branch.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
$ git add .
|
|
165
|
+
$ git commit -m "ci: Add customized scanner configuration"
|
|
166
|
+
```
|
|
167
|
+
{: .example-code}
|
|
168
|
+
|
|
169
|
+
Push the changes upstream to your branch which updates the Pull Request.
|
|
170
|
+
```bash
|
|
171
|
+
$ git push
|
|
172
|
+
```
|
|
173
|
+
{: .example-code}
|
|
174
|
+
|
|
175
|
+
The AppMap analysis report will be updated on the completion of the build and a new report will be displayed.
|
|
176
|
+
|
|
177
|
+
For more details about AppMap GitHub Actions refer to the [reference documentation](/docs/reference/github-action)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: docs
|
|
3
|
+
title: Set up AppMap in CI
|
|
4
|
+
description: "Learn to set up AppMap in CI using GitHub Actions or CircleCI. Explore how it works, example projects, and troubleshooting tips."
|
|
5
|
+
redirect_from: [/docs/analysis/integrating-with-ci/]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Set up AppMap in CI
|
|
9
|
+
|
|
10
|
+
<p class="alert alert-info">
|
|
11
|
+
If at any point you would like some help, <a href="/slack">join us in Slack</a>!
|
|
12
|
+
You'll find the AppMap team there, along with other AppMap users.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<a class="btn btn-primary btn-lg" href="https://github.com/marketplace/get-appmap">Get Started with our GitHub integration</a>
|
|
16
|
+
|
|
17
|
+
- [How it works](/docs/setup-appmap-in-ci/how-it-works)
|
|
18
|
+
- [Getting Started with GitHub Actions](/docs/setup-appmap-in-ci/in-github-actions)
|
|
19
|
+
- [Getting Started with CircleCI](/docs/setup-appmap-in-ci/in-circleci)
|
|
20
|
+
- [Example Projects](/docs/setup-appmap-in-ci/example-projects)
|
|
21
|
+
- [Matrix Builds](/docs/setup-appmap-in-ci/matrix-builds)
|
|
22
|
+
- [Troubleshooting](/docs/setup-appmap-in-ci/troubleshooting)
|