Skip to content

Commit

Permalink
Merge pull request #106 from hercules-ci/fix-when-dayOfWeek
Browse files Browse the repository at this point in the history
flakeModule: Fix dayOfWeek type
  • Loading branch information
roberth authored Dec 2, 2022
2 parents db4da42 + 7ec4a02 commit 392a077
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
12 changes: 9 additions & 3 deletions flake-dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ top@{ withSystem, lib, inputs, config, ... }: {
systems = [ "x86_64-linux" "aarch64-linux" ];
flake = {
# These aren't system dependent so we define them once. x86_64-linux is unrelated.
checks.x86_64-linux.evaluation-checks =
(import ./flake-modules/derivationTree-type.nix { inherit lib; }).tests
inputs.nixpkgs.legacyPackages.x86_64-linux.emptyFile;
checks.x86_64-linux = {
evaluation-checks =
(import ./flake-modules/derivationTree-type.nix { inherit lib; }).tests
inputs.nixpkgs.legacyPackages.x86_64-linux.emptyFile;

evaluation-herculesCI =
let it = (import ./flake-modules/herculesCI-eval-test.nix { inherit inputs; });
in it.tests inputs.nixpkgs.legacyPackages.x86_64-linux.emptyFile // { debug = it; };
};

tests = withSystem "x86_64-linux" ({ hci-effects, pkgs, ... }: {
git-crypt-hook = pkgs.callPackage ./effects/git-crypt-hook/test.nix { };
Expand Down
55 changes: 55 additions & 0 deletions flake-modules/herculesCI-eval-test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{ inputs }:
rec {
inherit (inputs) flake-parts;

example1 =
flake-parts.lib.mkFlake { self = { }; }
({ ... }: {
imports = [
../flake-module.nix
];
herculesCI.onSchedule.scheduledJob1.when = {
dayOfMonth = [ 1 3 5 7 31 ];
dayOfWeek = [ "Mon" "Wed" "Fri" ];
hour = [ 0 1 23 ];
minute = 32;
};
herculesCI.onSchedule.scheduledJob2.when = {
dayOfMonth = 31;
dayOfWeek = "Fri";
hour = 23;
minute = 59;
};
herculesCI.onSchedule.scheduledJob3 = { };
});

tests = ok:

assert (example1.herculesCI { }).onSchedule.scheduledJob1.when ==
{
dayOfMonth = [ 1 3 5 7 31 ];
dayOfWeek = [ "Mon" "Wed" "Fri" ];
hour = [ 0 1 23 ];
minute = 32;
};

assert (example1.herculesCI { }).onSchedule.scheduledJob2.when ==
{
dayOfMonth = [ 31 ];
dayOfWeek = [ "Fri" ];
hour = [ 23 ];
minute = 59;
};

assert (example1.herculesCI { }).onSchedule.scheduledJob3.when ==
{
dayOfMonth = null;
dayOfWeek = null;
hour = null;
minute = null;
};

ok;

}

2 changes: 1 addition & 1 deletion flake-modules/types/when.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let
'';
};
dayOfWeek = mkOption {
type = types.nullOr (types.enum [ "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun" ]);
type = types.nullOr (coercedToList (types.enum [ "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun" ]));
default = null;
description = ''
An optional list of week days during which to create a job.
Expand Down

0 comments on commit 392a077

Please sign in to comment.