summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-11-13 23:23:08 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-11-13 23:23:08 +0100
commit00e5bc0f9874eb9f929e917ba44bbd7b6f2ca4a8 (patch)
treefbfdb065ed90bbbf65dcbe3c41e9042d46ae15cf
parentd6ff11543a3897dd2b38ed121f958ef0050e272c (diff)
Do not require recipe and empty checkout in job definition
-rw-r--r--src/Config.hs13
-rw-r--r--src/Job.hs2
-rw-r--r--src/Job/Types.hs2
-rw-r--r--test/asset/publish/from_dependency.yaml5
4 files changed, 10 insertions, 12 deletions
diff --git a/src/Config.hs b/src/Config.hs
index d643f27..22bc89a 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -85,15 +85,18 @@ parseJob :: Text -> Node Pos -> Parser DeclaredJob
parseJob name node = flip (withMap "Job") node $ \j -> do
let jobName = JobName name
jobId = jobName
+ jobRecipe <- choice
+ [ fmap Just $ cabalJob =<< j .: "cabal"
+ , fmap Just $ shellJob =<< j .: "shell"
+ , return Nothing
+ ]
jobCheckout <- choice
[ parseSingleCheckout =<< j .: "checkout"
, parseMultipleCheckouts =<< j .: "checkout"
, withNull "no checkout" (return []) =<< j .: "checkout"
- , return [ JobCheckout Nothing Nothing Nothing ]
- ]
- jobRecipe <- choice
- [ cabalJob =<< j .: "cabal"
- , shellJob =<< j .: "shell"
+ , return $ if isJust jobRecipe
+ then [ JobCheckout Nothing Nothing Nothing ]
+ else []
]
jobArtifacts <- parseArtifacts j
jobUses <- maybe (return []) parseUses =<< j .:? "uses"
diff --git a/src/Job.hs b/src/Job.hs
index b40273f..1d4ade3 100644
--- a/src/Job.hs
+++ b/src/Job.hs
@@ -382,7 +382,7 @@ runJob job uses checkoutPath jdir = do
copyRecursive (aoutStorePath aout) target
bracket (liftIO $ openFile (jdir </> "log") WriteMode) (liftIO . hClose) $ \logs -> do
- forM_ (jobRecipe job) $ \p -> do
+ forM_ (fromMaybe [] $ jobRecipe job) $ \p -> do
(Just hin, _, _, hp) <- liftIO $ createProcess_ "" p
{ cwd = Just checkoutPath
, std_in = CreatePipe
diff --git a/src/Job/Types.hs b/src/Job/Types.hs
index d9fa08e..fd20e9a 100644
--- a/src/Job/Types.hs
+++ b/src/Job/Types.hs
@@ -18,7 +18,7 @@ data Job' d = Job
{ jobId :: JobId' d
, jobName :: JobName
, jobCheckout :: [ JobCheckout d ]
- , jobRecipe :: [ CreateProcess ]
+ , jobRecipe :: Maybe [ CreateProcess ]
, jobArtifacts :: [ ( ArtifactName, Pattern ) ]
, jobUses :: [ ArtifactSpec ]
, jobPublish :: [ JobPublish d ]
diff --git a/test/asset/publish/from_dependency.yaml b/test/asset/publish/from_dependency.yaml
index 40268fc..6bbfbf8 100644
--- a/test/asset/publish/from_dependency.yaml
+++ b/test/asset/publish/from_dependency.yaml
@@ -43,11 +43,6 @@ job gen:
job publish:
- shell:
- - "true"
-
- checkout:
-
publish:
- to: first
artifact: gen.x