From 00e5bc0f9874eb9f929e917ba44bbd7b6f2ca4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 13 Nov 2025 23:23:08 +0100 Subject: Do not require recipe and empty checkout in job definition --- src/Config.hs | 13 ++++++++----- src/Job.hs | 2 +- src/Job/Types.hs | 2 +- test/asset/publish/from_dependency.yaml | 5 ----- 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 -- cgit v1.2.3