diff --git a/README.md b/README.md index 01cead0..3d5c146 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in CI runner of YunoHost -**Shipped version:** 2023.02.12~ynh1 +**Shipped version:** 2023.04.05~ynh1 ## Screenshots diff --git a/README_fr.md b/README_fr.md index d1095d4..883a18e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Runner d'intégration continue de YunoHost -**Version incluse :** 2023.02.12~ynh1 +**Version incluse :** 2023.04.05~ynh1 ## Captures d’écran diff --git a/check_process b/check_process index 1571f8c..7f5c3c4 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,10 @@ ;; Test complet - ; pre-install - sudo git clone --quiet https://github.com/YunoHost/CI_package_check /home/CI_package_check ; Manifest domain="domain.tld" path="/path" + context="personal-ci" + mode="manual" + cluster="no" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/yunorunner.config.py b/conf/yunorunner.config.py index eb77e8e..354c7fe 100644 --- a/conf/yunorunner.config.py +++ b/conf/yunorunner.config.py @@ -1,10 +1,10 @@ BASE_URL = "https://__DOMAIN____PATH__" PORT = __PORT__ PACKAGE_CHECK_DIR = "__FINALPATH__/package_check/" -MONITOR_APPS_LIST = False -MONITOR_GIT = False +MONITOR_APPS_LIST = __AUTO__ +MONITOR_GIT = __AUTO__ MONITOR_ONLY_GOOD_QUALITY_APPS = False -MONTHLY_JOBS = False +MONTHLY_JOBS = __AUTO__ WORKER_COUNT = 1 YNH_BRANCH = "stable" DIST = "bullseye" diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..074585b --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,6 @@ +If you want to enable Matrix notification, you should look at +the instructions inside `__FINAL_PATH__lib/chat_notify.sh` to deploy matrix-commander. + +You may also want to tweak the `__FINAL_PATH__/config.py` file to run test with a different branch or architecture. + +When you're ready to start the CI, restart its service via the webadmin or run `systemctl restart __APP__`. diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..65be331 --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,2 @@ +YunoRunner will install LXD, for containers management. +Make sure your system has virtualization capability, and enough resources. diff --git a/manifest.json b/manifest.json index e830e79..37af0ce 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CI runner of YunoHost", "fr": "Runner d'intégration continue de YunoHost" }, - "version": "2023.02.12~ynh1", + "version": "2023.04.05~ynh1", "url": "https://github.com/YunoHost/yunorunner", "upstream": { "license": "GPL-3.0-or-later", @@ -37,6 +37,33 @@ "name": "path", "type": "path", "default": "/ci" + }, + { + "name": "context", + "type": "select", + "choices": ["personal-ci", "official-infra"], + "default": "personal-ci", + "ask": { + "en": "Leave it to 'personal-ci'. If set to 'official-infra', Yunorunner will take over your server and disable vital services to run alone." + } + }, + { + "name": "mode", + "type": "select", + "choices": ["auto", "manual"], + "default": "manual", + "ask": { + "en": "Should the jobs be automatically run from the apps list? In manual mode, Yunorunner will expect to be triggered by the `ciclic` command or webhooks (like ci-apps-dev). In auto mode, all apps of the catalog will be scheduled to be tested at least once a month and upon any change in their designated main branch (like ci-apps)." + } + }, + { + "name": "cluster", + "type": "select", + "choices": ["cluster", "no"], + "default": "no", + "ask": { + "en": "Should an LXD cluster be created with this server as first node? (cluster mode is experimental)" + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 16d4bd7..dd5a08b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,12 +9,118 @@ pkg_dependencies="python3-venv python3-dev python3-pip sqlite3 wkhtmltopdf optip yunorunner_repository="https://github.com/YunoHost/yunorunner" -yunorunner_release="50ae066741b8a7e845b691eac1045406b1ee7f16" +yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927" #================================================= # PERSONAL HELPERS #================================================= +function tweak_yunohost() { + + # Idk why this is needed but wokay I guess >_> + echo -e "\n127.0.0.1 $domain #CI_APP" >> /etc/hosts + + ynh_print_info "Disabling unecessary services to save up RAM..." + for SERVICE in mysql php7.4-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon + do + systemctl stop $SERVICE + systemctl disable $SERVICE --quiet + done + + yunohost app makedefault -d "$domain" $app + +} + +function setup_lxd() { + if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null + then + ynh_script_progression --message="Installing LXD... (this make take a long time!" + yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh + fi + + mkdir .lxd + pushd .lxd + + ynh_print_info "Configuring lxd..." + + if [ "$cluster" == "cluster" ] + then + local free_space=$(df --output=avail / | sed 1d) + local btrfs_size=$(( $free_space * 90 / 100 / 1024 / 1024 )) + local lxc_network=$((1 + $RANDOM % 254)) + + yunohost firewall allow TCP 8443 + cat >./preseed.conf <> "/etc/cron.d/yunorunner" << EOF +# self-upgrade every night +0 3 * * * root "$final_path/maintenance/self_upgrade.sh" >> "$final_path/maintenance/self_upgrade.log" 2>&1 +EOF +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 7a8381d..5445d22 100644 --- a/scripts/install +++ b/scripts/install @@ -25,6 +25,9 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH +context=$YNH_APP_ARG_CONTEXT +mode=$YNH_APP_ARG_MODE +cluster=$YNH_APP_ARG_CLUSTER app=$YNH_APP_INSTANCE_NAME @@ -87,6 +90,8 @@ pushd "$final_path" ynh_exec_as $app git remote add origin "$yunorunner_repository" ynh_exec_as $app git fetch --quiet --depth=1 origin "$yunorunner_release" ynh_exec_as $app git reset --quiet --hard FETCH_HEAD + setup_lxd + git clone https://github.com/YunoHost/package_check "./package_check" popd chmod 750 "$final_path" @@ -121,11 +126,28 @@ popd #================================================= ynh_script_progression --message="Adding a config file..." +if [ $mode = "auto" ]; then + auto="True" +else + auto="False" +fi + ynh_add_config --template="yunorunner.config.py" --destination="$final_path/config.py" chmod 400 "$final_path/config.py" chown $app:$app "$final_path/config.py" +#================================================= +# FINISH INSTALL +#================================================= +ynh_script_progression --message="Run Yunorunner's finish_install script..." + +if [ $context != "personal-ci" ] && [ ${PACKAGE_CHECK_EXEC:-0} -ne 0 ]; then + tweak_yunohost +fi + +add_cron_jobs + #================================================= # SETUP SYSTEMD #=================================================