Skip to content

Commit

Permalink
CI: split into separate tasks
Browse files Browse the repository at this point in the history
to ensure correct lifecycle order for schemathesis test
  • Loading branch information
dermetfan committed Jan 18, 2022
1 parent baf2c4f commit db6962a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
42 changes: 42 additions & 0 deletions actions/cicero/ci/lintAndBuild.nix
@@ -0,0 +1,42 @@
{ name, std, lib, actionLib, ... }@args:

std.behavior.onInputChange "start" name args

{
inputs.start = ''
"cicero/ci": start: {
clone_url: string
sha: string
statuses_url?: string
}
'';

job = { start }:
let cfg = start.value."cicero/ci".start; in
std.chain args [
actionLib.simpleJob

(std.networking.addNameservers [ "1.1.1.1" ])

(lib.optionalAttrs (cfg ? statuses_url)
(std.github.reportStatus cfg.statuses_url))

(std.git.clone cfg)

{
resources.memory = 1024 * 3;

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

(std.wrapScript "bash" (next: ''
set -ex
lint
${lib.escapeShellArgs next}
''))

std.nix.build
];
}
File renamed without changes.
54 changes: 13 additions & 41 deletions actions/cicero/ci.nix → actions/cicero/ci/schemathesis.nix
Expand Up @@ -4,22 +4,22 @@ std.behavior.onInputChange "start" name args

{
inputs.start = ''
"${name}": start: {
"cicero/ci": start: {
clone_url: string
sha: string
statuses_url?: string
}
'';

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

(std.escapeNames [ ] [ ])

{
cicero-ci.group.cicero = {
${name}.group.schemathesis = {
network = {
mode = "bridge";
port = {
Expand All @@ -29,57 +29,29 @@ std.behavior.onInputChange "start" name args
};

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

(std.networking.addNameservers [ "1.1.1.1" ])

(std.git.clone cfg)

{
resources.memory = 1024 * 3;

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

(std.wrapScript "bash" (next: ''
set -ex
lint
${lib.escapeShellArgs next}
''))

std.nix.build
];

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

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

cicero = {
lifecycle.sidecar = true;

config = {
packages = [
"github:input-output-hk/cicero/${cfg.sha}#cicero-entrypoint"
];
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 [
{ lifecycle.hook = "poststart"; }

(lib.optionalAttrs (cfg ? statuses_url)
(std.github.reportStatus cfg.statuses_url))

Expand Down

0 comments on commit db6962a

Please sign in to comment.