1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00

Merge pull request #50 from YunoHost-Apps/ci-auto-update-v2023.04.05

Upgrade to version 2023.04.05
This commit is contained in:
Alexandre Aubin 2023-09-10 00:29:11 +02:00 committed by GitHub
commit 338438d8e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 173 additions and 9 deletions

View file

@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
CI runner of YunoHost CI runner of YunoHost
**Shipped version:** 2023.02.12~ynh1 **Shipped version:** 2023.04.05~ynh1
## Screenshots ## Screenshots

View file

@ -18,7 +18,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
Runner d'intégration continue de YunoHost Runner d'intégration continue de YunoHost
**Version incluse :** 2023.02.12~ynh1 **Version incluse :** 2023.04.05~ynh1
## Captures décran ## Captures décran

View file

@ -1,9 +1,10 @@
;; Test complet ;; Test complet
; pre-install
sudo git clone --quiet https://github.com/YunoHost/CI_package_check /home/CI_package_check
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
context="personal-ci"
mode="manual"
cluster="no"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -1,10 +1,10 @@
BASE_URL = "https://__DOMAIN____PATH__" BASE_URL = "https://__DOMAIN____PATH__"
PORT = __PORT__ PORT = __PORT__
PACKAGE_CHECK_DIR = "__FINALPATH__/package_check/" PACKAGE_CHECK_DIR = "__FINALPATH__/package_check/"
MONITOR_APPS_LIST = False MONITOR_APPS_LIST = __AUTO__
MONITOR_GIT = False MONITOR_GIT = __AUTO__
MONITOR_ONLY_GOOD_QUALITY_APPS = False MONITOR_ONLY_GOOD_QUALITY_APPS = False
MONTHLY_JOBS = False MONTHLY_JOBS = __AUTO__
WORKER_COUNT = 1 WORKER_COUNT = 1
YNH_BRANCH = "stable" YNH_BRANCH = "stable"
DIST = "bullseye" DIST = "bullseye"

6
doc/POST_INSTALL.md Normal file
View file

@ -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__`.

2
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1,2 @@
YunoRunner will install LXD, for containers management.
Make sure your system has virtualization capability, and enough resources.

View file

@ -6,7 +6,7 @@
"en": "CI runner of YunoHost", "en": "CI runner of YunoHost",
"fr": "Runner d'intégration continue de 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", "url": "https://github.com/YunoHost/yunorunner",
"upstream": { "upstream": {
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
@ -37,6 +37,33 @@
"name": "path", "name": "path",
"type": "path", "type": "path",
"default": "/ci" "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)"
}
} }
] ]
} }

View file

@ -9,12 +9,118 @@ pkg_dependencies="python3-venv python3-dev python3-pip sqlite3 wkhtmltopdf optip
yunorunner_repository="https://github.com/YunoHost/yunorunner" yunorunner_repository="https://github.com/YunoHost/yunorunner"
yunorunner_release="50ae066741b8a7e845b691eac1045406b1ee7f16" yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927"
#================================================= #=================================================
# PERSONAL HELPERS # 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 <<EOF
config:
cluster.https_address: $domain:8443
core.https_address: ${domain}:8443
core.trust_password: ${yuno_pwd}
networks:
- config:
ipv4.address: 192.168.${lxc_network}.1/24
ipv4.nat: "true"
ipv6.address: none
description: ""
name: lxdbr0
type: bridge
project: default
storage_pools:
- config:
size: ${btrfs_size}GB
source: /var/lib/lxd/disks/local.img
description: ""
name: local
driver: btrfs
profiles:
- config: {}
description: Default LXD profile
devices:
lxdbr0:
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: local
type: disk
name: default
projects:
- config:
features.images: "true"
features.networks: "true"
features.profiles: "true"
features.storage.volumes: "true"
description: Default LXD project
name: default
cluster:
server_name: ${domain}
enabled: true
EOF
cat ./preseed.conf | lxd init --preseed
rm ./preseed.conf
lxc config set core.https_address [::]
else
lxd init --auto #--storage-backend=dir
fi
popd
# ci_user will be the one launching job, gives it permission to run lxd commands
usermod -a -G lxd $app
ynh_exec_as $app lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate
}
function add_cron_jobs() {
ynh_script_progression --message="Configuring the cron jobs.."
# Cron tasks
cat >> "/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 # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -25,6 +25,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH 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 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 remote add origin "$yunorunner_repository"
ynh_exec_as $app git fetch --quiet --depth=1 origin "$yunorunner_release" ynh_exec_as $app git fetch --quiet --depth=1 origin "$yunorunner_release"
ynh_exec_as $app git reset --quiet --hard FETCH_HEAD ynh_exec_as $app git reset --quiet --hard FETCH_HEAD
setup_lxd
git clone https://github.com/YunoHost/package_check "./package_check"
popd popd
chmod 750 "$final_path" chmod 750 "$final_path"
@ -121,11 +126,28 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Adding a config file..." 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" ynh_add_config --template="yunorunner.config.py" --destination="$final_path/config.py"
chmod 400 "$final_path/config.py" chmod 400 "$final_path/config.py"
chown $app:$app "$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 # SETUP SYSTEMD
#================================================= #=================================================