Commit | Line | Data |
---|---|---|
68b6e210 KS |
1 | #!/bin/bash |
2 | # shellcheck disable=SC2103 | |
3 | # | |
4 | # Copyright (C) 2021 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
5 | # | |
6 | # This program is free software: you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation, either version 3 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | set -exu | |
20 | ||
21 | RUBY_VERSION=2.7 | |
22 | ||
23 | # Add ssh key for deployment | |
24 | cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts | |
25 | cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa | |
26 | ||
27 | # Nodejs | |
28 | # Using Debian, as root | |
29 | apt-add-repository ppa:brightbox/ruby-ng | |
69114bc9 | 30 | apt-get update |
68b6e210 KS |
31 | apt-get install -y ruby${RUBY_VERSION} ruby${RUBY_VERSION}-dev ruby-switch ruby-bundler |
32 | ||
33 | ruby-switch --list | |
34 | ruby-switch --set ruby${RUBY_VERSION} | |
35 | ||
36 | ruby -v | |
37 | export PATH="/root/.gem/ruby/${RUBY_VERSION}.0/bin:$PATH" | |
38 | bundle config set --local path "/root/.gem" | |
39 | ||
40 | ||
41 | apt-get install -y jekyll npm grunt python3 python3-pip python3-venv | |
42 | ||
43 | # babeltrace dependencies | |
44 | apt-get install -y asciidoc xmlto libdw-dev libelf-dev elfutils autoconf automake libglib2.0-dev make doxygen flex bison | |
45 | ||
46 | npm install | |
47 | ||
48 | python3 -m venv build_venv && source build_venv/bin/activate | |
49 | pip install -r requirements.txt | |
50 | ||
51 | # Setting TERM avoids spurious warnings when configure is checking TPUT, as | |
52 | # $TERM is not set in the build environment. | |
53 | # As we've already opened a venv, set SKIP_VENV so the python job doesn't | |
54 | # create a second nested virtual environment. | |
55 | TERM=dumb SKIP_VENV=1 grunt build:prod --verbose | |
69114bc9 KS |
56 | |
57 | apt-get install -y linkchecker | |
58 | grunt connect:prod watch:prod & | |
59 | SERVER_PID="${!}" | |
60 | sleep 10 # While serve:prod starts up | |
61 | OUTPUT_FILE="$(mktemp -d)/linkchecker-out.csv" | |
62 | chown nobody "$(dirname "${OUTPUT_FILE}")" | |
63 | # @Note: Only internal links are checked by default | |
64 | if ! linkchecker -q -F "csv/utf-8/${OUTPUT_FILE}" http://localhost:10000/ ; then | |
65 | echo "Linkchecker failed or found broken links" | |
66 | cat "${OUTPUT_FILE}" | |
67 | kill "${SERVER_PID}" | |
68 | rm -rf "${OUTPUT_FILE}/.." | |
69 | sleep 5 # Let serve:prod stop | |
70 | exit 1 | |
71 | else | |
72 | rm -rf "${OUTPUT_FILE}/.." | |
73 | kill "${SERVER_PID}" | |
74 | fi | |
75 | ||
68b6e210 KS |
76 | grunt deploy:prod --verbose |
77 | ||
78 | # In the venv functions generated by the version of python installed on bionic | |
79 | # nodes, the deactivate function checks undefined variables (eg. $1) which causes | |
80 | # the build to fail when `set -u` is in effect. | |
81 | set +u | |
82 | deactivate | |
83 | ||
84 | # EOF |