gh-action: Add OCI scripts ci installation check (#109)

* Add files for install OneClickInstall with Vagrant

* Delete one matrix and add true for execute
This commit is contained in:
Iskandar Kurbonov 2023-12-19 17:42:05 +03:00 committed by GitHub
parent 7e84f75fb5
commit 64687d0960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 525 additions and 0 deletions

146
.github/workflows/ci-oci-install.yml vendored Normal file
View File

@ -0,0 +1,146 @@
name: Install OneClickInstall DocSpace
on:
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'install/OneClickInstall/**'
schedule:
- cron: '00 20 * * 6' # At 23:00 on Saturday.
workflow_dispatch:
inputs:
centos7:
type: boolean
description: 'CentOS 7'
default: true
centos8s:
type: boolean
description: 'CentOS 8 Stream'
default: true
centos9s:
type: boolean
description: 'CentOS 9 Stream'
default: true
debian10:
type: boolean
description: 'Debian 10'
default: true
debian11:
type: boolean
description: 'Debian 11'
default: true
debian12:
type: boolean
description: 'Debian 12'
default: true
ubuntu1804:
type: boolean
description: 'Ubuntu 18.04'
default: true
ubuntu2004:
type: boolean
description: 'Ubuntu 20.04'
default: true
ubuntu2204:
type: boolean
description: 'Ubuntu 22.04'
default: true
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix names
id: set-matrix
run: |
matrix=$(echo '{
"include": [
{"execute": '${{ github.event.inputs.centos7 || true }}', "name": "CentOS7", "os": "centos7", "distr": "generic"},
{"execute": '${{ github.event.inputs.centos8s || true }}', "name": "CentOS8S", "os": "centos8s", "distr": "generic"},
{"execute": '${{ github.event.inputs.centos9s || true }}', "name": "CentOS9S", "os": "centos9s", "distr": "generic"},
{"execute": '${{ github.event.inputs.debian10 || true }}', "name": "Debian10", "os": "debian10", "distr": "generic"},
{"execute": '${{ github.event.inputs.debian11 || true }}', "name": "Debian11", "os": "debian11", "distr": "generic"},
{"execute": '${{ github.event.inputs.debian12 || true }}', "name": "Debian12", "os": "debian12", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu1804 || true }}', "name": "Ubuntu18.04", "os": "ubuntu1804", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu2004 || true }}', "name": "Ubuntu20.04", "os": "ubuntu2004", "distr": "generic"},
{"execute": '${{ github.event.inputs.ubuntu2204 || true }}', "name": "Ubuntu22.04", "os": "ubuntu2204", "distr": "generic"}
]
}' | jq -c '{include: [.include[] | select(.execute == true)]}')
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
vagrant-up:
name: "Test DocSpace with ${{ matrix.name}}"
runs-on: ubuntu-22.04
needs: prepare
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.prepare.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Get update and install vagrant
run: |
set -eux
sudo apt update -y
sudo apt install vagrant virtualbox -y
- name: "Test production scripts with ${{matrix.name}}"
if: ${{ github.event_name == 'schedule' }}
uses: nick-fields/retry@v2
with:
max_attempts: 2
timeout_minutes: 40
retry_on: error
command: |
set -eux
cd tests/vagrant
TEST_CASE='--production-install' \
DISTR='${{ matrix.distr }}' \
OS='${{ matrix.os }}' \
DOWNLOAD_SCRIPT='-ds true' \
RAM='5100' \
CPU='3' \
ARGUMENTS="-arg '--skiphardwarecheck true --makeswap false'" \
vagrant up
on_retry_command: |
echo "RUN CLEAN UP: Destroy vagrant and one more try"
cd tests/vagrant
sleep 10
vagrant destroy --force
- name: "Test Local scripts with ${{matrix.name}}"
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
uses: nick-fields/retry@v2
with:
max_attempts: 2
timeout_minutes: 40
retry_on: error
command: |
set -eux
cd tests/vagrant
TEST_CASE='--local-install' \
DISTR='${{ matrix.distr }}' \
OS='${{matrix.os}}' \
RAM='5100' \
CPU='3' \
DOWNLOAD_SCRIPT='-ds false' \
TEST_REPO='-tr true' \
ARGUMENTS="-arg '--skiphardwarecheck true --makeswap false --localscripts true'" \
vagrant up
on_retry_command: |
echo "RUN CLEAN UP: Destroy vagrant and one more try"
cd tests/vagrant
sleep 10
vagrant destroy --force

