Skip to content

Commit

Permalink
fix(conform): simplifies configuration input
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Jun 1, 2022
1 parent ad34da4 commit c981459
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
14 changes: 13 additions & 1 deletion plugins/conform/mkConfig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ let
files = [ ./template.cue ];
output = ".conform.yaml";

# Expand out the data
test = {
commit = { };
license = { };
};

dataFinal = {
policies = (optional (data ? commit) { type = "commit"; spec = data.commit; }) ++
(optional (data ? license) { type = "license"; spec = data.license; });
};

# Generate the module
result = lib.mkTemplate {
inherit data files output;
inherit files output;
data = dataFinal;
};
in
{
Expand Down
69 changes: 30 additions & 39 deletions tests/conform/default.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
{ runTest }:
runTest "conform.mkConfig" ./expected.yml {
policies = [
{
type = "commit";
spec = {
header = {
length = 89;
imperative = true;
case = "lower";
invalidLastCharacters = ".";
};
gpg = {
required = false;
identity = {
gitHubOrganization = "some-organization";
};
};
conventional = {
types = [
"type"
];
scopes = [
"scope"
];
};
runTest "conform.mkConfig" ./expected.yml
{
commit = {
header = {
length = 89;
imperative = true;
case = "lower";
invalidLastCharacters = ".";
};
gpg = {
required = false;
identity = {
gitHubOrganization = "some-organization";
};
}

{
type = "license";
spec = {
skipPaths = [
".git/"
"build*/"
];
allowPrecedingComments = false;
};
}
];
};
conventional = {
types = [
"type"
];
scopes = [
"scope"
];
};
};
license = {
skipPaths = [
".git/"
"build*/"
];
allowPrecedingComments = false;
};
}

0 comments on commit c981459

Please sign in to comment.