Skip to main content

openci_workflow 0.1.0 copy "openci_workflow: ^0.1.0" to clipboard
openci_workflow: ^0.1.0 copied to clipboard

Define and run OpenCI workflows in Dart with branch triggers, shell commands, Flutter helpers, and live log streaming.

OpenCI Workflow #

Write OpenCI workflows in Dart. Define branch triggers, run shell commands, and stream command output to OpenCI's build logs.

Install #

Add the SDK to your repository's root package:

dart pub add --dev openci_workflow

For a Flutter repository, use flutter pub add --dev openci_workflow.

Define a workflow #

Create openci/static_analysis.dart in the repository root:

import 'package:openci_workflow/openci_workflow.dart';

Future<void> main() async {
  final openCI = await OpenCI.init(
    workflowName: 'Static Analysis',
    ciTriggers: [
      CITrigger.push(branch: 'main'),
      CITrigger.pullRequest(branch: 'main'),
    ],
  );

  await openCI.run('dart analyze --fatal-infos');
}

OpenCI discovers Dart files in openci/ and matches their declared triggers to GitHub events. Keep workflow names and trigger branches as string literals so the planner can read them without executing the workflow.

For Flutter analysis, use await openCI.flutter.staticAnalysis() or pass your preferred flutter analyze flags to openCI.run().

Run locally #

dart pub get
dart run openci/static_analysis.dart

Commands run sequentially when awaited. A failed command exits the workflow with the same exit code. Commands use sh, so the runtime needs a Unix shell and the tools called by the workflow.

Use workingDirectory to run a command relative to the repository root:

await openCI.run('flutter analyze', workingDirectory: 'apps/mobile');

Build logs #

Command output is always printed to stdout and stderr. OpenCI workers provide LOKI_URL, OPENCI_RUN_ID, and OPENCI_BUILD_JOB_ID to also send structured build logs to Loki. Without LOKI_URL, local execution only prints to the terminal.

Log forwarding failures produce a warning and do not change the command's exit status.

0
likes
0
points
1.13k
downloads

Publisher

verified publisheropenci.org

Weekly Downloads

Define and run OpenCI workflows in Dart with branch triggers, shell commands, Flutter helpers, and live log streaming.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

freezed_annotation, http, meta

More

Packages that depend on openci_workflow