summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Eval.hs18
-rw-r--r--test/asset/run/many_repos.yaml46
-rw-r--r--test/script/run.et58
3 files changed, 109 insertions, 13 deletions
diff --git a/src/Eval.hs b/src/Eval.hs
index 572dad2..7a5bad3 100644
--- a/src/Eval.hs
+++ b/src/Eval.hs
@@ -65,20 +65,24 @@ isDefaultRepoMissingInId djob
collectOtherRepos :: DeclaredJobSet -> DeclaredJob -> Eval [ ( Maybe ( RepoName, Maybe Text ), FilePath ) ]
collectOtherRepos dset decl = do
- let dependencies = map fst $ jobUses decl
+ jobs <- either (throwError . OtherEvalError . T.pack) return $ jobsetJobsEither dset
+ let gatherDependencies seen (d : ds)
+ | d `elem` seen = gatherDependencies seen ds
+ | Just job <- find ((d ==) . jobName) jobs
+ = gatherDependencies (d : seen) (map fst (jobUses job) ++ ds)
+ | otherwise = gatherDependencies (d : seen) ds
+ gatherDependencies seen [] = seen
+
+ let dependencies = gatherDependencies [] [ jobName decl ]
dependencyRepos <- forM dependencies $ \name -> do
- jobs <- either (throwError . OtherEvalError . T.pack) return $ jobsetJobsEither dset
job <- maybe (throwError $ OtherEvalError $ "job ‘" <> textJobName name <> "’ not found") return . find ((name ==) . jobName) $ jobs
return $ jobCheckout job
missingDefault <- isDefaultRepoMissingInId decl
let checkouts =
- (if missingDefault then id else (filter (isJust . jcRepo))) $
- concat
- [ jobCheckout decl
- , concat dependencyRepos
- ]
+ (if missingDefault then id else filter (isJust . jcRepo)) $
+ concat dependencyRepos
let commonSubdir reporev = joinPath $ foldr1 commonPrefix $
map (maybe [] splitDirectories . jcSubtree) . filter ((reporev ==) . jcRepo) $ checkouts
let canonicalRepoOrder = Nothing : maybe [] (map (Just . repoName) . configRepos) (jobsetConfig dset)
diff --git a/test/asset/run/many_repos.yaml b/test/asset/run/many_repos.yaml
index ebf07d8..0839ba6 100644
--- a/test/asset/run/many_repos.yaml
+++ b/test/asset/run/many_repos.yaml
@@ -2,6 +2,7 @@ repo r1:
repo r2:
repo r3:
repo r4:
+repo r5:
job first:
checkout:
@@ -49,6 +50,51 @@ job first_manual_revision:
path: some_file
+job second:
+ checkout:
+ - repo: r2
+ dest: d2
+ - repo: r5
+ dest: d5
+ - repo: r3
+ dest: d3
+
+ shell:
+ - touch second_file
+
+ artifact out:
+ path: second_file
+
+
job dependent:
uses:
- first.out
+
+ shell:
+ - mv some_file some_other_file
+
+ artifact out:
+ path: some_other_file
+
+
+job transitive:
+ uses:
+ - dependent.out
+
+ artifact out:
+ path: some_other_file
+
+
+job combined:
+ uses:
+ - first.out
+ - second.out
+
+ artifact out:
+ path: second_file
+
+
+job combined_transitive:
+ uses:
+ - combined.out
+ - transitive.out
diff --git a/test/script/run.et b/test/script/run.et
index 83104a0..99cce0b 100644
--- a/test/script/run.et
+++ b/test/script/run.et
@@ -461,6 +461,15 @@ test RunWithManyRepos:
git -C dir_r4 rev-parse HEAD
git -C dir_r4 rev-parse HEAD^{tree}
+ mkdir -p dir_r5
+ git -C dir_r5 -c init.defaultBranch=master init -q
+ git -C dir_r5 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'
+ touch dir_r5/file_r5
+ git -C dir_r5 add file_r5
+ git -C dir_r5 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r5'
+ git -C dir_r5 rev-parse HEAD
+ git -C dir_r5 rev-parse HEAD^{tree}
+
expect /([0-9a-f]+)/ from git_init capture mc
expect /([0-9a-f]+)/ from git_init capture mt
expect /([0-9a-f]+)/ from git_init capture r1c
@@ -471,41 +480,78 @@ test RunWithManyRepos:
expect /([0-9a-f]+)/ from git_init capture r3t
expect /([0-9a-f]+)/ from git_init capture r4c
expect /([0-9a-f]+)/ from git_init capture r4t
+ expect /([0-9a-f]+)/ from git_init capture r5c
+ expect /([0-9a-f]+)/ from git_init capture r5t
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "first" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "first" ]
expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
expect /(.*)/ from p capture done
guard (done == "run-finish")
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "$mc.first.$r1c.$r2t.$r3c.$r4t" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "$mc.first.$r1c.$r2t.$r3c.$r4t" ]
expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
expect /(.*)/ from p capture done
guard (done == "run-finish")
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "first_manual_revision" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "first_manual_revision" ]
expect_success from p of "$mt.first_manual_revision.$r1t.$r2t.$r4t"
expect /(.*)/ from p capture done
guard (done == "run-finish")
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "$mc.first_manual_revision.$r1c.$r2t.$r4t" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "$mc.first_manual_revision.$r1c.$r2t.$r4t" ]
expect_success from p of "$mt.first_manual_revision.$r1t.$r2t.$r4t"
expect /(.*)/ from p capture done
guard (done == "run-finish")
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "dependent" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "dependent" ]
+ expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.dependent.$r1t.$r2t.$r3t.$r4t"
+ expect /(.*)/ from p capture done
+ guard (done == "run-finish")
+
+ local:
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "$mc.dependent.$r1c.$r2t.$r3c.$r4t" ]
+ expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.dependent.$r1t.$r2t.$r3t.$r4t"
+ expect /(.*)/ from p capture done
+ guard (done == "run-finish")
+
+ local:
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "transitive" ]
+ expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.dependent.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.transitive.$r1t.$r2t.$r3t.$r4t"
+ expect /(.*)/ from p capture done
+ guard (done == "run-finish")
+
+ local:
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "$mc.transitive.$r1c.$r2t.$r3c.$r4t" ]
expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
expect_success from p of "$mt.dependent.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.transitive.$r1t.$r2t.$r3t.$r4t"
+ expect /(.*)/ from p capture done
+ guard (done == "run-finish")
+
+ local:
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "combined" ]
+ expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.second.$r2t.$r3t.$r5t"
+ expect_success from p of "$mt.combined.$r1t.$r2t.$r3t.$r4t.$r5t"
expect /(.*)/ from p capture done
guard (done == "run-finish")
local:
- spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "$mc.dependent.$r1c.$r2t.$r3c.$r4t" ]
+ spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "--repo=r5:./dir_r5", "./main", "run", "--rerun-all", "combined_transitive" ]
expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.second.$r2t.$r3t.$r5t"
expect_success from p of "$mt.dependent.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.transitive.$r1t.$r2t.$r3t.$r4t"
+ expect_success from p of "$mt.combined.$r1t.$r2t.$r3t.$r4t.$r5t"
+ expect_success from p of "$mt.combined_transitive.$r1t.$r2t.$r3t.$r4t.$r5t"
expect /(.*)/ from p capture done
guard (done == "run-finish")