diff options
| -rw-r--r-- | src/Command/Run.hs | 13 | ||||
| -rw-r--r-- | test/asset/run/dependencies.yaml | 55 | ||||
| -rw-r--r-- | test/script/run.et | 55 | 
3 files changed, 121 insertions, 2 deletions
| diff --git a/src/Command/Run.hs b/src/Command/Run.hs index 9652529..ca6d275 100644 --- a/src/Command/Run.hs +++ b/src/Command/Run.hs @@ -150,8 +150,17 @@ argumentJobSource names = do  refJobSource :: [ JobRef ] -> CommandExec JobSource  refJobSource [] = emptyJobSource  refJobSource refs = do -    jobs <- cmdEvalWith id $ mapM evalJobReference refs -    oneshotJobSource . map (JobSet Nothing . Right . (: [])) $ jobs +    jobs <- foldl' addJobToList [] <$> cmdEvalWith id (mapM evalJobReference refs) +    oneshotJobSource . map (JobSet Nothing . Right . reverse) $ jobs +  where +    deriveSetId :: Job -> [ JobIdPart ] +    deriveSetId job = let JobId parts = jobId job in init parts + +    addJobToList :: [[ Job ]] -> Job -> [[ Job ]] +    addJobToList (js@(j : _) : rest) job +        | deriveSetId j == deriveSetId job = (job : js) : rest +        | otherwise                        = js : addJobToList rest job +    addJobToList _ job                     = [[ job ]]  loadJobSetFromRoot :: (MonadIO m, MonadFail m) => JobRoot -> Commit -> m DeclaredJobSet  loadJobSetFromRoot root commit = case root of diff --git a/test/asset/run/dependencies.yaml b/test/asset/run/dependencies.yaml new file mode 100644 index 0000000..7452b5a --- /dev/null +++ b/test/asset/run/dependencies.yaml @@ -0,0 +1,55 @@ +job first: +  shell: +    - touch x + +  artifact out: +    path: x + + +job second: +  uses: +    - first.out + +  shell: +    - mv x y + +  artifact out: +    path: y + + +job third: +  uses: +    - first.out + +  shell: +    - mv x z + +  artifact out: +    path: z + + +job fourth: +  uses: +    - second.out + +  shell: +    - mv y w + +  artifact out: +    path: w + + +job fifth: +    uses: +      - third.out +      - fourth.out + +    shell: +      - mv z z2 +      - mv w w2 + +    artifact out1: +      path: z2 + +    artifact out2: +      path: w2 diff --git a/test/script/run.et b/test/script/run.et index b6dc1b0..5531707 100644 --- a/test/script/run.et +++ b/test/script/run.et @@ -228,3 +228,58 @@ test RunExplicitJob:              cat list              rm list          expect /c d/ from s + + +test RunExplicitDependentJob: +    node n +    shell on n as git_init: +        mkdir -p main +        git -C main -c init.defaultBranch=master init -q +        cp "${scripts.path}/dependencies.yaml" main/minici.yaml +        git -C main add minici.yaml +        git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + +        mkdir -p main/subdir + +        touch main/subdir/a +        git -C main add subdir +        git -C main -c user.name=test -c user.email=test commit -q -m 'commit' +        git -C main rev-parse HEAD^{commit} +        git -C main rev-parse HEAD^{tree} + +        touch main/subdir/b +        git -C main add subdir +        git -C main -c user.name=test -c user.email=test commit -q -m 'commit' +        git -C main rev-parse HEAD^{tree} + +        rm main/subdir/a +        rm main/subdir/b +        touch main/subdir/c +        git -C main add subdir +        git -C main -c user.name=test -c user.email=test commit -q -m 'commit' +        git -C main rev-parse HEAD^{tree} + +        touch main/subdir/d +        git -C main add subdir +        git -C main -c user.name=test -c user.email=test commit -q -m 'commit' +        git -C main rev-parse HEAD^{tree} + +    expect /([0-9a-f]+)/ from git_init capture c1 +    expect /([0-9a-f]+)/ from git_init capture t1 +    expect /([0-9a-f]+)/ from git_init capture t2 +    expect /([0-9a-f]+)/ from git_init capture t3 +    expect /([0-9a-f]+)/ from git_init capture t4 + +    local: +        spawn on n as p args [ "./main", "run", "$c1.first", "$t2.first", "$t3.second", "$c1.fifth", "$c1.fourth", "$c1.third", "$c1.second" ] +        expect_success from p of "$t1.first" +        expect_success from p of "$t1.second" +        expect_success from p of "$t1.third" +        expect_success from p of "$t1.fourth" +        expect_success from p of "$t1.fifth" +        expect_success from p of "$t2.first" +        expect from p /job-finish $t3.second error/ + +        flush from p matching /note .*/ +        expect /(.*)/ from p capture done +        guard (done == "run-finish") |