Skip to content

Commit fbd1fce

Browse files
authored
Update cabal_build_tests scripts to allow testing builds at commits. (#1191)
* Update cabal_build_tests scripts to allow testing builds at commits. The scripts were previously only aimed at build-testing `cardano-node` tags. The script can now also build-test specific commit hashes. Other changes: * Include installation of missing package dependencies (openssl, lmdb). * Include Secp256k1 installation. * "Parameterise" the script with cabal and ghc versions. * Installing of `cardano-cli` and `cardano-node` executables simplified. * Process PR comments: Missing Fedora packages, typos
1 parent e55beed commit fbd1fce

File tree

4 files changed

+164
-42
lines changed

4 files changed

+164
-42
lines changed

cabal_build_tests/install-node.sh

+130-38
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
11
#!/bin/bash
22

3-
### Builds cardano-node on Ubuntu or Fedora using Cabal and verifys successful installation
3+
### Builds cardano-node on Ubuntu or Fedora using Cabal and verifies successful installation
44
### Please note: sudo is not used because user is root
55
### Please note: 'source ~/.bashrc' cmd is not used because Docker runs this script as subscript
66

77
echo ""
88

9-
if [[ $TAGGED_VERSION == "null" ]]
9+
# Check that environment variables are correctly set up.
10+
if [[ -z "${GIT_OBJECT}" ]]
1011
then
11-
printf "Please specify TAGGED_VERSION on docker run.\ne.g. '-e TAGGED_VERSION=1.23.0'"
12+
>&2 printf "Please specify GIT_OBJECT_TYPE on docker run.\ne.g. '-e GIT_OBJECT_TYPE=tag' or '-e GIT_OBJECT_TYPE=commit'"
13+
elif [[ -z "${GIT_OBJECT}" ]]
14+
then
15+
>&2 printf "Please specify GIT_OBJECT on docker run.\ne.g. '-e GIT_OBJECT=1.23.0' for tags, or '-e GIT_OBJECT=78wagy3aw87ef' for commits."
16+
exit 1
1217
fi
1318

14-
echo "Using tagged version $TAGGED_VERSION"
19+
echo "Using git object '$GIT_OBJECT' of type '$GIT_OBJECT_TYPE'"
1520
cd ~ || exit 1
1621

22+
# Set up GHC and cabal-install versions
23+
GHC_VERSION="8.10.7"
24+
GHC="ghc-$GHC_VERSION"
25+
GHC_SUFFIX="x86_64-deb9-linux.tar.xz"
26+
GHC_FULL="$GHC-$GHC_SUFFIX"
27+
28+
echo "Using GHC version $GHC_VERSION"
29+
30+
CABAL_VERSION="3.6.2.0"
31+
CABAL="cabal-install-$CABAL_VERSION"
32+
CABAL_SUFFIX="x86_64-linux-deb10.tar.xz"
33+
CABAL_FULL="$CABAL-$CABAL_SUFFIX"
34+
35+
echo "Using cabal-install version $CABAL_VERSION"
36+
1737
# Install dependencies
1838
echo "Install dependencies"
1939
if [[ $(cat /etc/os-release) == *"fedora"* ]]
2040
then
2141
echo "Running on Fedora"
2242
yum update -y
2343
yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf -y
24-
yum install systemd-devel ncurses-devel ncurses-compat-libs -y
44+
yum install systemd-devel ncurses-devel ncurses-compat-libs which jq openssl-devel lmdb-devel -y
2545
elif [[ $(cat /etc/os-release) == *"ubuntu"* ]]
2646
then
2747
echo "Running on Ubuntu"
2848
apt-get update -y
29-
apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y
49+
apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf liblmdb-dev -y
3050
else
31-
echo "/etc/os-relase does not contain 'fedora' or 'ubuntu'"
32-
cat /etc/os-release
51+
>&2 echo "/etc/os-relase does not contain 'fedora' or 'ubuntu'"
52+
>&2 cat /etc/os-release
3353
exit 1
3454
fi
3555

3656
# Download, unpack, install and update Cabal
3757
echo "Download, unpack, install and update Cabal"
38-
wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
39-
tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz
40-
rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig
58+
wget https://downloads.haskell.org/~cabal/$CABAL/$CABAL_FULL
59+
tar -xf $CABAL_FULL
60+
rm $CABAL_FULL
4161
mkdir -p ~/.local/bin
4262
mv cabal ~/.local/bin/
4363

@@ -54,28 +74,36 @@ fi
5474

5575
cabal update
5676

57-
if [[ $(cabal --version) != *"cabal-install version 3.2.0.0"* ]]
77+
if [[ $(cabal --version) != *"cabal-install version $CABAL_VERSION"* ]]
5878
then
59-
echo "cabal version $(cabal --version) is not 3.2.0.0"
79+
>&2 echo "cabal version $(cabal --version) is not $CABAL_VERSION"
6080
exit 1
6181
else
62-
echo "cabal version 3.2.0.0 is correct"
82+
echo "cabal version $CABAL_VERSION is correct"
6383
fi
6484

65-
# Download and install GHC
85+
# Download, unpack and install GHC
6686
echo "Download and install GHC"
6787

6888
mkdir -p ~/src || exit 1
6989
cd ~/src || exit 1
70-
wget https://downloads.haskell.org/ghc/8.10.2/ghc-8.10.2-x86_64-deb9-linux.tar.xz
71-
tar -xf ghc-8.10.2-x86_64-deb9-linux.tar.xz
72-
rm ghc-8.10.2-x86_64-deb9-linux.tar.xz
73-
cd ghc-8.10.2 || exit 1
90+
wget https://downloads.haskell.org/ghc/$GHC_VERSION/$GHC_FULL
91+
tar -xf $GHC_FULL
92+
rm $GHC_FULL
93+
cd $GHC || exit 1
7494
./configure
7595
make install
7696

97+
if [[ $(ghc --version) != *"version $GHC_VERSION"* ]]
98+
then
99+
>&2 echo "ghc version $(ghc --version) is not $GHC_VERSION"
100+
exit 1
101+
else
102+
echo "ghc version $GHC_VERSION is correct"
103+
fi
104+
77105
# Install Libsodium
78-
echo "Install Lobsodium"
106+
echo "Install Libsodium"
79107

80108
mkdir -p ~/src || exit 1
81109
cd ~/src || exit 1
@@ -90,6 +118,19 @@ make install
90118
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
91119
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
92120

121+
# Install Secp256k1
122+
echo "Install Secp256k1"
123+
124+
mkdir -p ~/src || exit 1
125+
cd ~/src || exit 1
126+
git clone https://github.com/bitcoin-core/secp256k1
127+
cd secp256k1 || exit 1
128+
git checkout ac83be33
129+
./autogen.sh
130+
./configure --enable-module-schnorrsig --enable-experimental
131+
make
132+
make install
133+
93134
# Download the source code for cardano-node
94135
echo "Download the source code for cardano-node"
95136

@@ -99,42 +140,93 @@ git clone https://github.com/input-output-hk/cardano-node.git
99140
cd cardano-node || exit 1
100141
git fetch --all --recurse-submodules --tags
101142

102-
if [[ $(git tag) != *"$TAGGED_VERSION"* ]]
143+
# Checkout with prechecks for git object and git object type
144+
if [[ $(git cat-file -t "$GIT_OBJECT") != "commit" ]]
103145
then
104-
echo "$(git tag) does not contain $TAGGED_VERSION"
146+
>&2 echo "$(git cat-file -t "$GIT_OBJECT") does not refer to a commit/tag."
105147
exit 1
106148
fi
107149

108-
git checkout "tags/$TAGGED_VERSION"
150+
case $GIT_OBJECT_TYPE in
151+
tag)
152+
if [[ $(git tag) != *"$GIT_OBJECT"* ]]
153+
then
154+
>&2 echo "$(git tag) does not contain $GIT_OBJECT"
155+
exit 1
156+
fi
157+
;;
158+
commit)
159+
:
160+
;;
161+
*)
162+
exit 1
163+
;;
164+
esac
165+
166+
git checkout "$GIT_OBJECT"
109167

