Skip to content

Commit

Permalink
workbench: act on a batch of feedback from @jasagredo -- thanks!
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Sep 21, 2022
1 parent 75e7b7d commit 07af13f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 55 deletions.
43 changes: 11 additions & 32 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,38 +484,17 @@ Without further ado (**NOTE**: *the order of steps is important!*):
This command will produce a HUGE ``deps.png`` file, which will contain the entire chart of the project dependencies. The important part to look for will be the subset of packages highlighted in red -- those, which belong to the ``ouroboros-network`` repository. This will be the full *leaf dependency set*.
6. Edit the ``cardano-node/cabal.project`` as follows:
- for the *leaf dependency set*
1. in the very beginning of the ``cabal.project``, add their relative paths to the ``packages:`` section, e.g.:
.. code-block:: console
packages:
cardano-api
cardano-cli
...
trace-resources
trace-forward
../ouroboros-network/ouroboros-consensus-shelley
../ouroboros-network/ouroboros-consensus-cardano
2. in the corresponding ``source-repository-package`` section, comment out mentions of the packages, e.g.:
.. code-block:: console
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: c764553561bed8978d2c6753d1608dc65449617a
--sha256: 0hdh7xdrvxw943r6qr0xr4kwszindh5mnsn1lww6qdnxnmn7wcsc
subdir:
monoidal-synchronisation
network-mux
ouroboros-consensus
ouroboros-consensus-byron
-- ouroboros-consensus-cardano
ouroboros-consensus-protocol
-- ouroboros-consensus-shelley
ouroboros-network
ouroboros-network-framework
ouroboros-network-testing
- for the *leaf dependency set*, in the very beginning of the ``cabal.project``, add their relative paths to the ``packages:`` section, e.g.:
.. code-block:: console
packages:
cardano-api
cardano-cli
...
trace-resources
trace-forward
../ouroboros-network/ouroboros-consensus-shelley
../ouroboros-network/ouroboros-consensus-cardano
7. The two packages have now became **local** -- when you try ``cabal build exe:cardano-node`` now, you'll see that Cabal starts to build these dependencies you just localised. Hacking time!

Expand Down
12 changes: 5 additions & 7 deletions nix/workbench/lib-cabal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ export WB_NODE_EXECPREFIX="eval ${WB_TIME[*]@Q}"

function workbench-prebuild-executables()
{
local local_changes=

git diff --exit-code --quiet && echo -n ' ' || echo -n 'local changes + '
msg "prebuilding executables (because of useCabalRun)"
git diff --exit-code --quiet && echo -n ' ' || echo -n "$(yellow local changes +) "
git --no-pager log -n1 --alternate-refs --pretty=format:"%Cred%cr %Cblue%h %Cgreen%D %Cblue%s%Creset" --color
echo
newline
newline

echo "workbench: prebuilding executables (because of useCabalRun)"
unset NIX_ENFORCE_PURITY
for exe in cardano-node cardano-cli cardano-topology cardano-tracer tx-generator locli
do echo "workbench: $(blue prebuilding) $(red $exe)"
cabal -v0 build ${WB_FLAGS_CABAL} -- exe:$exe 2>&1 >/dev/null |
{ grep -v 'exprType TYPE'; true; } || return 1
cabal $(test -z "$verbose" && echo '-v0') build ${WB_FLAGS_CABAL} -- exe:$exe 2>&1 >/dev/null || return 1
done
echo
}
Expand Down
4 changes: 4 additions & 0 deletions nix/workbench/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ colorise() {
done
}

newline() {
echo >&2
}

msg() {
echo "workbench: $*" >&2
}
Expand Down
38 changes: 32 additions & 6 deletions nix/workbench/manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ case "${op}" in
local real_dir=$(realpath "$dir")

