Commit 00212f73 authored by Valentin Reis's avatar Valentin Reis

Merge branch 'argo-nodeos-config-suid-dir' into 'master'

Argo nodeos config suid dir

See merge request argo/argotest!12
parents 4619d5a8 28801c43
Pipeline #4713 passed with stage
in 6 seconds
......@@ -7,25 +7,95 @@ their master branch counterparts. see file `default.nix` for details.
The intended usage is to override (some of) the source(s) with WIP
version(s), as part of development or continuous integration. This
gitlab CI snippets shows how to do this on a nix-enabled runner. Mind that
this setup tracks argotest master.
gitlab CI snippets shows how to do this on a nix-enabled runner. Mind
that this setup tracks argotest master.
```{.yml}
### Usage
- Get Nix: `curl https://nixos.org/nix/install | sh`
- Use the 'argotest' nix function to provide an environment, among which the
`argotk.hs` tool, which runs tests. For example, we can run default tests
using pinned `argopkgs` sources like so:
```nix
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}: (import argotest {}).test' --run 'argotk.hs helloworld'
```
Alternatively, one can get rid of the `--run` option in order to be provided
with an environment in which all the argo components should be in the `PATH`,
along with the `argotk.hs` tool.
The arguments to the argotest function are defined in the default.nix file in
this repository. They all have default values.
For a more involved example, let's run a test in a custom environment. Here,
we'll run the 'helloworld' test in an environment that uses a local `nrm`
source, the master `libnrm` branch and a specific revision of the `containers`
branch:
```nix
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="argo-nodeos-config-suid-dir";})
}:
(import argotest {
nrm-src = /path/to/nrm;
libnrm-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/libnrm.git;
ref="master"; };
containers-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/containers.git;
ref="fancy-branch-name";
rev="commit-revisions-string";
};
}).test' --run 'argotk.hs helloworld'
```
*WARNING* There are a few things one has to be aware of using this workflow:
- Builds may fail if the local source repositories are dirty with old build files.
- Builds may fail if `PWD` is in a `nosuid`-enabled filesystem.
- Without using the `rev` argument, the `builtins.fetchGit` nix command
prefetches and buffers its output, with an expiration time that ranges ten
minutes by default. Use a local checkout if you need to modify some of these
sources on the fly:
```nix
nix-shell -E '{ argotest ? /path/to/argotest }:
(import argotest {
nrm-src = /path/to/nrm;
# libnrm-src left at default argument value (inherits from argopkgs)
# containers-src left at default argument value (inherits from argopkgs)
}).test' --run 'argotk.hs helloworld'
```
### Example CI setup
For example, we could setup the CI for the `containers` repo like:
``` {.yml}
integration.test:
stage: test
script:
- BUILD=$PWD
- git clone https://xgitlab.cels.anl.gov/argo/argotest.git
- cd argotest
- nix-shell -A test --run "./argotk.hs helloworld" --arg nrm-src ../.
- nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(import argotest { containers-src = ./. ; }).test'
--run 'argotk.hs helloworld'
artifacts:
paths:
- argotest/cmd_err.log
- argotest/cmd_out.log
- argotest/daemon_out.log
- argotest/daemon_out.log
- argotest/nrm.log
- argotest/time.log
- argotest/_output/cmd_err.log
- argotest/_output/cmd_out.log
- argotest/_output/daemon_out.log
- argotest/_output/daemon_out.log
- argotest/_output/nrm.log
- argotest/_output/time.log
expire_in: 1 week
except:
- /^wip\/.*/
......@@ -34,45 +104,40 @@ integration.test:
- integration
```
Standalone usage: example with the nrm source in `../`, provision the dependencies using:
```{.bash}
nix-shell -A test --arg nrm-src ../nrm
```
Then use the tool:
### Argotk.hs usage:
```{.bash}
./argotk.hs --help
argotk.hs --help
```
Output:
```{.txt pipe="sh"}
root/argotk.hs --help
root/argotk/argotk.hs --help
```
```{.bash}
./argotk.hs helloworld --help
argotk.hs helloworld --help
```
```{.txt pipe="sh"}
root/argotk.hs helloworld --help
root/argotk/argotk.hs helloworld --help
```
```{.bash}
./argotk.hs application --help
argotk.hs application --help
```
```{.txt pipe="sh"}
root/argotk.hs application --help
root/argotk/argotk.hs application --help
```
```{.bash}
./argotk.hs daemon --help
argotk.hs daemon --help
```
```{.txt pipe="sh"}
root/argotk.hs daemon --help
root/argotk/argotk.hs daemon --help
```
##### Hacking
### Hacking
- edit `.README.md` in place of README.md.
- the ./shake.hs build file takes care of a few things for the development workflow (readme and completion generation).
- the ./shake.hs build file takes care of a few things for the development
workflow (readme and completion generation).
......@@ -10,14 +10,87 @@ version(s), as part of development or continuous integration. This
gitlab CI snippets shows how to do this on a nix-enabled runner. Mind
that this setup tracks argotest master.
### Usage
- Get Nix: `curl https://nixos.org/nix/install | sh`
- Use the 'argotest' nix function to provide an environment, among
which the `argotk.hs` tool, which runs tests. For example, we can
run default tests using pinned `argopkgs` sources like so:
``` {.nix}
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}: (import argotest {}).test' --run 'argotk.hs helloworld'
```
Alternatively, one can get rid of the `--run` option in order to be
provided with an environment in which all the argo components should be
in the `PATH`, along with the `argotk.hs` tool.
The arguments to the argotest function are defined in the default.nix
file in this repository. They all have default values.
For a more involved example, let's run a test in a custom environment.
Here, we'll run the 'helloworld' test in an environment that uses a
local `nrm` source, the master `libnrm` branch and a specific revision
of the `containers` branch:
``` {.nix}
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="argo-nodeos-config-suid-dir";})
}:
(import argotest {
nrm-src = /path/to/nrm;
libnrm-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/libnrm.git;
ref="master"; };
containers-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/containers.git;
ref="fancy-branch-name";
rev="commit-revisions-string";
};
}).test' --run 'argotk.hs helloworld'
```
*WARNING* There are a few things one has to be aware of using this
workflow:
- Builds may fail if the local source repositories are dirty with old
build files.
- Builds may fail if `PWD` is in a `nosuid`-enabled filesystem.
- Without using the `rev` argument, the `builtins.fetchGit` nix
command prefetches and buffers its output, with an expiration time
that ranges ten minutes by default. Use a local checkout if you need
to modify some of these sources on the fly:
``` {.nix}
nix-shell -E '{ argotest ? /path/to/argotest }:
(import argotest {
nrm-src = /path/to/nrm;
# libnrm-src left at default argument value (inherits from argopkgs)
# containers-src left at default argument value (inherits from argopkgs)
}).test' --run 'argotk.hs helloworld'
```
### Example CI setup
For example, we could setup the CI for the `containers` repo like:
``` {.yml}
integration.test:
stage: test
script:
- BUILD=$PWD
- git clone https://xgitlab.cels.anl.gov/argo/argotest.git
- cd argotest
- nix-shell -A test --run "./argotk.hs helloworld" --arg nrm-src ../.
- nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(import argotest { containers-src = ./. ; }).test'
--run 'argotk.hs helloworld'
artifacts:
paths:
- argotest/_output/cmd_err.log
......@@ -34,17 +107,10 @@ integration.test:
- integration
```
Standalone usage: example with the nrm source in `../`, provision the
dependencies using:
### Argotk.hs usage:
``` {.bash}
nix-shell -A test --arg nrm-src ../nrm
```
Then use the tool:
``` {.bash}
./argotk.hs --help
argotk.hs --help
```
Output:
......@@ -67,7 +133,7 @@ Available commands:
```
``` {.bash}
./argotk.hs helloworld --help
argotk.hs helloworld --help
```
``` {.txt}
......@@ -79,19 +145,36 @@ Available options:
```
``` {.bash}
./argotk.hs application --help
argotk.hs application --help
```
``` {.txt}
Usage: argotk.hs application COMMAND
Usage: argotk.hs application [-w|--working_directory DIRECTORY] COMMAND
Setup stack and run an arbitrary command in a container.
Available options:
-w,--working_directory DIRECTORY
Working directory. Will be used for logging.
COMMAND Application to run inside the container
-h,--help Show this help text
```
##### Hacking
``` {.bash}
argotk.hs daemon --help
```
``` {.txt}
Usage: argotk.hs daemon [-w|--working_directory DIRECTORY]
Set up and launch the daemon in synchronous mode, with properly cleaned
sockets, logfiles.
Available options:
-w,--working_directory DIRECTORY
Working directory. Will be used for logging.
-h,--help Show this help text
```
### Hacking
- edit `.README.md` in place of README.md.
......
......@@ -77,10 +77,9 @@ prepareDaemonShell
prepareDaemonShell wd dargs daemon_out daemon_err nrm_log = do
mktree wd
cd wd
confPath <- myWhich "argo_nodeos_config"
myWhich "daemon"
tempDirPath <- mktempdir "/tmp" "argo-expe"
let confPath' = tempDirPath </> "argo_nodeos_config"
confPath <- myWhich "argo_nodeos_config"
let confPath' = "./argo_nodeos_config"
cp confPath confPath'
printInfo $ format ("Copied the configurator to " % fp % "\n") confPath'
printInfo $ format "Trying to sudo chown and chmod argo_nodeos_config\n"
......
......@@ -16,7 +16,6 @@ import System.Console.ANSI.Types ( Color )
import Options.Applicative
import System.Posix.Signals
import Control.Monad
import System.Environment.FindBin
wdOption = strOption
( long "working_directory"
......
......@@ -8,7 +8,7 @@ _argotk.hs()
CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
done
COMPREPLY=( $(./argotk.hs "${CMDLINE[@]}") )
COMPREPLY=( $(./argotk/argotk.hs "${CMDLINE[@]}") )
}
complete -o filenames -F _argotk.hs argotk.hs
......@@ -66,16 +66,15 @@ in rec
cp ${manifests}/* $out/share/
'';
buildInputs = [
(hpkgs.ghcWithPackages (p: [p.argo p.FindBin]))
(hpkgs.ghcWithPackages (p: [p.argo ]))
];
propagatedBuildInputs = [
(hpkgs.ghcWithPackages (p: [p.argo p.FindBin]))
(hpkgs.ghcWithPackages (p: [p.argo ]))
pkgs.coreutils
];
inherit shellHook;
};
test = pkgs.stdenv.mkDerivation rec {
name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
......@@ -90,5 +89,23 @@ in rec
MANIFESTS = ./manifests;
};
hack = pkgs.stdenv.mkDerivation rec {
name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [
containers
amg
nrm
(hpkgs.ghcWithPackages (p: devHPackages ++ [
argotk
argo
(pkgs.haskell.lib.doJailbreak p.panpipe)
p.turtle]))
];
inherit shellHook;
MANIFESTS = ./manifests;
};
}
......@@ -12,7 +12,7 @@ main = shakeArgs shakeOptions $ do
want ["README.md", "completion/argotk.sh"]
"completion/*.sh"
%> \out -> mkCompletionRule out "bash" $ takeFileName out -<.> "hs"
%> \out -> mkCompletionRule out "bash" $ "argotk" </> takeFileName out -<.> "hs"
"README.md" %> \out -> do
let template = ".README.md"
......
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