Skip to content

Commit

Permalink
workbench: massive refactoring; initial nixops+libvirtd/aws backends
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Jan 31, 2023
1 parent 5ec21f1 commit 2461dbd
Show file tree
Hide file tree
Showing 95 changed files with 2,027 additions and 508 deletions.
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -40,7 +40,8 @@ trace-documentation:
###
### Workbench
###
CI_TARGETS := hlint workbench-ci-test haddock-hoogle
workbench-ci: workbench-ci-test ci-test-auto ci-test-autonix ci-test-autonomad
CI_TARGETS := hlint workbench-ci haddock-hoogle
ci: ci-report ci-targets
ci-report:
@echo -e "\033[34mGoals under test\033[0m: \033[33m$(CI_TARGETS)\033[0m"
Expand Down Expand Up @@ -71,7 +72,7 @@ ps: ## Plain-text list of profiles
##
PROFILES_BASE := default plutus plutus-secp-ecdsa plutus-secp-schnorr oldtracing idle tracer-only
PROFILES_STARTSTOP := startstop startstop-p2p startstop-plutus startstop-notracer startstop-oldtracing
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-dense10
PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-notracer ci-test-dense10 aws-test
PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-plutus-secp-ecdsa ci-bench-plutus-secp-schnorr ci-bench-notracer
PROFILES_10 := 10 10-p2p 10-plutus 10-notracer
PROFILES_FORGE_STRESS := forge-stress forge-stress-p2p forge-stress-plutus forge-stress-plutus-singleton forge-stress-notracer
Expand Down
4 changes: 3 additions & 1 deletion default.nix
Expand Up @@ -5,7 +5,9 @@ in
{
# override scripts with custom configuration
withHoogle ? defaultCustomConfig.withHoogle
, profileName ? defaultCustomConfig.localCluster.profileName
, profileNix ? null
, profileName ? if profileNix != null then profileNix.profileName
else defaultCustomConfig.localCluster.profileName;
, workbenchDevMode ? defaultCustomConfig.localCluster.workbenchDevMode
, customConfig ? {
inherit withHoogle;
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions lib.mk
Expand Up @@ -27,12 +27,14 @@ endif
endef

define define_profile_targets
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad, $$(prof), true,false,false,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonomad, $$(prof), true,false, true,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad, $$(prof), true,false,false,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonomad, $$(prof), true,false, true,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nixops, $$(prof), true,false,false,false,false, nixops)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonixops, $$(prof), true,false, true, true,false, nixops)))
endef
2 changes: 2 additions & 0 deletions nix/custom-config.nix
@@ -1,4 +1,5 @@
self: {
profiled = false;
withHoogle = true;
localCluster = {
cacheDir = "${self.localCluster.stateDir}/.cache";
Expand All @@ -9,6 +10,7 @@ self: {
basePort = 30000;
workbenchDevMode = true;
extraBackendConfig = {};
useCabalRun = true;
};
membench = {
snapshotSlot = 37173650;
Expand Down
19 changes: 0 additions & 19 deletions nix/nixops.nix

This file was deleted.

99 changes: 57 additions & 42 deletions nix/pkgs.nix
@@ -1,7 +1,61 @@
# our packages overlay
final: prev: with final; {
final: prev:

let
inherit (prev) customConfig;
inherit (final) pkgs cardanoNodePackages;
inherit (prev.pkgs) lib;

# A generic, fully parameteric version of the workbench development environment.
workbench = pkgs.callPackage ./workbench {};

# A conveniently-parametrisable workbench preset.
# See https://input-output-hk.github.io/haskell.nix/user-guide/development/
# The general idea is:
# backendName -> useCabalRun -> backend
# stateDir -> batchName -> profileName -> backend -> workbench -> runner
# * `workbench` is in case a pinned version of the workbench is needed.
workbench-runner =
let backendRegistry =
{
nixops = ./workbench/backend/nixops.nix;
nomad = ./workbench/backend/nomad.nix;
supervisor = ./workbench/backend/supervisor.nix;
};
in
{ stateDir ? customConfig.localCluster.stateDir
, batchName ? customConfig.localCluster.batchName
, profileNix ? null
, profileName ? if profileNix != null then profileNix.profileName
else customConfig.localCluster.profileName
, backendName ? customConfig.localCluster.backendName
, useCabalRun ? customConfig.localCluster.useCabalRun
, workbenchDevMode ? customConfig.localCluster.workbenchDevMode
, profiled ? customConfig.profiled
, cardano-node-rev ? null
, workbench ? pkgs.workbench
}:
let
# The `useCabalRun` flag is set in the backend to allow the backend to
# override its value. The runner uses the value of `useCabalRun` from
# the backend to prevent a runner using a different value.
backend = import (backendRegistry."${backendName}")
{ inherit pkgs lib useCabalRun; };
in import ./workbench/backend/runner.nix
{
inherit pkgs lib cardanoNodePackages;
inherit stateDir batchName profileName backend;
inherit cardano-node-rev;
inherit useCabalRun workbench workbenchDevMode;
};

# Workbench instantiated by parameters from customConfig:
custom-config-workbench-runner = workbench-runner {};

in with final;
{
inherit (cardanoNodeProject.args) compiler-nix-name;
inherit workbench workbench-runner;

cabal = haskell-nix.cabal-install.${compiler-nix-name};

Expand Down Expand Up @@ -68,48 +122,8 @@ final: prev: with final; {
script = "submit-api";
};

# A generic, parameteric version of the workbench development environment.
workbench = pkgs.callPackage ./workbench {};

all-profiles-json = workbench.profile-names-json;

# A parametrisable workbench, that can be used with nix-shell or lorri.
# See https://input-output-hk.github.io/haskell.nix/user-guide/development/
# The general idea is:
# backendName -> useCabalRun -> backend
# stateDir -> batchName -> profileName -> backend -> workbench -> runner
# * `workbench` is in case a pinned version of the workbench is needed.
workbench-runner =
let backendRegistry =
{
supervisor = ./workbench/backend/supervisor.nix;
nomad = ./workbench/backend/nomad.nix;
};
in
{ stateDir ? customConfig.localCluster.stateDir
, batchName ? customConfig.localCluster.batchName
, profileName ? customConfig.localCluster.profileName
, backendName ? customConfig.localCluster.backendName
, useCabalRun ? false
, profiled ? false
, cardano-node-rev ? null
, workbench ? pkgs.workbench
, workbenchDevMode ? false
}:
let
# The `useCabalRun` flag is set in the backend to allow the backend to
# override its value. The runner uses the value of `useCabalRun` from
# the backend to prevent a runner using a different value.
backend = import (backendRegistry."${backendName}")
{ inherit pkgs lib useCabalRun; };
in import ./workbench/backend/runner.nix
{
inherit pkgs lib cardanoNodePackages;
inherit stateDir batchName profileName backend;
inherit cardano-node-rev;
inherit workbench workbenchDevMode;
};

# Disable failing python uvloop tests
python38 = prev.python38.override {
packageOverrides = pythonFinal: pythonPrev: {
Expand All @@ -118,4 +132,5 @@ final: prev: with final; {
});
};
};
}
} //
custom-config-workbench-runner.overlay final prev
Expand Up @@ -4,7 +4,7 @@
, run
, trace ? false }:

pkgs.runCommand "workbench-run-analysis-${profileNix.name}"
pkgs.runCommand "workbench-run-analysis-${profileNix.profileName}"
{ requiredSystemFeatures = [ "benchmark" ];
nativeBuildInputs = with pkgs.haskellPackages; with pkgs;
[ bash coreutils gnused jq moreutils nixWrapped workbench.workbench ];
Expand Down
4 changes: 2 additions & 2 deletions nix/workbench/analyse.sh → nix/workbench/analyse/analyse.sh
Expand Up @@ -37,7 +37,7 @@ usage_analyse() {
$(red analyse) $(blue options):
$(helpopt --filters F,F,F..) Comma-separated list of named chain filters: see bench/chain-filters
$(helpopt --filters F,F,F..) Comma-separated list of named chain filters: see bench/analyse/chain-filters
Note: filter names have no .json suffix
Defaults are specified by the run's profile.
$(helpopt --filter-expr JSON)
Expand Down Expand Up @@ -616,7 +616,7 @@ throttle_shell_job_spawns() {

analysis_set_filters() {
local filter_names=($(echo $1 | sed 's_,_ _g'))
local filter_paths=(${filter_names[*]/#/"$global_basedir/chain-filters/"})
local filter_paths=(${filter_names[*]/#/"$global_basedir/analyse/chain-filters/"})
local filter_files=(${filter_paths[*]/%/.json})

for f in ${filter_files[*]}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions nix/workbench/backend.sh → nix/workbench/backend/backend.sh
Expand Up @@ -4,9 +4,9 @@ usage_backend() {
Test if the cluster specified by the run directory
is currently running
setenv-defaults PROFILE-DIR
setenv-defaults BACKEND-DATA-DIR
Setup the global environment in env.jq,
using profile in PROFILE-DIR
using backend data in BACKEND-DATA-DIR
allocate-run RUNDIR
describe-run RUNDIR
Expand Down Expand Up @@ -69,7 +69,7 @@ case "${op}" in
;;

assert-stopped )
backend is-running &&
backend is-running run/current &&
fatal "backend reports that cluster is already running. Please stop it first: $(yellow stop-cluster)" ||
true
;;
Expand Down

0 comments on commit 2461dbd

Please sign in to comment.