Skip to content

Commit

Permalink
fixup schemathesis test for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed Jan 17, 2022
1 parent e1e4def commit 362c6dd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 37 deletions.
67 changes: 31 additions & 36 deletions actions/cicero/ci.nix
Expand Up @@ -12,8 +12,7 @@ std.behavior.onInputChange "start" name args
'';

job = { start }:
let cfg = start.value."${name}".start;
in
let cfg = start.value.${name}.start; in
std.chain args [
actionLib.jobDefaults

Expand All @@ -23,78 +22,74 @@ std.behavior.onInputChange "start" name args
cicero-ci.group.cicero = {
network = {
mode = "bridge";
port.http.to = 8080;
port = {
http.to = 8080;
db.to = 5432;
};
};

task = {
lintAndBuild = std.chain args [
(lib.optionalAttrs (cfg ? statuses_url)
(std.github.reportStatus cfg.statuses_url))

(std.wrapScript "bash" (next: ''
set -x
mkdir -p /etc
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
${lib.escapeShellArgs next}
''))
(std.networking.addNameservers [ "1.1.1.1" ])

(std.git.clone cfg)

{
resources = {
memory = 32 * 1024;
cpu = 16000;
};

resources.memory = 1024;
config.packages = std.data-merge.append [
"github:input-output-hk/cicero#devShell.x86_64-linux"
"github:input-output-hk/cicero/${cfg.sha}#devShell.x86_64-linux"
];
}

(std.wrapScript "bash" (next: ''
set -exuo pipefail
golangci-lint run
gocritic check -enableAll -disable=ifElseChain,ptrToRefParam,unnamedResult,appendAssign ./...
nixpkgs-fmt --check .
set -ex
go generate ./...
lint
${lib.escapeShellArgs next}
''))

std.nix.build
];

dev = {
config.nixos =
"github:input-output-hk/cicero/${cfg.sha}#nixosConfigurations.dev";
cicero = {
lifecycle = {
hook = "prestart";
sidecar = true;
};

config = {
packages = [
"github:input-output-hk/cicero/${cfg.sha}#cicero-entrypoint"
];
command = [ "/bin/entrypoint" ];
};

env.DATABASE_URL = "postgres://cicero:@127.0.0.1:\${NOMAD_PORT_db}/cicero?sslmode=disable";
};

dev = {
lifecycle = {
hook = "prestart";
sidecar = true;
};

config.nixos = "github:input-output-hk/cicero/${cfg.sha}#nixosConfigurations.dev";
};

schemathesis = std.chain args [
(lib.optionalAttrs (cfg ? statuses_url)
(std.github.reportStatus cfg.statuses_url))

(std.wrapScript "bash" (next: ''
set -ex
mkdir -p /etc
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
exec ${lib.escapeShellArgs next}
''))
(std.networking.addNameservers [ "1.1.1.1" ])

(std.git.clone cfg)

{
resources = {
memory = 32 * 1024;
cpu = 16000;
};

config.packages = std.data-merge.append [
"github:input-output-hk/cicero#devShell.x86_64-linux"
"github:input-output-hk/cicero/${cfg.sha}#devShell.x86_64-linux"
];
}

Expand Down
29 changes: 28 additions & 1 deletion pkgs/cicero/evaluators/nix/lib.nix
Expand Up @@ -208,6 +208,33 @@ rec {
template = data-merge.append outer.template;
};

networking = {
nameservers = nameservers: action: next:
data-merge.merge
(next // {
# XXX we have to pre-create `template` because it may not be present
# see https://github.com/divnix/data-merge/issues/1
template = next.template or [];
})
{
template = data-merge.append [ {
destination = "/etc/resolv.conf";
left_delimiter = "";
right_delimiter = "";
data = lib.concatStringsSep "\n" (map (ns: "nameserver " + ns) nameservers);
} ];
};

addNameservers = nameservers:
wrapScript "bash" (next: ''
mkdir -p /etc
for nameserver in ${lib.escapeShellArgs nameservers}; do
echo "nameserver $nameserver" >> /etc/resolv.conf
done
${lib.escapeShellArgs next}
'');
};

nix = {
install = action: next:
data-merge.merge
Expand Down Expand Up @@ -360,6 +387,6 @@ rec {
inherit (tasks) script;
inherit (chains) chain;
inherit (chains.jobs) escapeNames singleTask;
inherit (chains.tasks) wrapScript nix makes git github;
inherit (chains.tasks) wrapScript networking nix makes git github;
inherit data-merge;
}

0 comments on commit 362c6dd

Please sign in to comment.