local args=(
--null-input
--slurp --raw-input
--arg dir "$real_dir"
--arg node "$node_rev"
--arg node_branch $(manifest_local_repo_branch "$dir")
Expand All @@ -28,10 +28,11 @@ case "${op}" in
--arg cardano_base $(manifest_cabal_project_dep_pin_hash "$dir" cardano-base)
--arg cardano_prelude $(manifest_cabal_project_dep_pin_hash "$dir" cardano-prelude)
)
jq '
manifest_cabal_package_localisations "$dir" | jq '
{ "cardano-node": $node
, "cardano-node-branch": $node_branch
, "cardano-node-status": $node_status
, "cardano-node-package-localisations": (. | split("\n") | unique | map(select(. != "")))
, "ouroboros-network": $ouroboros_network
, "cardano-ledger": $cardano_ledger
, "plutus": $plutus
Expand All @@ -42,6 +43,7 @@ case "${op}" in
| ($manifest
| del(."cardano-node-status")
| del(."cardano-node-branch")
| del(."cardano-node-package-localisations")
| to_entries
| map(if .value | length | (. == 40) then . else
error ([ "While collecting software manifest from \"\($dir)\": "
Expand Down Expand Up @@ -75,10 +77,11 @@ case "${op}" in
" (branch \(colorly("yellow"; $manifest."cardano-node-branch")) - \(repo_status($manifest."cardano-node-status")))"
}[$repo] // "";
. as $manifest
| ($manifest
(."cardano-node-package-localisations") as $localisations
| . as $manifest
| del(."cardano-node-status")
| del(."cardano-node-branch")
| del(."cardano-node-package-localisations")
| to_entries
| (map(.key | length) | max | . + 1) as $maxlen
| map([ " \(.key): "
Expand All @@ -87,11 +90,24 @@ case "${op}" in
, repo_comment($manifest; .key)
, "\n"
] | add)
| add
)
| . +
if $localisations == [] then []
else "\n" +
" \(colorly("yellow"; "localised packages")): " +
"\(colorly("red"; $localisations | join(" ")))"
| [.]
end +
["\n"]
| add
' --raw-output -L$global_basedir <<<$json
;;

collect-and-report )
local usage="USAGE: wb manifest $0 CARDANO-NODE-CHECKOUT"
local dir=${1:-.}; if test $# -ge 1; then shift; fi

manifest report "$(manifest collect-from-checkout "$dir")";;

* ) usage_manifest;; esac
}

Expand Down Expand Up @@ -129,3 +145,13 @@ manifest_local_repo_branch() {
else echo -n "unknown-branch"
fi
}

manifest_cabal_package_localisations() {
local dir=$1
if ! git -C "$dir" diff --exit-code --quiet -- cabal.project || \
! git -C "$dir" diff --exit-code --quiet -- cabal.project --staged
then
git -C "$dir" diff --exit-code -- cabal.project
git -C "$dir" diff --exit-code -- cabal.project --staged
fi | grep -F '+ ../' | cut -d/ -f2-3
}
3 changes: 0 additions & 3 deletions nix/workbench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ case "$op" in
else progress "run" "allocating a new one"
fi

## 0. report software manifest
progress "run | manifest" "component versions:"
manifest report "$manifest"
local hash=$(jq '."cardano-node" | .[:5]' -r <<<$manifest)

## 1. compute cluster composition
Expand Down
25 changes: 18 additions & 7 deletions nix/workbench/wb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ start()
local node_rev=
local cabal_mode=
local skip_prebuild=
local prebuild_done=
local genesis_cache_entry_dir=
local topology_dir=
local verbose=
Expand Down Expand Up @@ -144,7 +145,7 @@ start()
--supervisor | --backend-supervisor )
backend=supervisor;;

--verbose ) export verbose=t;;
--verbose | -v ) export verbose=t;;
--trace | --debug ) set -x;;
--trace-wb | --trace-workbench ) export WB_EXTRA_FLAGS=--trace;;
--help ) usage_start
Expand All @@ -154,10 +155,6 @@ start()

if test -n "$cabal_mode"
then . $(dirname "$0")/lib-cabal.sh
if test -z "$skip_prebuild"
then workbench-prebuild-executables
else progress "workbench | cabal" "skipping Cabal prebuilding due to $(yellow --skip-prebuild)"
fi
fi

backend assert-is $backend
Expand All @@ -169,10 +166,24 @@ start()

local top_i
for ((top_i=0; top_i<$iterations; top_i++))
do progress "top-level" "profile $(with_color 'yellow' $profile_name), iteration $(with_color 'white' $((top_i+1))) of $(with_color 'yellow' $iterations)"
do newline
progress "manifest" "component versions:"
local manifest=$(manifest collect-from-checkout "$node_source" $node_rev)
manifest report "$manifest"

if test -z "$cabal_mode" -o -n "$prebuild_done"
then true
elif test -n "$skip_prebuild"
then progress "workbench | cabal" "skipping Cabal prebuilding due to $(yellow --skip-prebuild)"
else workbench-prebuild-executables
prebuild_done=t
fi

progress "top-level" "profile $(with_color 'yellow' $profile_name), iteration $(with_color 'white' $((top_i+1))) of $(with_color 'yellow' $iterations)"

local args=(
${run_allocate_args[@]}
--manifest "$(manifest collect-from-checkout "$node_source" $node_rev)"
--manifest "$manifest"
)
run ${run_args[@]} 'allocate' $batch_name $profile_name "${args[@]}"
local run=$(run current-tag)
Expand Down

0 comments on commit 07af13f

Please sign in to comment.