If you are using a build server or other system to automate your builds, you can include the verification scan as part of this process to automatically list the results, for example using cron. We are internally using the system this way using an Ubuntu-based custom build server.
Calling verify from the command line interface
The following script can be used to perform a check of the complete project, the result is written to a text file and can then be processed further.
This is the linux call we use to run this code. You can adjust it to your needs; a full documentation on how to do this is beyond the scope of this documentation and project:
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity -quit -batchmode -nographics -projectPath /myProjectPath/ -executeMethod BuildServerFunctions.PerformVerify > /builds/verifyLog.txt
//
// Copyright (c) 2023 Off The Beaten Track UG
// All rights reserved.
//
using Sparrow.Verification;
using OTBT.Framework.Utils;
using UnityEngine;
using System.IO;
public class BuildServerFunctions
{
// this function can be called from the command line
private static string PerformVerify()
{
string path = "./Builds/verifyReport.txt";
if (!Directory.Exists("./Builds"))
Directory.CreateDirectory("./Builds");
StreamWriter writer = new StreamWriter(path, true);
VerifyWindow verifyWindow = new VerifyWindow();
var dict = verifyWindow.PerformCheck(VerifyWindow.CheckType.All);
int numberOfProblems = dict.Count;
string output = $"**Verify found {numberOfProblems} problems in project {Application.productName}.**\n";
writer.WriteLine($"Verify found {numberOfProblems} problems in project {Application.productName}.\n");
int areaProblems = 0;
string tempOutput = "";
dict.Sort((a, b) => a.category.CompareTo(b.category));
string lastCategory = "";
foreach (VerifyResult check in dict)
{
if (!check.category.Equals(lastCategory))
{
lastCategory = check.category;
tempOutput += "\n\n" + lastCategory;
}
areaProblems += 1;
tempOutput += "\n" + check.toString;
}
if(areaProblems > 0)
output += " :red_circle: "+": " + areaProblems + " problems\n";
writer.WriteLine((areaProblems > 0 ? " XX" : " OK") + " " + ": " + areaProblems + " problems" + tempOutput);
Dbg.Log(null, output);
writer.Close();
return output;
}
}
Integration into build servers
You can integrate your Verify scan into Travis CI or Circle CI by including the command line call in the CI system’s build script. In the respective configuration file (e.g., .travis.yml
for Travis CI or config.yml
for Circle CI), add a step that executes your Verify script. Ensure that the required environment with Unity and all dependencies is set up. This allows you to automatically run the scan with each build and evaluate the results accordingly.