Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
argonix
Commits
0f7812dd
Commit
0f7812dd
authored
May 13, 2019
by
Valentin Reis
Browse files
adds `argonix test` target
parent
bc7b9efd
Pipeline
#7297
passed with stages
in 1 minute and 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Args.hs
View file @
0f7812dd
...
...
@@ -39,6 +39,7 @@ data ArgsCommon = ArgsCommon
,
verbosity
::
Verbosity
,
run
::
Maybe
Text
,
overrides
::
[(
Text
,
Text
)]
,
overrideAs
::
[(
Text
,
Text
)]
,
grafting
::
Grafting
,
sandboxing
::
Sandboxing
,
offline
::
Bool
...
...
@@ -50,8 +51,9 @@ data Grafting = Libnrm | NoGraft deriving (Show, Eq)
data
NixStaticInOut
=
Both
Text
|
Src
Text
|
SimpleTarget
Text
|
StringArg
Text
|
Target
Text
deriving
(
Eq
)
data
NixCommand
=
NixBuild
|
NixShell
data
NixCommand
=
NixBuild
|
NixShell
|
NixTest
instance
Default
ArgsCommon
where
def
=
ArgsCommon
...
...
@@ -59,6 +61,7 @@ instance Default ArgsCommon where
argopkgs
=
"<argopkgs>"
,
run
=
Nothing
,
overrides
=
[]
,
overrideAs
=
[]
,
grafting
=
NoGraft
,
sandboxing
=
NoSandbox
,
offline
=
False
...
...
@@ -115,6 +118,7 @@ commonParser = do
"Enable libnrm grafting to avoid rebuilding applications."
)
overrides
<-
catMaybes
<$>
ts
overrideAs
<-
catMaybes
<$>
tsA
run
<-
optional
$
strOption
(
long
"run"
<>
metavar
"COMMAND"
<>
help
"Command to run the environment instead of an interactive shell"
...
...
@@ -130,6 +134,18 @@ commonParser = do
(
toS
longform
<>
" source folder override."
)
)
pure
$
mapT
longform
parsed
tsA
::
Parser
[
Maybe
(
Text
,
Text
)]
tsA
=
traverse
optSrcA
stringArgs
optSrcA
::
Text
->
Parser
(
Maybe
(
Text
,
Text
))
optSrcA
longform
=
do
parsed
<-
optional
$
strOption
(
long
(
toS
longform
)
<>
metavar
"PATH"
<>
help
(
toS
longform
<>
" string argument."
)
)
pure
$
mapT
longform
parsed
mapT
::
Text
->
Maybe
Text
->
Maybe
(
Text
,
Text
)
mapT
longform
thePath
=
case
thePath
of
Nothing
->
Nothing
...
...
@@ -151,11 +167,17 @@ sources = mapMaybe toSrc nixStatic
toSrc
(
Both
t
)
=
Just
t
toSrc
_
=
Nothing
stringArgs
::
[
Text
]
stringArgs
=
mapMaybe
toSrc
nixStatic
where
toSrc
(
StringArg
t
)
=
Just
t
toSrc
_
=
Nothing
isTarget
::
Text
->
Bool
isTarget
x
=
Target
x
`
elem
`
nixStatic
nixStatic
::
[
NixStaticInOut
]
nixStatic
=
src
<>
both
<>
simpletarget
<>
target
nixStatic
=
src
<>
both
<>
simpletarget
<>
target
<>
stringA
where
src
=
[
Src
"experiments"
]
both
=
...
...
@@ -176,6 +198,7 @@ nixStatic = src <> both <> simpletarget <> target
,
"argonix"
]
simpletarget
=
SimpleTarget
<$>
[
"numabench-check"
,
"excit-check"
]
stringA
=
StringArg
<$>
[
"genericTestName"
]
target
=
Target
<$>
[
"powerexpe"
...
...
@@ -195,4 +218,5 @@ nixStatic = src <> both <> simpletarget <> target
,
"testLAMMPS"
,
"testQMCPack"
,
"testAll"
,
"testGeneric"
]
src/Nixwrap.hs
View file @
0f7812dd
...
...
@@ -21,7 +21,6 @@ import Protolude
import
qualified
Data.Text
as
T
(
lines
,
isInfixOf
,
unwords
)
import
Options.Applicative
import
System.Console.ANSI
...
...
@@ -80,18 +79,16 @@ main = SIO.hSetBuffering SIO.stdout SIO.NoBuffering
(
progDesc
"Enter an argo-compatible nix-shell"
)
)
<>
command
"remote-shell"
(
info
(
remotely
<$>
targetParser
<*>
commonParser
<*>
remoteParser
)
(
progDesc
"Enter an argo-compatible nix-shell on a remote machine with nix enabled"
)
"test"
(
info
(
wrap
NixTest
<$>
targetParser
<*>
commonParser
)
(
progDesc
"Enter an argo-compatible nix-shell"
)
)
<>
help
"Type of operation to run."
)
toCommand
::
NixCommand
->
Text
toCommand
NixBuild
=
"nix-build"
toCommand
NixTest
=
"nix-build"
toCommand
NixShell
=
"nix-shell"
targetParser
::
Parser
Text
...
...
@@ -195,9 +192,12 @@ setupSystem target sa = do
[(
"XDG_CACHE_HOME"
,
varXDG_CACHE_HOME
),
(
"TMPDIR"
,
varTMPDIR
)]
++
passVars
when
(
isTarget
target
)
$
setupNodeOs
envVars
nodeosVar
<-
if
isTarget
target
then
setupNodeOs
envVars
>>
return
[(
"ARGO_NODEOS_CONFIG"
,
"/tmp/argo_nodeos_config"
)]
else
return
[]
return
(
envVars
,
varTMPDIR
)
return
(
envVars
++
nodeosVar
,
varTMPDIR
)
where
getVars
::
[
Text
]
->
IO
[(
Text
,
Text
)]
getVars
vars
=
catMaybes
<$>
for
vars
maybeGet
...
...
@@ -248,6 +248,7 @@ nixArguments :: Text -> ArgsCommon -> [Text]
nixArguments
target
ArgsCommon
{
..
}
=
[
argopkgs
,
"-A"
,
target
]
++
concat
[
[
"--arg"
,
longform
<>
"-src"
,
p
]
|
(
longform
,
p
)
<-
overrides
]
++
concat
[
[
"--argstr"
,
longform
,
p
]
|
(
longform
,
p
)
<-
overrideAs
]
++
(
if
grafting
==
Libnrm
then
[
"--arg"
,
"graftLibnrm"
,
"true"
]
else
[]
)
++
[
"-o"
,
"/tmp/papa"
]
++
[
"--show-trace"
|
v
]
...
...
@@ -258,38 +259,43 @@ wrap :: NixCommand -> Text -> ArgsCommon -> IO ()
wrap
nixCommand
target
sa
@
ArgsCommon
{
..
}
=
do
when
(
verbosity
==
Verbose
)
$
print
sa
(
envVars
,
tmpDir
)
<-
setupSystem
target
sa
putText
$
nixc
<>
" "
<>
T
.
unwords
arglist
case
nixCommand
of
NixShell
->
executeFile
(
toS
nixc
)
True
(
fmap
toS
arglist
)
Nothing
NixShell
->
executeFile
(
toS
nixc
)
True
(
fmap
toS
arglist
)
(
Just
$
evC
envVars
)
NixTest
->
P
.
runProcess
(
P
.
setEnv
(
evC
envVars
)
(
P
.
proc
(
toS
nixc
)
$
fmap
toS
arglistTest
))
>>=
\
case
ExitSuccess
->
copySuccess
"/tmp/papa"
ExitFailure
_
->
copyFailure
(
toS
tmpDir
)
>>
die
"build failed."
NixBuild
->
P
.
runProcess
(
P
.
setEnv
(
fmap
(
\
(
x
,
y
)
->
(
toS
x
,
toS
y
))
envVars
)
(
P
.
proc
(
toS
nixc
)
$
fmap
toS
arglist
)
)
(
P
.
setEnv
(
evC
envVars
)
(
P
.
proc
(
toS
nixc
)
$
fmap
toS
arglist
))
>>=
\
case
ExitSuccess
->
copySuccess
"/tmp/papa"
ExitFailure
_
->
copyFailure
(
toS
tmpDir
)
>>
die
"build failed."
where
evC
=
fmap
(
\
(
x
,
y
)
->
(
toS
x
,
toS
y
))
copySuccess
source
=
do
runProcessVerbose
verbosity
"cp"
[
"--no-preserve=mode"
,
"-Hr"
,
source
,
"./result"
]
[]
runProcessVerbose
verbosity
"find"
[
"./result"
,
"-type"
,
"l"
,
"-delete"
]
[]
runProcessVerbose
verbosity
"chmod"
[
"-R"
,
"+w"
,
"./result"
]
[]
runProcessVerbose
verbosity
"cp"
[
"--no-preserve=mode"
,
"-Hr"
,
source
,
"./result"
]
[]
runProcessVerbose
verbosity
"find"
[
"./result"
,
"-type"
,
"l"
,
"-delete"
]
[]
runProcessVerbose
verbosity
"chmod"
[
"-R"
,
"+w"
,
"./result"
]
[]
copyFailure
source
=
do
runProcessVerbose
verbosity
"cp"
[
"--no-preserve=mode"
,
"-r"
,
source
,
"./nixtmpdir"
]
[]
runProcessVerbose
verbosity
"chmod"
[
"-R"
,
"+w"
,
"./nixtmpdir"
]
[]
runProcessVerbose
verbosity
"cp"
[
"--no-preserve=mode"
,
"-r"
,
source
,
"./nixtmpdir"
]
[]
runProcessVerbose
verbosity
"chmod"
[
"-R"
,
"+w"
,
"./nixtmpdir"
]
[]
nixc
=
toCommand
nixCommand
arglist
=
nixArguments
target
sa
++
[
"--allow-new-privileges"
,
"-K"
,
"--option"
,
"build-use-sandbox"
]
++
[
if
sandboxing
==
Sandbox
then
"true"
else
"false"
]
nixc
=
toCommand
nixCommand
arglist
=
nixArguments
target
sa
++
extraBuildArgs
remotely
::
Text
->
ArgsCommon
->
ArgsRemote
->
IO
()
remotely
_
_
_
=
putText
"unsupported in this version"
<>
undefined
arglistTest
=
nixArguments
"testGeneric"
sa
++
[
"--arg"
,
"genericTestName"
,
target
]
-- no sandbox use is possible. If sandbox paths were read only we could add:
{-, "--option"-}
{-, "build-use-sandbox"-}
{-, "--option"-}
{-, "extra-sandbox-paths"-}
{-, "/tmp/ /etc/argo/ /var/run/ /var/lock/"-}
extraBuildArgs
=
[
"--allow-new-privileges"
,
"-K"
,
"--option"
,
"build-use-sandbox"
]
++
[
if
sandboxing
==
Sandbox
then
"true"
else
"false"
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment