Skip to content

Commit

Permalink
run tullia tasks sequentially in CI actions
Browse files Browse the repository at this point in the history
to reduce load at one time
  • Loading branch information
dermetfan committed Sep 27, 2022
1 parent 7fc79ef commit e9e338b
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions nix/tullia.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
inherit (self.inputs.utils.lib) flattenTree;

ciInputName = "GitHub event";
in {
in rec {
tasks = let
common = {
config,
Expand Down Expand Up @@ -47,6 +47,26 @@ in {
(__foldl' lib.mergeAttrs {})
]
// { inherit (hydraJobs) build-version cardano-deployment; };

# returns attrset of tullia tasks named with the given prefix
# that run the corresponding task and depend on each other in the order given
taskSequence = taskNamePrefix: taskNames: lib.listToAttrs (
lib.imap0 (i: taskName: lib.nameValuePair
(taskNamePrefix + taskName)
({...}: {
imports = [tasks.${taskName}];
after = lib.optional (i > 0) (
taskNamePrefix + __elemAt taskNames (i - 1)
);
})
) taskNames
);

# returns attrset of tullia tasks that run the given hydra jobs sequentially in lexicographical order
hydraJobsTaskSequence = taskNamePrefix: hydraJobs: taskSequence taskNamePrefix (__attrNames hydraJobs);

ciPushTasks = hydraJobsTaskSequence "ci/push/" (systemHydraJobs self.outputs.hydraJobs);
ciPrTasks = hydraJobsTaskSequence "ci/pr/" (systemHydraJobs self.outputs.hydraJobsPr);
in
(__mapAttrs (jobName: _: (args: {
imports = [common];
Expand All @@ -65,15 +85,17 @@ in {
memory = 1024 * 8;
nomad.resources.cpu = 10000;
})) (systemHydraJobs self.outputs.hydraJobs))
// ciPushTasks
// ciPrTasks
// {
"ci/push" = {...}: {
imports = [common];
after = __attrNames (systemHydraJobs self.outputs.hydraJobs);
after = [(lib.last (__attrNames ciPushTasks))];
};

"ci/pr" = {...}: {
imports = [common];
after = __attrNames (systemHydraJobs self.outputs.hydraJobsPr);
after = [(lib.last (__attrNames ciPrTasks))];
};
};

Expand Down

0 comments on commit e9e338b

Please sign in to comment.