mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2026-06-19 08:39:26 +02:00
fix: pipelines can have either trigger or script
They canno thave both, so here I add assertions support and use them to avoid this case.
This commit is contained in:
parent
097f775cff
commit
70dc878112
8 changed files with 107 additions and 19 deletions
|
|
@ -2,9 +2,10 @@
|
|||
lib,
|
||||
cilib,
|
||||
jobSubmodule,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkOption types filterAttrs mergeAttrsList mapAttrs mkRenamedOptionModule literalExpression;
|
||||
inherit (lib) mkOption types filterAttrs mergeAttrsList mapAttrs mkRenamedOptionModule literalExpression attrValues;
|
||||
inherit (cilib.helpers) filterUnset unset mkUnsetOption toYaml toYamlPretty eitherWithSubOptions;
|
||||
|
||||
pipelineConfigSubmodule = {rootConfig, ...}: {
|
||||
|
|
@ -153,7 +154,7 @@
|
|||
in {
|
||||
_file = ./pipeline.nix;
|
||||
# from https://docs.gitlab.com/ci/yaml/#default
|
||||
imports = builtins.map (val: mkRenamedOptionModule [val] ["default" val]) [
|
||||
imports = [(pkgs.path + /nixos/modules/misc/assertions.nix)] ++ builtins.map (val: mkRenamedOptionModule [val] ["default" val]) [
|
||||
"after_script"
|
||||
"artifacts"
|
||||
"before_script"
|
||||
|
|
@ -211,16 +212,20 @@
|
|||
// gitlabOptions;
|
||||
config = let
|
||||
attrsToKeep = builtins.attrNames gitlabOptions;
|
||||
jobs = config.jobs;
|
||||
# Propagate job assertions up to pipeline level
|
||||
jobAssertions = lib.concatLists (map (job: job.assertions) (attrValues jobs));
|
||||
in {
|
||||
assertions = jobAssertions;
|
||||
finalConfig =
|
||||
(filterUnset (filterAttrs (n: _v: builtins.elem n attrsToKeep) config))
|
||||
// mapAttrs (_name: value: value.finalConfig) config.jobs;
|
||||
// mapAttrs (_name: value: value.finalConfig) jobs;
|
||||
packages =
|
||||
{
|
||||
"gitlab-ci:pipeline:${name}" = toYaml "gitlab-ci-config.json" config.finalConfig;
|
||||
"gitlab-ci:pipeline:${name}:pretty" = toYamlPretty "gitlab-ci-config.yml" config.finalConfig;
|
||||
}
|
||||
// mergeAttrsList (map (job: job.packages) (builtins.attrValues config.jobs));
|
||||
// mergeAttrsList (map (job: job.packages) (builtins.attrValues jobs));
|
||||
};
|
||||
};
|
||||
in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue