mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
Merge branch 'fix-job-patch' into 'main'
fix: weird jobs patching See merge request TECHNOFAB/nix-gitlab-ci!15
This commit is contained in:
commit
8a752f92cf
3 changed files with 45 additions and 14 deletions
|
|
@ -646,7 +646,7 @@ in rec {
|
|||
};
|
||||
depsDrv = cilib.mkJobDeps {
|
||||
key = name;
|
||||
job = config.finalConfig;
|
||||
inherit job;
|
||||
nixConfig = config.nix;
|
||||
};
|
||||
runnerDrv = cilib.mkJobRun {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{inputs, ...}: let
|
||||
inherit (inputs) cilib;
|
||||
inherit (inputs) cilib pkgs;
|
||||
in
|
||||
cilib.mkCI {
|
||||
config.soonix = {
|
||||
|
|
@ -58,9 +58,25 @@ in
|
|||
};
|
||||
};
|
||||
pipelines."default" = {
|
||||
stages = ["test" "build" "deploy"];
|
||||
stages = ["check" "test" "build" "deploy"];
|
||||
variables = {
|
||||
EXAMPLE = "empty";
|
||||
CURL = toString pkgs.curl;
|
||||
};
|
||||
jobs = {
|
||||
"check" = {
|
||||
stage = "check";
|
||||
script = [
|
||||
"set -euo pipefail"
|
||||
"echo EXAMPLE=$EXAMPLE CURL=$CURL SAMPLE=$SAMPLE HELLO=$HELLO"
|
||||
];
|
||||
variables = {
|
||||
SAMPLE = "working";
|
||||
HELLO = toString pkgs.hello;
|
||||
};
|
||||
};
|
||||
"test" = {
|
||||
nix.deps = with pkgs; [coreutils nix];
|
||||
stage = "test";
|
||||
script = [
|
||||
"nix run .#tests -- --junit=junit.xml"
|
||||
|
|
@ -73,6 +89,7 @@ in
|
|||
};
|
||||
"docs" = {
|
||||
stage = "build";
|
||||
nix.deps = with pkgs; [coreutils nix];
|
||||
script = [
|
||||
# sh
|
||||
''
|
||||
|
|
|
|||
|
|
@ -10,9 +10,17 @@
|
|||
simplePipeline = cilib.mkCI {
|
||||
pipelines."test" = {
|
||||
stages = ["test"];
|
||||
variables = {
|
||||
EXAMPLE = "empty";
|
||||
CURL = toString pkgs.curl;
|
||||
};
|
||||
jobs."test" = {
|
||||
stage = "test";
|
||||
script = ["echo hello world"];
|
||||
variables = {
|
||||
SAMPLE = "working";
|
||||
HELLO = toString pkgs.hello;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -30,21 +38,29 @@
|
|||
(cilib.mkCI {}).packages;
|
||||
}
|
||||
{
|
||||
name = "simple pipeline";
|
||||
name = "simple pipeline final config";
|
||||
expected = {
|
||||
stages = [".pre" "test" ".post"];
|
||||
variables = {
|
||||
EXAMPLE = "empty";
|
||||
CURL = toString pkgs.curl;
|
||||
};
|
||||
"test" = {
|
||||
image = "$NIX_CI_IMAGE";
|
||||
stage = "test";
|
||||
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
||||
script = ["echo hello world"];
|
||||
after_script = ["finalize_nix_ci"];
|
||||
variables = {
|
||||
SAMPLE = "working";
|
||||
#HELLO = toString pkgs.hello;
|
||||
};
|
||||
};
|
||||
};
|
||||
actual = simplePipeline.pipelines."test".finalConfig;
|
||||
}
|
||||
{
|
||||
name = "simple pipeline yaml";
|
||||
name = "simple pipeline json";
|
||||
type = "script";
|
||||
script = let
|
||||
package = simplePipeline.packages."gitlab-ci:pipeline:test";
|
||||
|
|
@ -56,25 +72,23 @@
|
|||
assert_file_contains ${package} 'gitlab-ci:pipeline:test:job-deps:test'
|
||||
assert_file_contains ${package} 'finalize_nix_ci'
|
||||
assert_file_contains ${package} 'echo hello world'
|
||||
assert_file_contains ${package} '"EXAMPLE":"empty"'
|
||||
assert_file_contains ${package} '"SAMPLE":"working"'
|
||||
assert_file_contains ${package} '"CURL":"/nix/store/.*-curl-.*"'
|
||||
'';
|
||||
}
|
||||
{
|
||||
name = "dont fail on store paths";
|
||||
name = "simple pipeline deps drv";
|
||||
type = "script";
|
||||
script = let
|
||||
package =
|
||||
(cilib.mkCI {
|
||||
pipelines."test" = {
|
||||
variables.EXAMPLE = "${pkgs.hello}";
|
||||
};
|
||||
}).packages."gitlab-ci:pipeline:test";
|
||||
package = simplePipeline.packages."gitlab-ci:pipeline:test:job-deps:test";
|
||||
in
|
||||
# sh
|
||||
''
|
||||
${ntlib.helpers.path [pkgs.gnugrep]}
|
||||
${ntlib.helpers.scriptHelpers}
|
||||
assert_file_contains ${package} '[".pre",".post"]'
|
||||
assert_file_contains ${package} '"EXAMPLE":"/nix/store/.*-hello-.*"'
|
||||
assert_file_contains ${package} ':$PATH'
|
||||
assert_file_contains ${package} 'HELLO="/nix/store/.*-hello-.*"'
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue