Skip to content

Commit

Permalink
tullia/actions: do not use after, reference subtask directly for now.
Browse files Browse the repository at this point in the history
 Until `after` is properly supported.
  • Loading branch information
jbgi committed Jan 18, 2023
1 parent d1f26f7 commit a908988
Showing 1 changed file with 96 additions and 77 deletions.
173 changes: 96 additions & 77 deletions nix/tullia.nix
Original file line number Diff line number Diff line change
@@ -1,115 +1,134 @@
/*
This file defines tullia tasks and cicero actions.
Tullia is a sandboxed multi-runtime DAG task runner with Cicero support.
Tasks can be written in different languages and are compiled for each runtime using Nix.
It comes with essential building blocks for typical CI/CD scenarios.
Learn more: https://github.com/input-output-hk/tullia
Cicero is an if-this-then-that machine on HashiCorp Nomad.
It can run any event-and-state-driven automation actions
and hence CI/CD pipelines are a natural fit.
In tandem with Tullia, an action could be described as
the rule that describes when a Tullia task is to be invoked.
Learn more: https://github.com/input-output-hk/cicero
This file defines tullia tasks and cicero actions.
Tullia is a sandboxed multi-runtime DAG task runner with Cicero support.
Tasks can be written in different languages and are compiled for each runtime using Nix.
It comes with essential building blocks for typical CI/CD scenarios.
Learn more: https://github.com/input-output-hk/tullia
Cicero is an if-this-then-that machine on HashiCorp Nomad.
It can run any event-and-state-driven automation actions
and hence CI/CD pipelines are a natural fit.
In tandem with Tullia, an action could be described as
the rule that describes when a Tullia task is to be invoked.
Learn more: https://github.com/input-output-hk/cicero
*/

let
ciInputName = "GitHub event";
repository = "input-output-hk/cardano-node";
in rec {
tasks = let
common = {
config,
...
}: {
preset = {
nix.enable = true;

github.ci = {
enable = config.actionRun.facts != {};
inherit repository;
remote = config.preset.github.lib.readRepository ciInputName null;
revision = config.preset.github.lib.readRevision ciInputName null;
in
rec {
tasks =
let
common =
{ config
, ...
}: {
preset = {
nix.enable = true;

github.ci = {
enable = config.actionRun.facts != { };
inherit repository;
remote = config.preset.github.lib.readRepository ciInputName null;
revision = config.preset.github.lib.readRevision ciInputName null;
};
};

nomad.driver = "exec";
};
};

nomad.driver = "exec";
};

mkBulkJobsTask = jobsAttrs: { config
, lib
, ...
}: {
imports = [ common ];

mkBulkJobsTask = jobsAttrs: {
config,
lib,
...
}: {
imports = [common];
command.text = config.preset.github.status.lib.reportBulk {
bulk.text = ''
nix eval .#outputs.hydraJobs --apply __attrNames --json |
nix-systems -i |
jq 'with_entries(select(.value))' # filter out systems that we cannot build for
'';
each.text = ''nix build -L .#hydraJobs."$1".${jobsAttrs}'';
skippedDescription = lib.escapeShellArg "No nix builder available for this system";
};

command.text = config.preset.github.status.lib.reportBulk {
bulk.text = ''
nix eval .#outputs.hydraJobs --apply __attrNames --json |
nix-systems -i |
jq 'with_entries(select(.value))' # filter out systems that we cannot build for
env.NIX_CONFIG = ''
# `kvm` for NixOS tests
# `benchmark` for benchmarks
extra-system-features = kvm benchmark
# bigger timeouts (900 by default on cicero) needed for some derivations (especially on darwin)
max-silent-time = 1800
'';
each.text = ''nix build -L .#hydraJobs."$1"."${jobsAttrs}"'';
skippedDescription = lib.escapeShellArg "No nix builder available for this system";
};

env.NIX_CONFIG = ''
# `kvm` for NixOS tests
# `benchmark` for benchmarks
extra-system-features = kvm benchmark
# bigger timeouts (900 by default on cicero) needed for some derivations (especially on darwin)
max-silent-time = 1800
'';

memory = 1024 * 32;
nomad.resources.cpu = 10000;
};
in
memory = 1024 * 32;
nomad.resources.cpu = 10000;
};
in
{
"ci/pr/required" = mkBulkJobsTask "pr.required";
"ci/pr/nonrequired" = mkBulkJobsTask "pr.nonrequired";
"ci/push/required" = mkBulkJobsTask "required";

"ci/cardano-deployment" = {lib, ...} @ args: {
imports = [common];
"ci/cardano-deployment" = { lib, ... } @ args: {
imports = [ common ];
command.text = ''
nix build -L .#hydraJobs.cardano-deployment
'';
memory = 1024 * 16;
nomad.resources.cpu = 10000;
};

"ci/push" = {lib, ...} @ args: {
imports = [common];
after = ["ci/push/required" "ci/cardano-deployment"];
"ci/push" = { lib, ... } @ args: {
imports = [ common ];
after = [ "ci/push/required" "ci/cardano-deployment" ];
};

"ci/pr" = {lib, ...} @ args: {
imports = [common];
after = ["ci/pr/required" "ci/pr/nonrequired" "ci/cardano-deployment"];
"ci/pr" = { lib, ... } @ args: {
imports = [ common ];
after = [ "ci/pr/required" "ci/pr/nonrequired" "ci/cardano-deployment" ];
};
};

actions = {
"cardano-node/ci/push" = {
task = "ci/push";
io = ''
#lib.io.github_push
actions =
let
prIo = ''
#lib.io.github_pr
#input: "${ciInputName}"
#repo: "${repository}"
#branch: "master|staging|trying"
'';
};

"cardano-node/ci/pr" = {
task = "ci/pr";
io = ''
#lib.io.github_pr
pushIo = ''
#lib.io.github_push
#input: "${ciInputName}"
#repo: "${repository}"
#branch: "master|staging|trying"
'';
in
{

"cardano-node/ci/push/required" = {
task = "ci/push/required";
io = pushIo;
};
"cardano-node/ci/push/cardano-deployment" = {
task = "ci/cardano-deployment";
io = pushIo;
};

"cardano-node/ci/pr/required" = {
task = "ci/pr/required";
io = prIo;
};
"cardano-node/ci/pr/nonrequired" = {
task = "ci/pr/nonrequired";
io = prIo;
};
"cardano-node/ci/pr/cardano-deployment" = {
task = "ci/cardano-deployment";
io = prIo;
};
};
};
}

0 comments on commit a908988

Please sign in to comment.