Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
argotest
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Reis
argotest
Commits
ed8c2813
Commit
ed8c2813
authored
Feb 09, 2019
by
Valentin Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
argonix -> argotest, implement target_machine.
parent
e2aafd1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
2 deletions
+131
-2
.gitignore
.gitignore
+2
-0
argotest.hs
argotest.hs
+127
-0
default.nix
default.nix
+2
-2
No files found.
.gitignore
View file @
ed8c2813
.argo_nodeos_config_exit_message
.direnv
*/.direnv
_output
result
.shake
...
...
argo
nix
.hs
→
argo
test
.hs
View file @
ed8c2813
#!
/
usr
/
bin
/
env
nix
-
shell
#!
nix
-
shell
default
.
nix
-
i
runhaskell
-
A
executor
#!
nix
-
shell
default
.
nix
-
i
runhaskell
-
A
argotest
{-# language RecordWildCards #-}
{-# language TupleSections #-}
{-# language ApplicativeDo #-}
{-# language OverloadedStrings #-}
...
...
@@ -16,6 +15,9 @@ import Prelude hiding ( FilePath )
import
System.IO
(
withFile
)
import
Debug.Trace
import
Data.Text
(
unpack
,
pack
)
import
Filesystem.Path
(
(
</>
)
)
import
Control.Concurrent.Async
import
System.Console.ANSI
...
...
@@ -25,8 +27,8 @@ import System.Posix.Process
data
StackArgs
=
StackArgs
{
verbosity
::
Verbosity
,
targetMachine
::
Maybe
FilePath
,
run
::
Maybe
FilePath
,
targetMachine
::
Maybe
String
,
run
::
Maybe
String
,
overrides
::
[(
String
,
FilePath
)]
}
deriving
(
Show
)
data
Verbosity
=
Verbose
|
Normal
deriving
(
Show
)
...
...
@@ -50,31 +52,76 @@ executorParser = do
"Target machine to run on"
)
overrides
<-
catMaybes
<$>
truc
run
<-
optional
$
strOption
run
<-
optional
$
strOption
(
long
"run"
<>
metavar
"COMMAND"
<>
help
"Command to run
once in the environment
"
"Command to run
the environment instead of an interactive shell
"
)
pure
StackArgs
{
..
}
where
truc
::
Parser
[
Maybe
(
String
,
FilePath
)]
truc
=
traverse
optSrc
[
"argotk"
,
"argopkgs"
,
"nrm"
,
"containers"
,
"libnrm"
,
"amg"
,
"lammps"
,
"qmcpack"
,
"stream"
]
truc
=
traverse
optSrc
[
"argotk"
,
"argopkgs"
,
"nrm"
,
"containers"
,
"libnrm"
,
"amg"
,
"lammps"
,
"qmcpack"
,
"stream"
]
optSrc
::
String
->
Parser
(
Maybe
(
String
,
FilePath
))
optSrc
l
=
do
parsed
<-
optional
$
strOption
(
long
l
<>
metavar
"PATH"
<>
help
(
l
<>
" source folder override."
))
parsed
<-
optional
$
strOption
(
long
l
<>
metavar
"PATH"
<>
help
(
l
<>
" source folder override."
))
pure
$
mapT
l
parsed
mapT
::
String
->
Maybe
FilePath
->
Maybe
(
String
,
FilePath
)
mapT
l
thePath
=
case
thePath
of
Nothing
->
Nothing
Just
p
->
Just
(
l
,
p
)
Nothing
->
Nothing
Just
p
->
Just
(
l
,
p
)
main
::
IO
()
main
=
sh
$
do
a
@
StackArgs
{
..
}
<-
liftIO
$
execParser
opts
let
arguments
=
[
"-A"
,
"test"
]
liftIO
$
executeFile
"nix-shell"
True
([
"-A"
,
"test"
]
++
(
concat
[
[
"--arg"
,
(
l
<>
"-src"
)
,
encodeString
p
]
|
(
l
,
p
)
<-
overrides
]))
Nothing
let
arguments
=
argumentsBuilder
a
case
targetMachine
of
Nothing
->
liftIO
$
executeFile
"nix-shell"
True
arguments
Nothing
Just
host
->
do
printf
s
"argotest.hs: creating a derivation in the local store:
\n
"
drv
<-
single
$
inproc
"nix-instantiate"
([
"default.nix"
,
"--quiet"
]
++
map
pack
arguments
)
empty
printf
(
s
%
"
\n
"
)
$
lineToText
drv
printf
s
"argotest.hs: building the derivation's output:
\n
"
proc
"nix-store"
[
"--realize"
,
lineToText
drv
,
"--quiet"
]
empty
printf
s
"argotest.hs: copying the derivation's closure.
\n
"
proc
"nix-copy-closure"
[
"--include-outputs"
,
"--to"
,
pack
host
,
lineToText
drv
]
empty
liftIO
$
executeFile
"ssh"
True
[
"-t"
,
host
,
"source .profile; source .bash_profile; nix-shell $drv"
]
Nothing
where
argumentsBuilder
::
StackArgs
->
[
String
]
argumentsBuilder
a
@
StackArgs
{
..
}
=
[
"-A"
,
"test"
]
++
concat
[
[
"--arg"
,
l
<>
"-src"
,
encodeString
p
]
|
(
l
,
p
)
<-
overrides
]
++
(
case
run
of
Just
command
->
[
"--run"
,
command
]
Nothing
->
[]
)
opts
=
info
(
executorParser
<**>
helper
)
(
fullDesc
<>
progDesc
"Test environment builder for argo. This is a lightweight wrapper around various nix commands."
<>
header
"argonix"
(
fullDesc
<>
progDesc
"Test environment builder for argo. This is a lightweight wrapper around various nix commands."
<>
header
"argonix"
)
default.nix
View file @
ed8c2813
...
...
@@ -76,7 +76,7 @@ in
];
});
executor
=
argopkgs
.
mkShell
{
argotest
=
argopkgs
.
mkShell
{
name
=
"shake"
;
buildInputs
=
[
(
argopkgs
.
haskellPackages
.
ghcWithPackages
(
p
:
with
p
;
[
...
...
@@ -86,5 +86,5 @@ in
];
};
executor-hack
=
addHackEnv
executor
;
argotest-hack
=
addHackEnv
argotest
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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