From c11cf4ea1822b280be7873c61c004d23627b0349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 26 Nov 2025 21:38:01 +0100 Subject: Well-defined order of dependencies in job ID --- src/Eval.hs | 4 ++- test/asset/run/many_repos.yaml | 23 +++++++++++++++ test/script/run.et | 67 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 test/asset/run/many_repos.yaml diff --git a/src/Eval.hs b/src/Eval.hs index e98bb29..71c9b9f 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -81,7 +81,9 @@ collectOtherRepos dset decl = do ] let commonSubdir reporev = joinPath $ foldr1 commonPrefix $ map (maybe [] splitDirectories . jcSubtree) . filter ((reporev ==) . jcRepo) $ checkouts - return $ map (\r -> ( r, commonSubdir r )) . nub . map jcRepo $ checkouts + let canonicalRepoOrder = Nothing : maybe [] (map (Just . repoName) . configRepos) (jobsetConfig dset) + getCheckoutsForName rname = map (\r -> ( r, commonSubdir r )) $ nub $ filter ((rname ==) . fmap fst) $ map jcRepo checkouts + return $ concatMap getCheckoutsForName canonicalRepoOrder evalJob :: [ ( Maybe RepoName, Tree ) ] -> DeclaredJobSet -> DeclaredJob -> Eval ( Job, JobSetId ) diff --git a/test/asset/run/many_repos.yaml b/test/asset/run/many_repos.yaml new file mode 100644 index 0000000..63f8fa2 --- /dev/null +++ b/test/asset/run/many_repos.yaml @@ -0,0 +1,23 @@ +repo r1: +repo r2: +repo r3: +repo r4: + +job first: + checkout: + - repo: r1 + dest: d1 + - repo: r4 + dest: d4b + - repo: r3 + dest: d3 + - repo: r2 + dest: d2 + - repo: r4 + dest: d4 + + shell: + - touch some_file + + artifact out: + path: some_file diff --git a/test/script/run.et b/test/script/run.et index f33c2fa..9fbfd13 100644 --- a/test/script/run.et +++ b/test/script/run.et @@ -400,3 +400,70 @@ test RunRerun: flush from p matching /note .*/ expect /(.*)/ from p capture done guard (done == "run-finish") + + +test RunWithManyRepos: + node n + shell on n as git_init: + mkdir -p main + git -C main -c init.defaultBranch=master init -q + cp "${scripts.path}/many_repos.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' + git -C main rev-parse HEAD + git -C main rev-parse HEAD^{tree} + + mkdir -p dir_r1 + git -C dir_r1 -c init.defaultBranch=master init -q + git -C dir_r1 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch dir_r1/file_r1 + git -C dir_r1 add file_r1 + git -C dir_r1 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r1' + git -C dir_r1 rev-parse HEAD + git -C dir_r1 rev-parse HEAD^{tree} + + mkdir -p dir_r2 + git -C dir_r2 -c init.defaultBranch=master init -q + git -C dir_r2 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch dir_r2/file_r2 + git -C dir_r2 add file_r2 + git -C dir_r2 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r2' + git -C dir_r2 rev-parse HEAD + git -C dir_r2 rev-parse HEAD^{tree} + + mkdir -p dir_r3 + git -C dir_r3 -c init.defaultBranch=master init -q + git -C dir_r3 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch dir_r3/file_r3 + git -C dir_r3 add file_r3 + git -C dir_r3 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r3' + git -C dir_r3 rev-parse HEAD + git -C dir_r3 rev-parse HEAD^{tree} + + mkdir -p dir_r4 + git -C dir_r4 -c init.defaultBranch=master init -q + git -C dir_r4 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch dir_r4/file_r4 + git -C dir_r4 add file_r4 + git -C dir_r4 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r4' + git -C dir_r4 rev-parse HEAD + git -C dir_r4 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 + expect /([0-9a-f]+)/ from git_init capture r1t + expect /([0-9a-f]+)/ from git_init capture r2c + expect /([0-9a-f]+)/ from git_init capture r2t + expect /([0-9a-f]+)/ from git_init capture r3c + 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 + + 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" ] + expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t" + + 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" ] + expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t" -- cgit v1.2.3