Commit c0d05db8 authored by Valentin Reis's avatar Valentin Reis
Browse files

fix the artifact logic.

parent 54ea6949
Pipeline #5883 passed with stages
in 1 minute and 45 seconds
...@@ -139,10 +139,10 @@ instance Default ArgsRemote where ...@@ -139,10 +139,10 @@ instance Default ArgsRemote where
targets :: [Text] targets :: [Text]
targets = mapMaybe toTarget nixStatic targets = mapMaybe toTarget nixStatic
where where
toTarget (Target t) = Just t toTarget (Target t) = Just t
toTarget (SimpleTarget t) = Just t toTarget (SimpleTarget t) = Just t
toTarget (Both t) = Just t toTarget (Both t) = Just t
toTarget _ = Nothing toTarget _ = Nothing
sources :: [Text] sources :: [Text]
sources = mapMaybe toSrc nixStatic sources = mapMaybe toSrc nixStatic
...@@ -175,7 +175,7 @@ nixStatic = src <> both <> simpletarget <> target ...@@ -175,7 +175,7 @@ nixStatic = src <> both <> simpletarget <> target
, "openmc" , "openmc"
, "argonix" , "argonix"
] ]
simpletarget = SimpleTarget <$> ["numabench-check" , "excit-check"] simpletarget = SimpleTarget <$> ["numabench-check", "excit-check"]
target = target =
Target Target
<$> [ "powerexpe" <$> [ "powerexpe"
...@@ -317,7 +317,7 @@ shellVerbose verbosity s = do ...@@ -317,7 +317,7 @@ shellVerbose verbosity s = do
readProcessVerbose :: Verbosity -> Text -> [Text] -> [(Text, Text)] -> IO Text readProcessVerbose :: Verbosity -> Text -> [Text] -> [(Text, Text)] -> IO Text
readProcessVerbose verbosity name arguments envVars = do readProcessVerbose verbosity name arguments envVars = do
putVerbose verbosity $ name <> mconcat (intersperse " " arguments) putVerbose verbosity $ name <> " " <> mconcat (intersperse " " arguments)
head head
. T.lines . T.lines
. toS . toS
...@@ -332,7 +332,7 @@ readProcessVerbose verbosity name arguments envVars = do ...@@ -332,7 +332,7 @@ readProcessVerbose verbosity name arguments envVars = do
runProcessVerbose :: Verbosity -> Text -> [Text] -> [(Text, Text)] -> IO () runProcessVerbose :: Verbosity -> Text -> [Text] -> [(Text, Text)] -> IO ()
runProcessVerbose a b c d = void $ readProcessVerbose a b c d runProcessVerbose a b c d = void $ readProcessVerbose a b c d
setupSystem :: Text -> ArgsCommon -> IO ([(Text, Text)],Text) setupSystem :: Text -> ArgsCommon -> IO ([(Text, Text)], Text)
setupSystem target sa = do setupSystem target sa = do
sVerbose "sudo rm -rf result" >>= \case sVerbose "sudo rm -rf result" >>= \case
...@@ -347,12 +347,10 @@ setupSystem target sa = do ...@@ -347,12 +347,10 @@ setupSystem target sa = do
["-d", "/tmp/deletable-nix-cache-XXXX"] ["-d", "/tmp/deletable-nix-cache-XXXX"]
[] []
varTMPDIR <- rpVerbose "mktemp" varTMPDIR <- rpVerbose "mktemp" ["-d", "/tmp/tmpdir-XXXX"] []
["-d", "/tmp/tmpdir-XXXX"]
[]
sVerbose $ "chmod 777 " <> varTMPDIR sVerbose $ "chmod 777 " <> varTMPDIR
passVars <- getVars ["PATH", "NIX_PATH", "NIX_SSL_CERT_FILE"] passVars <- getVars ["PATH", "NIX_PATH", "NIX_SSL_CERT_FILE"]
let envVars = let envVars =
[("XDG_CACHE_HOME", varXDG_CACHE_HOME), ("TMPDIR", varTMPDIR)] [("XDG_CACHE_HOME", varXDG_CACHE_HOME), ("TMPDIR", varTMPDIR)]
...@@ -360,7 +358,7 @@ setupSystem target sa = do ...@@ -360,7 +358,7 @@ setupSystem target sa = do
when (isTarget target) $ setupNodeOs envVars when (isTarget target) $ setupNodeOs envVars
return (envVars,varXDG_CACHE_HOME) return (envVars, varXDG_CACHE_HOME)
where where
getVars :: [Text] -> IO [(Text, Text)] getVars :: [Text] -> IO [(Text, Text)]
getVars vars = catMaybes <$> mapM maybeGet vars getVars vars = catMaybes <$> mapM maybeGet vars
...@@ -411,18 +409,24 @@ nixArguments target ArgsCommon {..} = ...@@ -411,18 +409,24 @@ nixArguments target ArgsCommon {..} =
wrap :: NixCommand -> Text -> ArgsCommon -> IO () wrap :: NixCommand -> Text -> ArgsCommon -> IO ()
wrap nixCommand target sa@ArgsCommon {..} = do wrap nixCommand target sa@ArgsCommon {..} = do
when (verbosity == Verbose) $ print sa when (verbosity == Verbose) $ print sa
(envVars,tmpXDGHOME) <- setupSystem target sa (envVars, tmpXDGHOME) <- setupSystem target sa
putText $ nixc <> " " <> T.unwords arglist putText $ nixc <> " " <> T.unwords arglist
case nixCommand of case nixCommand of
NixShell -> executeFile (toS nixc) True (fmap toS arglist) Nothing NixShell -> executeFile (toS nixc) True (fmap toS arglist) Nothing
NixBuild -> do NixBuild ->
_ <- P.runProcess P.runProcess
(P.setEnv (fmap (\(x, y) -> (toS x, toS y)) envVars) (P.setEnv (fmap (\(x, y) -> (toS x, toS y)) envVars)
(P.proc (toS nixc) $ fmap toS arglist) (P.proc (toS nixc) $ fmap toS arglist)
) )
runProcessVerbose verbosity "cp" ["-r", "/tmp/papa", "./result"] [] >>= \case
runProcessVerbose verbosity "cp" ["-r", toS tmpXDGHOME, "./nixtmpdir"] [] ExitSuccess -> copySuccess "/tmp/papa"
ExitFailure _ -> copyFailure $ toS tmpXDGHOME
where where
copySuccess source =
runProcessVerbose verbosity "cp" ["-r", source, "./result"] []
copyFailure source =
runProcessVerbose verbosity "cp" ["-r", source, "./nixtmpdir"] []
nixc = toCommand nixCommand nixc = toCommand nixCommand
arglist = arglist =
nixArguments target sa nixArguments target sa
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment