Commit 08c61880 authored by Valentin Reis's avatar Valentin Reis

packaging fix.

parent 9a011e40
Pipeline #5024 canceled with stage
#### integration testing
#### `argotk`
Integration tests that validate the argo stack, leveraging the 'argopkgs'
repository. The intended usage is to override (some of) the source(s) with WIP
version(s), as part of development or continuous integration.
This is a stack executor for argo. It can be used standalone and drives CI tests.
It should be used via [argotest](https://xgitlab.cels.anl.gov/argo/argotest).
### Usage (tl;dr, I already have nix on my machine.)
```bash
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {
#nrm-src = /path/to/nrm
#libnrm-src = /path/to/nrm
#containers-src = /path/to/nrm
}).test' --run "argotk.hs TestHello"
```
### Usage (in three parts)
- [**1**] Get Nix: `curl https://nixos.org/nix/install | sh`
- [**2**] Use the `test` attribute of the argotest' nix attribute set to enter a
test environment. For example, we can run default tests on the
"argopkgs-pinned" version of argo components using:
```bash
nix-shell -E '
let
argotest-src =
builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
};
argotest = import argotest-src {};
in
argotest.test'
```
This environment has all the necessary Argo components in its PATH. The
argotest function has various arguments, defined in the default.nix file at the
rooto of this repository. They all have default values. For a more involved
example, let's get a custom test environment.
Here, we'll use an environment that uses a local `nrm` source, the master
`libnrm` branch and a specific revision of the `containers` branch. We'l'l use
the master `argotest` branch for that:
```nix
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(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 TestHello'
```
- [**3**] The `test`environment contains the `argotk.hs` tool, which runs various
operations on the argo stack:
Commands list:
#### Usage
```{.bash}
argotk.hs --help
argotk --help
```
Output:
```{.txt pipe="sh"}
root/argotk/argotk.hs --help
argotk --help
```
Detailed help:
```{.bash}
argotk.hs TestHello --help
argotk TestHello --help
```
Output:
```{.txt pipe="sh"}
root/argotk/argotk.hs TestHello --help
```
#### Misc
Alternatively, one can use the `--run` option to run a test directly:
```bash
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {}).test' --run "argotk.hs TestHello"
argotk TestHello --help
```
#### WARNINGS
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.
- 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.
### Hacking
- edit `.README.md` in place of README.md.
- see `default.nix`
- the ./shake.hs build file takes care of a few things for the development
workflow (readme and completion generation).
- edit `.README.md` in place of README.md and run ./shake.hs as a pre-commit hook.
This diff is collapsed.
......@@ -11,10 +11,6 @@ let
};
};
devInputs = with hpkgs; with pkgs; [
sysstat
];
devHPackages = with hpkgs; [
cabal-install
apply-refact
......@@ -27,11 +23,23 @@ let
];
in rec
{
inherit(hpkgs) argotk;
inherit (hpkgs) argotk;
hack = hpkgs.shellFor {
packages = p: with p; [ argotk ];
withHoogle = true;
buildInputs = devInputs ++ devHPackages;
buildInputs = devHPackages;
};
preCommit = pkgs.mkShell {
name = "shake";
MANIFESTS = "/tmp";
buildInputs = [
(pkgs.haskellPackages.ghcWithPackages (p: with p; [
argotk
shake
(pkgs.haskell.lib.doJailbreak panpipe)
]))
];
};
}
#! /usr/bin/env nix-shell
#! nix-shell -i runhaskell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [shake])"
#! nix-shell -i runhaskell -A preCommit
import Development.Shake
import Development.Shake.FilePath
......@@ -13,18 +13,15 @@ main = shakeArgs shakeOptions $ do
want ["README.md", "completion/argotk.sh"]
"completion/*.sh"
%> \out -> mkCompletionRule out "bash" $ takeFileName out -<.> "hs"
%> \out -> do
let cplA = cmd "argotk" ["--bash-completion-script", "argotk"]
(Stdout cplScript) <- cplA
liftIO $ writeFile out cplScript
"README.md" %> \out -> do
let template = ".README.md"
need [template , "argotk/argotk.hs" , "argo/src/Argo/Stack.hs"]
need [template , "src/argotk.hs" , "src/Argo/Stack.hs"]
(Stdout panpipe) <- cmd "which panpipe"
cmd_ "pandoc --filter"
[take (length panpipe - 1) panpipe, template, "-o", out]
where
mkCompletionAction str sn =
(sn, cmd ("argotk/" ++ sn) ["--" ++ str ++ "-completion-script", sn])
mkCompletionRule out str fn = do
let (needed, cplA) = mkCompletionAction str fn
(Stdout cplScript) <- cplA
liftIO $ writeFile out cplScript
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