Integrating with CI (Parallel Jobs)

For applications with large test suites, you can greatly accelerate your builds by running the test cases in parallel using a tool like Knapsack Pro.

AppMap Analysis works great with parallel builds, because the scanning can also be distributed across the jobs (aka workers, containers). Parallel builds can reduce test execution from hours to minutes, and when AppMap Analysis is performed in parallel, it adds negligible overhead to the build process.

The @appland/scanner CLI provides two features to facilitate parallel scanning:

  1. The option ci --merge-key associates the scan results for each job with a merge-key that is common to all the parallelized jobs.
  2. merge is invoked after all the jobs are complete, using the merge-key to merge the scan results together.

Configure parallel builds

Follow the instructions for your CI tool to configure the parallel build.

Run ci with --merge-key in each job

The merge key identifies the build number.

Examples

  • Travis: TRAVIS_BUILD_NUMBER
  • GitLab CI: CI_PIPELINE_IID
  • Jenkins: BUILD_NUMBER
$ npx @appland/scanner ci -c appmap-analysis-config.yml -d tmp/appmap --merge-key=$BUILD_NUMBER
..!.......!..........!..........!..........!..........!....................!!...
....!..........!..........!..........!.....................!..........!.........
...
Creating mapset in app mycorp/myapp-server with 2 AppMaps
Uploading findings
Uploaded 2 findings to https://app.land/scanner_jobs/121    

Run the merge command in the final build stage

$ npx @appland/scanner merge $BUILD_NUMBER
Merging scan results in app mycorp/myapp-server with merge key 10348
Merged results to https://app.land/scanner_jobs/130215

Update the commit status and/or fail the build

See the Integrating with CI (Basic) guide for details.


Was this page helpful? thumb_up Yes thumb_down No
Thank you for your feedback!