diff options
| -rw-r--r-- | src/Job.hs | 12 | ||||
| -rw-r--r-- | test/asset/shell/minici.yaml | 28 | ||||
| -rw-r--r-- | test/script/shell.et | 51 |
3 files changed, 86 insertions, 5 deletions
@@ -388,6 +388,13 @@ prepareJob dir job inner = do subtree <- maybe return (getSubtree Nothing . makeRelative (treeSubdir tree)) mbsub $ tree checkoutAt subtree $ checkoutPath </> fromMaybe "" dest + liftIO $ forM_ (jobUses job) $ \( jid, aname ) -> do + modifyError (userError . T.unpack) $ do + wpath <- getArtifactWorkPath dir jid aname + let target = checkoutPath </> wpath + liftIO $ createDirectoryIfMissing True $ takeDirectory target + copyArtifact dir jid aname target + let jdir = dir </> jobStorageSubdir (jobId job) liftIO $ createDirectoryIfMissing True jdir inner checkoutPath @@ -420,11 +427,6 @@ copyArtifact storageDir jid aname tpath = do runJob :: Job -> [ ( ArtifactSpec Evaluated, ArtifactOutput) ] -> FilePath -> FilePath -> ExceptT (JobStatus JobOutput) IO JobOutput runJob job uses checkoutPath jdir = do - liftIO $ forM_ (filter ((`elem` jobUses job) . fst) uses) $ \( _, aout ) -> do - let target = checkoutPath </> aoutWorkPath aout - createDirectoryIfMissing True $ takeDirectory target - copyRecursive (aoutStorePath aout) target - bracket (liftIO $ openFile (jdir </> "log") WriteMode) (liftIO . hClose) $ \logs -> do forM_ (fromMaybe [] $ jobRecipe job) $ \ep -> do ( p, input ) <- case ep of diff --git a/test/asset/shell/minici.yaml b/test/asset/shell/minici.yaml new file mode 100644 index 0000000..b980161 --- /dev/null +++ b/test/asset/shell/minici.yaml @@ -0,0 +1,28 @@ +repo r1: +repo r2: + +job generate: + checkout: null + + shell: + - echo "content 1" > f1 + - mkdir -p dir + - echo "content 2" > dir/f2 + + artifact file: + path: f1 + + artifact dir: + path: dir + + +job combine: + checkout: + - repo: r1 + dest: d1 + - repo: r2 + dest: d2 + + uses: + - generate.file + - generate.dir diff --git a/test/script/shell.et b/test/script/shell.et new file mode 100644 index 0000000..c3a2282 --- /dev/null +++ b/test/script/shell.et @@ -0,0 +1,51 @@ +module shell + +import common + +asset scripts: + path: ../asset/shell + + +test ShellPrepare: + node n + shell on n as git_init: + 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^{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^{tree} + + expect /([0-9a-f]+)/ from git_init capture r1t + expect /([0-9a-f]+)/ from git_init capture r2t + + local: + spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r2:./dir_r2", "${scripts.path}/minici.yaml", "run", "generate" ] + expect /run-finish/ from p + + local: + spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r2:./dir_r2", "${scripts.path}/minici.yaml", "shell", "combine.$r1t.$r2t" ] + with p: + send "ls ." + expect /d1/ + expect /d2/ + expect /f1/ + expect /dir/ + with p: + send "ls d1" + expect /file_r1/ + with p: + send "ls d2" + expect /file_r2/ + with p: + send "ls dir" + expect /f2/ |