110168
# Configure and build options
111169
echo "Configure and build options"
112-
cabal configure --with-compiler=ghc-8.10.2
170+
cabal configure --with-compiler=$GHC
113171
echo "package cardano-crypto-praos" >> cabal.project.local
114172
echo " flags: -external-libsodium-vrf" >> cabal.project.local
115173

116174
# Build and install the node
117175
echo "Build and install the node"
118176
cabal build all
119-
cabal install all --bindir ~/.local/bin
177+
cabal install --bindir=~/.local/bin cardano-node cardano-cli
120178

121-
if [[ ! -d ~/.local/bin/dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-cli-$TAGGED_VERSION/x/ ]]
179+
dirs=( ~/.local/bin/dist-newstyle/build/x86_64-linux/"$GHC"/cardano-cli-*/x/ )
180+
[ "${#dirs[@]}" -ge 2 ] && exit 1
181+
if [ ! -e "${dirs[0]}" ]
122182
then
123183
echo "Cabal build's --binddir did not work! Manually copying to ~/.local/bin/"
124-
cp -p "dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-node-$TAGGED_VERSION/x/cardano-node/build/cardano-node/cardano-node" ~/.local/bin/
125-
cp -p "dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-cli-$TAGGED_VERSION/x/cardano-cli/build/cardano-cli/cardano-cli" ~/.local/bin/
126-
fi
127-
128-
# Verify node is installed
129-
echo "Verify node is installed"
130-
if [[ $(cardano-cli --version) == *"$TAGGED_VERSION"* ]]
131-
then
132-
cardano-cli --version
133-
else
134-
echo "$(cardano-cli --version) does not contain $TAGGED_VERSION"
135-
exit 1
184+
cp -p "$(./scripts/bin-path.sh cardano-node)" ~/.local/bin/
185+
cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/
136186
fi
137187

