55# BASE_TAR_URL - URL of a tarball with binaries for base revision
66# BASE_REVISION - revision of cardano-node to upgrade from (alternative to BASE_TAR_URL)
77# UPGRADE_REVISION - revision of cardano-node to upgrade to
8+ # UPGRADE_CLI_REVISION - revision of cardano-cli to upgrade to (optional)
89
910set -Eeuo pipefail
1011trap ' echo "Error at line $LINENO"' ERR
1112
12- if [[ -z " ${BASE_TAR_URL:- " " } " && -z " ${BASE_REVISION:- " " } " ]]; then
13+ if [[ -z " ${BASE_TAR_URL:- } " && -z " ${BASE_REVISION:- } " ]]; then
1314 echo " BASE_TAR_URL or BASE_REVISION must be set"
1415 exit 1
1516fi
1617
18+ if [ -n " ${GITHUB_ACTIONS:- } " ]; then
19+ CI_OPTIMIZE_SPACE=" ${CI_OPTIMIZE_SPACE:- " true" } "
20+ fi
21+
1722nix --version
1823df -h .
1924
@@ -69,31 +74,52 @@ echo "::group::Nix env setup step1"
6974printf " start: %(%H:%M:%S)T\n" -1
7075
7176# shellcheck disable=SC1090,SC1091
72- . .github/nix_override_cardano_node .sh
77+ . .github/source_cardano_node .sh
7378
74- # update cardano-node to specified revision
79+ # Prepare cardano-node for the base revision.
7580# If BASE_TAR_URL is set, instead of using nix, download and extract binaries for base revision
76- # from a published tarball to save disk space, and use the same nix env as will be used for
77- # UPGRADE_REVISION. We are running out of space on GitHub Actions runners.
78- if [[ -z " ${BASE_TAR_URL:- " " } " && -n " ${BASE_REVISION:- " " } " ]]; then
79- NODE_OVERRIDE=$( node_override " ${BASE_REVISION} " )
80- elif [ -n " ${UPGRADE_REVISION:- " " } " ]; then
81- NODE_OVERRIDE=$( node_override " $UPGRADE_REVISION " )
82- else
83- NODE_OVERRIDE=$( node_override)
81+ # from a published tarball.
82+ PATH_PREPEND_BASE=" "
83+ if [ -z " ${BASE_TAR_URL:- } " ]; then
84+ if [ -z " ${BASE_REVISION:- } " ]; then
85+ echo " Either BASE_TAR_URL or BASE_REVISION must be set"
86+ exit 1
87+ fi
88+ cardano_bins_build_all " $BASE_REVISION " " " " _base"
89+ PATH_PREPEND_BASE=" $( cardano_bins_print_path_prepend " " " _base" ) "
90+ fi
91+ export PATH_PREPEND_BASE
92+
93+ # Prepare cardano-node for the upgrade revision
94+ cardano_bins_build_all " ${UPGRADE_REVISION:- " master" } " " ${UPGRADE_CLI_REVISION:- } " " _upgrade"
95+ PATH_PREPEND_UPGRADE=" $( cardano_bins_print_path_prepend " ${UPGRADE_CLI_REVISION:- } " " _upgrade" ) "
96+ export PATH_PREPEND_UPGRADE
97+
98+ # Prepare cardano-cli for the upgrade revision if UPGRADE_CLI_REVISION is set
99+ if [ -n " ${UPGRADE_CLI_REVISION:- } " ]; then
100+ export CARDANO_CLI_REV=" $UPGRADE_CLI_REVISION "
101+ # shellcheck disable=SC1090,SC1091
102+ . .github/source_cardano_cli.sh
103+ cardano_cli_build " $UPGRADE_CLI_REVISION " " _upgrade"
104+ PATH_PREPEND_UPGRADE=" $( cardano_cli_print_path_prepend " _upgrade" ) ${PATH_PREPEND_UPGRADE} "
105+ export PATH_PREPEND_UPGRADE
106+ fi
107+
108+ # optimize nix store space if requested
109+ if [ " ${CI_OPTIMIZE_SPACE:- " false" } " != " false" ]; then
110+ nix store gc || :
84111fi
85112
86- # shellcheck disable=SC2086
87- nix flake update --accept-flake-config $NODE_OVERRIDE
88113# shellcheck disable=SC2016
89- nix develop --accept-flake-config .# venv --command bash -c '
114+ nix develop --accept-flake-config .# testenv --command bash -c '
90115 set -euo pipefail
91- : > " $WORKDIR /.nix_step1 "
92- echo " ::endgroup::" # end group for "Nix env setup step1 "
116+ : > " $WORKDIR /.nix_setup "
117+ echo " ::endgroup::" # end group for "Nix env setup"
93118
94119 echo " ::group::Python venv setup step1"
95120 printf " start: %(%H:%M:%S)T\n" -1
96121 . .github/setup_venv.sh clean
122+ export PATH=" ${PATH_PREPEND_BASE}${PATH} "
97123 echo " ::endgroup::" # end group for "Python venv setup step1"
98124
99125 echo " ::group::🧪 Testrun Step1"
@@ -102,40 +128,14 @@ nix develop --accept-flake-config .#venv --command bash -c '
102128 # prepare scripts for stating cluster instance, start cluster instance, run smoke tests
103129 retval=0
104130 ./.github/node_upgrade_pytest.sh step1 || retval=" $? "
105- exit " $retval "
106- ' || retval="$?"
107-
108- if [ ! -e "$WORKDIR/.nix_step1" ]; then
109- echo "Nix env setup failed, exiting"
110- exit 1
111- fi
112-
113- # retval 0 == all tests passed; 1 == some tests failed; > 1 == some runtime error and we don' t want to continue
114- [ " $retval " -le 1 ] || exit " $retval "
115-
116- echo " ::endgroup::" # end group for "Testrun Step1"
117-
118- echo " ::group::Nix env setup steps 2 & 3"
119- printf " start: %(%H:%M:%S)T\n" -1
120-
121- # update cardano-node to specified branch and/or revision, or to the latest available revision
122- if [ -n " ${UPGRADE_REVISION:- " " } " ]; then
123- NODE_OVERRIDE=$( node_override " $UPGRADE_REVISION " )
124- else
125- NODE_OVERRIDE=$( node_override)
126- fi
127-
128- # shellcheck disable=SC2086
129- nix flake update --accept-flake-config $NODE_OVERRIDE
130- # shellcheck disable=SC2016
131- nix develop --accept-flake-config .# venv --command bash -c '
132- set -euo pipefail
133- : > " $WORKDIR /.nix_step2"
134- echo " ::endgroup::" # end group for "Nix env setup steps 2 & 3"
131+ # retval 0 == all tests passed; 1 == some tests failed; > 1 == some runtime error and we do not want to continue
132+ [ " $retval " -le 1 ] || exit " $retval "
133+ echo " ::endgroup::" # end group for "Testrun Step1"
135134
136135 echo " ::group::Python venv setup steps 2 & 3"
137136 printf " start: %(%H:%M:%S)T\n" -1
138137 . .github/setup_venv.sh clean
138+ export PATH=" ${PATH_PREPEND_UPGRADE}${PATH} "
139139 echo " ::endgroup::" # end group for "Python venv setup steps 2 & 3"
140140
141141 echo " ::group::🧪 Testrun Step2"
@@ -144,27 +144,25 @@ nix develop --accept-flake-config .#venv --command bash -c '
144144 # update cluster nodes, run smoke tests
145145 retval=0
146146 ./.github/node_upgrade_pytest.sh step2 || retval=" $? "
147- # retval 0 == all tests passed; 1 == some tests failed; > 1 == some runtime error and we dont want to continue
148147 [ " $retval " -le 1 ] || exit " $retval "
149148 echo " ::endgroup::" # end group for "Testrun Step2"
150149
151150 echo " ::group::🧪 Testrun Step3"
152151 printf " start: %(%H:%M:%S)T\n" -1
153152 df -h .
154- # update to Conway , run smoke tests
153+ # update the rest of cluster nodes , run smoke tests
155154 retval=0
156155 ./.github/node_upgrade_pytest.sh step3 || retval=" $? "
157- df -h .
158156 echo " ::endgroup::" # end group for "Testrun Step3"
159157
160158 echo " ::group::Teardown cluster & collect artifacts"
161159 printf " start: %(%H:%M:%S)T\n" -1
162- # teardown cluster
160+ df -h .
163161 ./.github/node_upgrade_pytest.sh finish || :
164162 exit $retval
165163' || retval="$?"
166164
167- if [ ! -e "$WORKDIR/.nix_step2 " ]; then
165+ if [ ! -e "$WORKDIR/.nix_setup " ]; then
168166 echo "Nix env setup failed, exiting"
169167 exit 1
170168fi
175173_cleanup
176174
177175# prepare artifacts for upload in GitHub Actions
178- if [ -n "${GITHUB_ACTIONS:-"" }" ]; then
176+ if [ -n "${GITHUB_ACTIONS:-}" ]; then
179177 # save testing artifacts
180178 ./.github/save_artifacts.sh
181179
0 commit comments