runCiOf function

Future<int> runCiOf(
  1. MatrixApp app, {
  2. required String directory,
  3. required MatrixCi ci,
  4. bool build = false,
  5. MatrixCommands commands = const MatrixCommands(),
})

Runs the commands of the CI of app, which smf create generated in directory as that app of the matrix, such as an app with every module of the plan of a job of CI, in a clone of it (runCiCommands): those of each push, and with build then the build, with the values of MatrixCiBuild.variables, in a clone of its own, since a build starts from a repository without .env, which the checks may have written.

Returns 0 when each command succeeded and the build left its file, and 1 otherwise, and for an app without CI, whose run would check nothing. The log of commands gets what happens, and their ci runs the commands.

Implementation

Future<int> runCiOf(
  MatrixApp app, {
  required String directory,
  required MatrixCi ci,
  bool build = false,
  MatrixCommands commands = const MatrixCommands(),
}) async {
  // coverage:ignore-start
  // The default prints to the terminal, as the runs in CI do; the tests give
  // their own.
  final say = commands.log ?? _print;
  // coverage:ignore-end
  final run = commands.ci ?? runCiCommands;
  final ofApp = ci(app);
  if (ofApp == null) {
    say('${app.name} has no commands of CI to run.');
    return 1;
  }
  final (checked, output) = await run(directory, ofApp.checks);
  say(output.trim());
  if (checked != 0) return 1;
  if (!build) return 0;
  final (built, buildOutput) = await run(
    directory,
    ofApp.build.commands,
    environment: ofApp.build.variables,
    artifact: ofApp.build.artifact,
  );
  say(buildOutput.trim());
  return built == 0 ? 0 : 1;
}