188+
# Verify installation
189+
case $GIT_OBJECT_TYPE in
190+
tag)
191+
GIT_TAG=$GIT_OBJECT
192+
193+
# Verify cli is installed
194+
echo "Verify cli is installed"
195+
if [[ $(cardano-cli --version) == *"$GIT_TAG"* ]]
196+
then
197+
cardano-cli --version
198+
else
199+
>&2 echo "$(cardano-cli --version) does not contain $GIT_TAG"
200+
exit 1
201+
fi
202+
203+
# Verify node is installed
204+
echo "Verify node is installed"
205+
if [[ $(cardano-node --version) == *"$GIT_TAG"* ]]
206+
then
207+
cardano-node --version
208+
else
209+
>&2 echo "$(cardano-node --version) does not contain $GIT_TAG"
210+
exit 1
211+
fi
212+
213+
;;
214+
commit)
215+
# Verify cli is installed
216+
echo "Verify cli is installed"
217+
cardano-cli --version
218+
219+
# Verify node is installed
220+
echo "Verify node is installed"
221+
cardano-node --version
222+
223+
;;
224+
*)
225+
exit 1
226+
;;
227+
esac
228+
229+
# Succes message
138230
printf "\nSuccess\n\n"
139231
echo "You can use 'docker exec -it <container-id> /bin/bash' in a separate session to play in the environment."
140232
echo "Press any key to stop container."

cabal_build_tests/readme.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
## Run tests
77

88
### To test cardano-node Cabal build on Ubuntu:
9-
`./run-ubuntu.sh <cardano-node tag>`
9+
`./run-ubuntu.sh -t tag -o <cardano-node tag>`
10+
11+
`./run-ubuntu.sh -t commit -o <cardano-node commit>`
1012

1113
### To test cardano-node Cabal build on Fedora:
1214

13-
`./run-fedora.sh <cardano-node tag>`
15+
`./run-fedora.sh -t tag -o <cardano-node tag>`
16+
17+
`./run-fedora.sh -t commit -o <cardano-node commit>`
1418

1519
If "Success" is shown at the end and exit with code 0 then build has completed successfully and verified with cardano-cli.

cabal_build_tests/run-fedora.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/bin/bash
22

3+
GIT_OBJECT_TYPE=""
4+
GIT_OBJECT=""
5+
6+
while getopts t:o: flag
7+
do
8+
case "${flag}" in
9+
t) GIT_OBJECT_TYPE=${OPTARG};;
10+
o) GIT_OBJECT=${OPTARG};;
11+
*) echo "Error in command line parsing" >&2
12+
exit 1
13+
esac
14+
done
15+
316
docker build . -f fedora/Dockerfile -t cardano-node-fedora && \
4-
docker run --security-opt label:disable -it -e TAGGED_VERSION="$1" cardano-node-fedora
17+
docker run --security-opt label:disable -it -e GIT_OBJECT_TYPE="$GIT_OBJECT_TYPE" -e GIT_OBJECT="$GIT_OBJECT" cardano-node-fedora

cabal_build_tests/run-ubuntu.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/bin/bash
22

3+
GIT_OBJECT_TYPE=""
4+
GIT_OBJECT=""
5+
6+
while getopts t:o: flag
7+
do
8+
case "${flag}" in
9+
t) GIT_OBJECT_TYPE=${OPTARG};;
10+
o) GIT_OBJECT=${OPTARG};;
11+
*) echo "Error in command line parsing" >&2
12+
exit 1
13+
esac
14+
done
15+
316
docker build . -f ubuntu/Dockerfile -t cardano-node-ubuntu && \
4-
docker run --security-opt label:disable -it -e TAGGED_VERSION="$1" cardano-node-ubuntu
17+
docker run --security-opt label:disable -it -e GIT_OBJECT_TYPE="$GIT_OBJECT_TYPE" -e GIT_OBJECT="$GIT_OBJECT" cardano-node-ubuntu

0 commit comments

Comments
 (0)