From e716e12a7150481e3cd8a541b75726f87188a1a9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 25 Mar 2023 17:36:27 +0100 Subject: [PATCH] reorganize dependencies installation --- .forgejo/workflows/integration.yml | 3 +-- dependencies.sh | 43 ++++++++++++++++++++++++++++++ docker.sh | 12 --------- lxc.sh | 23 ---------------- testdata/run.sh | 5 +++- 5 files changed, 48 insertions(+), 38 deletions(-) create mode 100755 dependencies.sh delete mode 100755 docker.sh delete mode 100755 lxc.sh diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index bf7b502..556f59f 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -6,8 +6,7 @@ jobs: - uses: actions/checkout@v3 - run: | set -x - ./lxc.sh - ./docker.sh + ./dependencies.sh ./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19 ./forgejo-runner.sh setup # testdata/run.sh workflow http://root:admin1234@$(cat forgejo-ip):3000 root demo diff --git a/dependencies.sh b/dependencies.sh new file mode 100755 index 0000000..6848c53 --- /dev/null +++ b/dependencies.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -x + +function install_docker() { + if ! systemctl is-active --quiet docker; then + echo deb http://deb.debian.org/debian bullseye-backports main | tee /etc/apt/sources.list.d/backports.list && apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --quiet -y -t bullseye-backports git docker.io + fi +} + +function install_lxc() { + if ! systemctl is-active --quiet lxc-net; then + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y -qq make git libvirt0 libpam-cgfs bridge-utils uidmap dnsmasq-base dnsmasq dnsmasq-utils qemu-user-static + systemctl disable --now dnsmasq + apt-get install -y -qq lxc + systemctl stop lxc-net + cat >> /etc/default/lxc-net <<'EOF' +LXC_ADDR="10.0.7.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.7.0/24" +LXC_DHCP_RANGE="10.0.7.2,10.0.7.254" +LXC_DHCP_MAX="253" +EOF + systemctl start lxc-net + fi +} + +function install_other() { + local packages="sudo" + if ! which $packages ; then + apt-get install -y -qq $packages + fi +} + +function setup() { + install_docker + install_lxc + install_other +} + +setup diff --git a/docker.sh b/docker.sh deleted file mode 100755 index bfbee07..0000000 --- a/docker.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -x - -setup() { - if ! systemctl is-active --quiet docker; then - echo deb http://deb.debian.org/debian bullseye-backports main | tee /etc/apt/sources.list.d/backports.list && apt-get update - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --quiet -y -t bullseye-backports git docker.io - fi -} - -setup diff --git a/lxc.sh b/lxc.sh deleted file mode 100755 index 93886c6..0000000 --- a/lxc.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -x - -setup() { - if ! systemctl is-active --quiet lxc-net; then - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq make git libvirt0 libpam-cgfs bridge-utils uidmap dnsmasq-base dnsmasq dnsmasq-utils qemu-user-static - systemctl disable --now dnsmasq - apt-get install -y -qq lxc - systemctl stop lxc-net - cat >> /etc/default/lxc-net <<'EOF' -LXC_ADDR="10.0.7.1" -LXC_NETMASK="255.255.255.0" -LXC_NETWORK="10.0.7.0/24" -LXC_DHCP_RANGE="10.0.7.2,10.0.7.254" -LXC_DHCP_MAX="253" -EOF - systemctl start lxc-net - fi -} - -setup diff --git a/testdata/run.sh b/testdata/run.sh index 21090ed..9f63cb9 100755 --- a/testdata/run.sh +++ b/testdata/run.sh @@ -31,7 +31,10 @@ function wait_success() { fi sleep 1 done - test "$(check_status "$forgejo" "$repo" "$sha")" = "success" + if ! test "$(check_status "$forgejo" "$repo" "$sha")" = "success" ; then + cat forgejo-runner.log + return 1 + fi } function push() {