22
tests/vagrant/Vagrantfile vendored Normal file
View File

@ -0,0 +1,22 @@
Vagrant.configure("2") do |config|
config.vm.box = "#{ENV['DISTR']}/#{ENV['OS']}"
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", "#{ENV['RAM']}"] #<= total RAM.
v.customize ["modifyvm", :id, "--cpus", "#{ENV['CPU']}"] #<= total CPU.
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
config.vm.define 'ubuntu'
config.vm.hostname = "host4test"
if ENV['TEST_CASE'] != '--production-install'
config.vm.provision "file", source: "../../../DocSpace-buildtools/install/OneClickInstall/.", destination: "/tmp/docspace/"
end
config.vm.provision "shell", path: './install.sh', :args => "#{ENV['DOWNLOAD_SCRIPT']} #{ENV['TEST_REPO']} #{ENV['ARGUMENTS']}"
# Prevent SharedFoldersEnableSymlinksCreate errors
config.vm.synced_folder ".", "/vagrant", disabled: true
end

357
tests/vagrant/install.sh Normal file
View File

@ -0,0 +1,357 @@
#!/bin/bash
set -e
while [ "$1" != "" ]; do
case $1 in
-ds | --download-scripts )
if [ "$2" != "" ]; then
DOWNLOAD_SCRIPTS=$2
shift
fi
;;
-arg | --arguments )
if [ "$2" != "" ]; then
ARGUMENTS=$2
shift
fi
;;
-pi | --production-install )
if [ "$2" != "" ]; then
PRODUCTION_INSTALL=$2
shift
fi
;;
-li | --local-install )
if [ "$2" != "" ]; then
LOCAL_INSTALL=$2
shift
fi
;;
-lu | --local-update )
if [ "$2" != "" ]; then
LOCAL_UPDATE=$2
shift
fi
;;
-tr | --test-repo )
if [ "$2" != "" ]; then
TEST_REPO_ENABLE=$2
shift
fi
;;
esac
shift
done
export TERM=xterm-256color^M
SERVICES_SYSTEMD=(
"docspace-api.service"
"docspace-doceditor.service"
"docspace-studio-notify.service"
"docspace-files.service"
"docspace-notify.service"
"docspace-studio.service"
"docspace-backup-background.service"
"docspace-files-services.service"
"docspace-people-server.service"
"docspace-backup.service"
"docspace-healthchecks.service"
"docspace-socket.service"
"docspace-clear-events.service"
"docspace-login.service"
"docspace-ssoauth.service"
"ds-converter.service"
"ds-docservice.service"
"ds-metrics.service")
function common::get_colors() {
COLOR_BLUE=$'\e[34m'
COLOR_GREEN=$'\e[32m'
COLOR_RED=$'\e[31m'
COLOR_RESET=$'\e[0m'
COLOR_YELLOW=$'\e[33m'
export COLOR_BLUE
export COLOR_GREEN
export COLOR_RED
export COLOR_RESET
export COLOR_YELLOW
}
#############################################################################################
# Checking available resources for a virtual machine
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
#############################################################################################
function check_hw() {
local FREE_RAM=$(free -h)
local FREE_CPU=$(nproc)
echo "${COLOR_RED} ${FREE_RAM} ${COLOR_RESET}"
echo "${COLOR_RED} ${FREE_CPU} ${COLOR_RESET}"
}
#############################################################################################
# Prepare vagrant boxes like: set hostname/remove postfix for DEB distributions
# Globals:
# None
# Arguments:
# None
# Outputs:
# ☑ PREPAVE_VM: **<prepare_message>**
#############################################################################################
function prepare_vm() {
if [ -f /etc/lsb-release ] ; then
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
DISTRIB_CODENAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
DISTRIB_RELEASE=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
elif [ -f /etc/lsb_release ] || [ -f /usr/bin/lsb_release ] ; then
DIST=`lsb_release -a 2>&1 | grep 'Distributor ID:' | awk -F ":" '{print $2 }'`
REV=`lsb_release -a 2>&1 | grep 'Release:' | awk -F ":" '{print $2 }'`
DISTRIB_CODENAME=`lsb_release -a 2>&1 | grep 'Codename:' | awk -F ":" '{print $2 }'`
DISTRIB_RELEASE=`lsb_release -a 2>&1 | grep 'Release:' | awk -F ":" '{print $2 }'`
elif [ -f /etc/os-release ] ; then
DISTRIB_CODENAME=$(grep "VERSION=" /etc/os-release |awk -F= {' print $2'}|sed s/\"//g |sed s/[0-9]//g | sed s/\)$//g |sed s/\(//g | tr -d '[:space:]')
DISTRIB_RELEASE=$(grep "VERSION_ID=" /etc/os-release |awk -F= {' print $2'}|sed s/\"//g |sed s/[0-9]//g | sed s/\)$//g |sed s/\(//g | tr -d '[:space:]')
fi
DIST=`echo "$DIST" | tr '[:upper:]' '[:lower:]' | xargs`;
DISTRIB_CODENAME=`echo "$DISTRIB_CODENAME" | tr '[:upper:]' '[:lower:]' | xargs`;
REV=`echo "$REV" | xargs`;
if [ ! -f /etc/centos-release ]; then
if [ "${DIST}" = "debian" ]; then
if [ "${DISTRIB_CODENAME}" == "bookworm" ]; then
apt-get update -y
apt install -y curl gnupg
fi
apt-get remove postfix -y
echo "${COLOR_GREEN}☑ PREPAVE_VM: Postfix was removed${COLOR_RESET}"
fi
if [ "${TEST_REPO_ENABLE}" == 'true' ]; then
mkdir -p -m 700 $HOME/.gnupg
echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://nexus.onlyoffice.com/repository/4testing-debian stable main" | sudo tee /etc/apt/sources.list.d/onlyoffice4testing.list
curl -fsSL https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/onlyoffice.gpg --import
chmod 644 /usr/share/keyrings/onlyoffice.gpg
fi
fi
if [ -f /etc/centos-release ]; then
if [ "${TEST_REPO_ENABLE}" == 'true' ]; then
cat > /etc/yum.repos.d/onlyoffice4testing.repo <<END
[onlyoffice4testing]
name=onlyoffice4testing repo
baseurl=https://nexus.onlyoffice.com/repository/centos-testing/4testing/main/noarch
gpgcheck=1
enabled=1
gpgkey=https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE
END
yum -y install centos*-release
fi
local REV=$(cat /etc/redhat-release | sed 's/[^0-9.]*//g')
if [[ "${REV}" =~ ^9 ]]; then
update-crypto-policies --set LEGACY
echo "${COLOR_GREEN}☑ PREPAVE_VM: sha1 gpg key chek enabled${COLOR_RESET}"
fi
fi
# Clean up home folder
rm -rf /home/vagrant/*
if [ -d /tmp/docspace ]; then
mv /tmp/docspace/* /home/vagrant
fi
echo '127.0.0.1 host4test' | sudo tee -a /etc/hosts
echo "${COLOR_GREEN}☑ PREPAVE_VM: Hostname was setting up${COLOR_RESET}"
}
#############################################################################################
# Install docspace and then healthcheck
# Globals:
# None
# Arguments:
# None
# Outputs:
# Script log
#############################################################################################
function install_docspace() {
if [ "${DOWNLOAD_SCRIPTS}" == 'true' ]; then
wget https://download.onlyoffice.com/docspace/docspace-install.sh
else
sed 's/set -e/set -xe/' -i *.sh
fi
printf "N\nY\nY" | bash docspace-install.sh ${ARGUMENTS}
if [[ $? != 0 ]]; then
echo "Exit code non-zero. Exit with 1."
exit 1
else
echo "Exit code 0. Continue..."
fi
}
#############################################################################################
# Healthcheck function for systemd services
# Globals:
# SERVICES_SYSTEMD
# Arguments:
# None
# Outputs:
# Message about service status
#############################################################################################
function healthcheck_systemd_services() {
for service in ${SERVICES_SYSTEMD[@]}
do
if systemctl is-active --quiet ${service}; then
echo "${COLOR_GREEN}☑ OK: Service ${service} is running${COLOR_RESET}"
else
echo "${COLOR_RED}⚠ FAILED: Service ${service} is not running${COLOR_RESET}"
SYSTEMD_SVC_FAILED="true"
fi
done
}
#############################################################################################
# Set output if some services failed
# Globals:
# None
# Arguments:
# None
# Outputs:
# ⚠ ⚠ ATTENTION: Some sevices is not running ⚠ ⚠
# Returns
# 0 if all services is start correctly, non-zero if some failed
#############################################################################################
function healthcheck_general_status() {
if [ ! -z "${SYSTEMD_SVC_FAILED}" ]; then
echo "${COLOR_YELLOW}⚠ ⚠ ATTENTION: Some sevices is not running ⚠ ⚠ ${COLOR_RESET}"
exit 1
fi
}
#############################################################################################
# Get logs for all services
# Globals:
# $SERVICES_SYSTEMD
# Arguments:
# None
# Outputs:
# Logs for systemd services
# Returns:
# none
# Commentaries:
# This function succeeds even if the file for cat was not found. For that use ${SKIP_EXIT} variable
#############################################################################################
function services_logs() {
for service in ${SERVICES_SYSTEMD[@]}; do
echo -----------------------------------------
echo "${COLOR_GREEN}Check logs for systemd service: $service${COLOR_RESET}"
echo ---------------------- -------------------
EXIT_CODE=0
journalctl -u $service || true
done
local MAIN_LOGS_DIR="/var/log/onlyoffice"
local DOCSPACE_LOGS_DIR="${MAIN_LOGS_DIR}/docspace"
local DOCUMENTSERVER_LOGS_DIR="${MAIN_LOGS_DIR}/documentserver"
local DOCSERVICE_LOGS_DIR="${DOCUMENTSERVER_LOGS_DIR}/docservice"
local CONVERTER_LOGS_DIR="${DOCUMENTSERVER_LOGS_DIR}/converter"
local METRICS_LOGS_DIR="${DOCUMENTSERVER_LOGS_DIR}/metrics"
ARRAY_MAIN_SERVICES_LOGS=($(ls ${MAIN_LOGS_DIR} | grep log | sed 's/web.sql.log//;s/web.api.log//;s/nginx.*//' ))
ARRAY_DOCSPACE_LOGS=($(ls ${DOCSPACE_LOGS_DIR}))
ARRAY_DOCSERVICE_LOGS=($(ls ${DOCSERVICE_LOGS_DIR}))
ARRAY_CONVERTER_LOGS=($(ls ${CONVERTER_LOGS_DIR}))
ARRAY_METRICS_LOGS=($(ls ${METRICS_LOGS_DIR}))
echo "-----------------------------------"
echo "${COLOR_YELLOW} Check logs for main services ${COLOR_RESET}"
echo "-----------------------------------"
for file in ${ARRAY_MAIN_SERVICES_LOGS[@]}; do
echo ---------------------------------------
echo "${COLOR_GREEN}logs from file: ${file}${COLOR_RESET}"
echo ---------------------------------------
cat ${MAIN_LOGS_DIR}/${file} || true
done
echo "-----------------------------------"
echo "${COLOR_YELLOW} Check logs for Docservice ${COLOR_RESET}"
echo "-----------------------------------"
for file in ${ARRAY_DOCSERVICE_LOGS[@]}; do
echo ---------------------------------------
echo "${COLOR_GREEN}logs from file: ${file}${COLOR_RESET}"
echo ---------------------------------------
cat ${DOCSERVICE_LOGS_DIR}/${file} || true
done
echo "-----------------------------------"
echo "${COLOR_YELLOW} Check logs for Converter ${COLOR_RESET}"
echo "-----------------------------------"
for file in ${ARRAY_CONVERTER_LOGS[@]}; do
echo ---------------------------------------
echo "${COLOR_GREEN}logs from file ${file}${COLOR_RESET}"
echo ---------------------------------------
cat ${CONVERTER_LOGS_DIR}/${file} || true
done
echo "-----------------------------------"
echo "${COLOR_YELLOW} Start logs for Metrics ${COLOR_RESET}"
echo "-----------------------------------"
for file in ${ARRAY_METRICS_LOGS[@]}; do
echo ---------------------------------------
echo "${COLOR_GREEN}logs from file ${file}${COLOR_RESET}"
echo ---------------------------------------
cat ${METRICS_LOGS_DIR}/${file} || true
done
echo "-----------------------------------"
echo "${COLOR_YELLOW} Start logs for DocSpace ${COLOR_RESET}"
echo "-----------------------------------"
for file in ${ARRAY_DOCSPACE_LOGS[@]}; do
echo ---------------------------------------
echo "${COLOR_GREEN}logs from file ${file}${COLOR_RESET}"
echo ---------------------------------------
cat ${DOCSPACE_LOGS_DIR}/${file} || true
done
}
function healthcheck_docker_installation() {
exit 0
}
main() {
common::get_colors
prepare_vm
check_hw
install_docspace
sleep 120
services_logs
healthcheck_systemd_services
healthcheck_general_status
}
main