/
regression.sh
executable file
·151 lines (119 loc) · 3.6 KB
/
regression.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#! /usr/bin/env -S nix develop --accept-flake-config .#base -c bash
# shellcheck shell=bash
set -xeuo pipefail
nix --version
REPODIR="$(readlink -m "${0%/*}/..")"
cd "$REPODIR"
export WORKDIR="$REPODIR/run_workdir"
# shellcheck disable=SC1090,SC1091
. .github/stop_cluster_instances.sh
# stop all running cluster instances
stop_instances "$WORKDIR"
# create clean workdir
rm -rf "${WORKDIR:?}"
mkdir -p "$WORKDIR"
export TMPDIR="$WORKDIR/tmp"
mkdir -p "$TMPDIR"
# setup dbsync (disabled by default)
case "${CI_ENABLE_DBSYNC:-"false"}" in
"true" | 1)
# shellcheck disable=SC1090,SC1091
. .github/source_dbsync.sh
;;
"false" | 0)
;;
*)
echo "Unknown value for CI_ENABLE_DBSYNC: ${CI_ENABLE_DBSYNC}" >&2
exit 1
;;
esac
# setup plutus-apps (enabled by default)
# The "plutus-apps" repo is needed for the `create-script-context` tool, which is used by the
# Plutus tests that are testing script context.
case "${CI_ENABLE_PLUTUS_APPS:-"true"}" in
"true" | 1)
# shellcheck disable=SC1090,SC1091
. .github/source_plutus_apps.sh
;;
"false" | 0)
;;
*)
echo "Unknown value for CI_ENABLE_PLUTUS: ${CI_ENABLE_PLUTUS}" >&2
exit 1
;;
esac
if [ "${CI_TOPOLOGY:-""}" = "p2p" ]; then
export ENABLE_P2P="true"
elif [ "${CI_TOPOLOGY:-""}" = "mixed" ]; then
export MIXED_P2P="true"
export NUM_POOLS="${NUM_POOLS:-4}"
fi
export ARTIFACTS_DIR="${ARTIFACTS_DIR:-".artifacts"}"
rm -rf "${ARTIFACTS_DIR:?}"
export SCHEDULING_LOG=scheduling.log
true > "$SCHEDULING_LOG"
MARKEXPR="${MARKEXPR:-""}"
if [ "${MARKEXPR:-""}" = "all" ]; then
unset MARKEXPR
fi
if [ -n "${CLUSTERS_COUNT:-""}" ]; then
export CLUSTERS_COUNT
fi
if [ "${TX_ERA:-""}" == "default" ]; then
export TX_ERA=""
fi
if [ "${CI_FAST_CLUSTER:-"false"}" != "false" ] && [ -z "${SCRIPTS_DIRNAME:-""}" ]; then
export SCRIPTS_DIRNAME="${CLUSTER_ERA:-"babbage"}_fast"
fi
export CARDANO_NODE_SOCKET_PATH_CI="$WORKDIR/state-cluster0/bft1.socket"
# assume we run tests on testnet when `BOOTSTRAP_DIR` is set
if [ -n "${BOOTSTRAP_DIR:-""}" ]; then
export CARDANO_NODE_SOCKET_PATH_CI="$WORKDIR/state-cluster0/relay1.socket"
export MAKE_TARGET="${MAKE_TARGET:-"testnets"}"
fi
# function to update cardano-node to specified branch and/or revision, or to the latest available
# shellcheck disable=SC1090,SC1091
. .github/nix_override_cardano_node.sh
echo "::group::Nix env setup"
printf "start: %(%H:%M:%S)T\n" -1
# run tests and generate report
set +e
# shellcheck disable=SC2046,SC2016,SC2119
nix develop --accept-flake-config $(node_override) --command bash -c '
printf "finish: %(%H:%M:%S)T\n" -1
echo "::endgroup::" # end group for "Nix env setup"
echo "::group::Pytest run"
if [ -e ".bin" ]; then export PATH="${PWD}/.bin:${PATH}"; fi
export CARDANO_NODE_SOCKET_PATH="$CARDANO_NODE_SOCKET_PATH_CI"
make "${MAKE_TARGET:-"tests"}"
retval="$?"
echo "::endgroup::"
echo "::group::Collect artifacts"
./.github/cli_coverage.sh .
exit "$retval"
'
retval="$?"
# move reports to root dir
mv .reports/testrun-report.* ./
# grep testing artifacts for errors
# shellcheck disable=SC1090,SC1091
. .github/grep_errors.sh
# stop all running cluster instances
stop_instances "$WORKDIR"
# stop postgres if running
stop_postgres || true
# prepare artifacts for upload in Github Actions
if [ -n "${GITHUB_ACTIONS:-""}" ]; then
# create results archive
./.github/results.sh .
# save testing artifacts
# shellcheck disable=SC1090,SC1091
. .github/save_artifacts.sh
# compress scheduling log
xz "$SCHEDULING_LOG"
echo
echo "Dir content:"
ls -1a
fi
echo "::endgroup::" # end group for "Collect artifacts"
exit "$retval"