While you develop in Visual Builder we check your code to make sure there are no errors in it using an audit framework. This audit framework is also available outside of the IDE, which can be helpful when you want to incorporate code auditing in your CI/CD flow. For example if you want to verify that the code a developer is about to merge passes audit.
In Visual Builder Studio you can incorporate build jobs as part of the merge request step. This build job can audit the code to make sure it doesn't have issues before we approve merging. In the video below we show how to:
- Configure a job to run as part of a merge request
- Use build job to run a VB Audit task
- Store the audit results
- Link the build job to a merge request
Configuring an Audit Build Jobs
In the video we create a special type of build job which is marked to be used in merge requests. Once you mark a job that way, it will be available for you to add it as a linked job to a merge request aiming to merge code from one branch to the other. The git repo and branch are passed as parameters to the job automatically from your merge request. This means that you can use the same job for multiple merge requests across branches.
To invoke the audit framework provided by Visual Builder we use the grunt vb-audit command in a shell script. We add two commands in a new shell step:
npm install grunt vb-audit --audit.outputfile='results.json'
This will run the audit and direct the output into the results.json file. We then add a post-build step to archive that file with the job. This way we can access that report easily.
Setting Audit Level
One thing we might want to do is limit the level of notifications we get, for example to ignore small issues (warnings) and only flag errors. We can set this in the app's Gruntfile.js. Here is an example of the setting you can use:
module.exports = (grunt) => {
grunt.initConfig({
'vb-audit': {
options: {
// audit options
config: {
lowestReportedSeverity: 'error'
},
}
}
});
require('load-grunt-tasks')(grunt);
};
For more information about the audit command and the settings you can use to fine tune reporting and which files to review check out the Audit section of the VB doc.
