22235: differentiated frozen manageable projects
[arvados.git] / build / package-testing / common-test-rails-server-package.sh
1 #!/bin/sh
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 set -e
7
8 if [ 0 = "$#" ]; then
9     PACKAGE_NAME="$(basename "$0" | grep -Eo '\barvados.*$')"
10     PACKAGE_NAME=${PACKAGE_NAME%.sh}
11 else
12     PACKAGE_NAME=$1; shift
13 fi
14
15 API_GEMS_LS="$(mktemp --tmpdir api-gems-XXXXXX.list)"
16 trap 'rm -f "$API_GEMS_LS"' EXIT INT TERM QUIT
17
18 cd "/var/www/${PACKAGE_NAME%-server}"
19
20 check_gem_dirs() {
21     local when="$1"; shift
22     env -C shared/vendor_bundle/ruby ls -1 >"$API_GEMS_LS"
23     local ls_count="$(wc -l <"$API_GEMS_LS")"
24     if [ "$ls_count" = 1 ]; then
25         return 0
26     fi
27     echo "Package $PACKAGE_NAME FAILED: $ls_count gem directories created after $when:" >&2
28     case "${ARVADOS_DEBUG:-0}" in
29         0) cat "$API_GEMS_LS" >&2 ;;
30         *) env -C shared/vendor_bundle/ruby find -maxdepth 3 -type d -ls >&2 ;;
31     esac
32     return 11
33 }
34
35 check_gem_dirs "initial install"
36
37 case "$TARGET" in
38     debian*|ubuntu*)
39         apt-get install -y nginx
40         dpkg-reconfigure "$PACKAGE_NAME"
41         ;;
42     rocky*)
43         microdnf --assumeyes install httpd
44         microdnf --assumeyes reinstall "$PACKAGE_NAME"
45         ;;
46     *)
47         echo -e "$0: Unknown target '$TARGET'.\n" >&2
48         exit 1
49         ;;
50 esac
51
52 check_gem_dirs "package reinstall"
53 env -C current bundle list >"$ARV_PACKAGES_DIR/$PACKAGE_NAME.gems"