Skip to content

Commit

Permalink
Maintenance: Automate testing of packager.io packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mgruner committed Oct 9, 2024
1 parent 0b11fbf commit 25bdaa1
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitlab/ci/test/packager.io.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.packager.io:
image: docker
stage: test
interruptible: false
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"
services: []
cache: []
before_script: []
script:
- .gitlab/packager.io/run-scenarios.sh
after_script:
- .gitlab/packager.io/cleanup.sh

packager.io:debian-11:
extends: [.packager.io]
variables:
DISTRIBUTION: debian
DISTRIBUTION_VERSION: '11'

packager.io:debian-12:
extends: [.packager.io]
variables:
DISTRIBUTION: debian
DISTRIBUTION_VERSION: '12'

packager.io:ubuntu-20.04:
extends: [.packager.io]
variables:
DISTRIBUTION: ubuntu
DISTRIBUTION_VERSION: '20.04'

packager.io:ubuntu-22.04:
extends: [.packager.io]
variables:
DISTRIBUTION: ubuntu
DISTRIBUTION_VERSION: '22.04'

packager.io:ubuntu-24.04:
extends: [.packager.io]
variables:
DISTRIBUTION: ubuntu
DISTRIBUTION_VERSION: '24.04'

packager.io:rhel-8:
extends: [.packager.io]
variables:
DISTRIBUTION: rhel
DISTRIBUTION_VERSION: '8'

packager.io:rhel-9:
extends: [.packager.io]
variables:
DISTRIBUTION: rhel
DISTRIBUTION_VERSION: '9'

packager.io:sles-15:
extends: [.packager.io]
variables:
DISTRIBUTION: sles
DISTRIBUTION_VERSION: '15'
15 changes: 15 additions & 0 deletions .gitlab/packager.io/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -eu

cd "$(dirname $0)"

docker compose down --timeout 0
docker volume prune --all --force

DELETE_IMAGES=$(docker image ls "zammad-packagerio-ci-${CI_JOB_ID}" -q)
if [ -n "$DELETE_IMAGES" ]
then
# shellcheck disable=SC2086
docker image rm $DELETE_IMAGES
fi
16 changes: 16 additions & 0 deletions .gitlab/packager.io/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: zammad-packagerio-ci-${CI_JOB_ID}
services:
zammad:
image: zammad-packagerio-ci-${CI_JOB_ID}:${DISTRIBUTION}-${DISTRIBUTION_VERSION}
build:
context: "."
platforms: ["linux/amd64"]
dockerfile: dockerfiles/Dockerfile.${DISTRIBUTION}
args:
DISTRIBUTION: ${DISTRIBUTION}
DISTRIBUTION_VERSION: ${DISTRIBUTION_VERSION}
CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}
privileged: true
restart: unless-stopped
expose: ["80"]
9 changes: 9 additions & 0 deletions .gitlab/packager.io/dockerfiles/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG DISTRIBUTION_VERSION
FROM docker.io/library/debian:${DISTRIBUTION_VERSION}
ARG DISTRIBUTION
ARG DISTRIBUTION_VERSION
ARG CI_COMMIT_REF_NAME
ADD dockerfiles dockerfiles
ADD scenarios scenarios
RUN bash /dockerfiles/bootstrap.debian.sh
ENTRYPOINT [ "/sbin/init" ]
9 changes: 9 additions & 0 deletions .gitlab/packager.io/dockerfiles/Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG DISTRIBUTION_VERSION
FROM docker.io/library/rockylinux:${DISTRIBUTION_VERSION}
ARG DISTRIBUTION
ARG DISTRIBUTION_VERSION
ARG CI_COMMIT_REF_NAME
ADD dockerfiles dockerfiles
ADD scenarios scenarios
RUN bash /dockerfiles/bootstrap.rhel.sh
ENTRYPOINT [ "/sbin/init" ]
9 changes: 9 additions & 0 deletions .gitlab/packager.io/dockerfiles/Dockerfile.sles
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG DISTRIBUTION_VERSION
FROM docker.io/opensuse/leap:${DISTRIBUTION_VERSION}
ARG DISTRIBUTION
ARG DISTRIBUTION_VERSION
ARG CI_COMMIT_REF_NAME
ADD dockerfiles dockerfiles
ADD scenarios scenarios
RUN bash /dockerfiles/bootstrap.sles.sh
ENTRYPOINT [ "/sbin/init" ]
9 changes: 9 additions & 0 deletions .gitlab/packager.io/dockerfiles/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG DISTRIBUTION_VERSION
FROM docker.io/library/ubuntu:${DISTRIBUTION_VERSION}
ARG DISTRIBUTION
ARG DISTRIBUTION_VERSION
ARG CI_COMMIT_REF_NAME
ADD dockerfiles dockerfiles
ADD scenarios scenarios
RUN bash /dockerfiles/bootstrap.ubuntu.sh
ENTRYPOINT [ "/sbin/init" ]
12 changes: 12 additions & 0 deletions .gitlab/packager.io/dockerfiles/bootstrap.debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/bash

set -eu

export DEBIAN_FRONTEND=noninteractive

cd "$(dirname $0)"

bash ./shared.deb.sh

echo "deb [signed-by=/usr/share/keyrings/zammad-archive-keyring.gpg] https://dl.packager.io/srv/deb/zammad/zammad/${CI_COMMIT_REF_NAME}/debian ${DISTRIBUTION_VERSION} main" > /etc/apt/sources.list.d/zammad.list
apt-get update && apt-get install -y --download-only zammad
26 changes: 26 additions & 0 deletions .gitlab/packager.io/dockerfiles/bootstrap.rhel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/bash

set -eu

dnf update -y

dnf install -y systemd epel-release

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
echo "[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md"| tee /etc/yum.repos.d/elasticsearch-7.x.repo
dnf install -y elasticsearch

rpm --import https://dl.packager.io/srv/zammad/zammad/key

curl -o /etc/yum.repos.d/zammad.repo \
https://dl.packager.io/srv/zammad/zammad/${CI_COMMIT_REF_NAME}/installer/el/${DISTRIBUTION_VERSION}.repo

dnf update -y
dnf install -y --downloadonly zammad
26 changes: 26 additions & 0 deletions .gitlab/packager.io/dockerfiles/bootstrap.sles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/bash

set -eu

zypper update -y

zypper install -y systemd

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
echo "[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md"| tee /etc/zypp/repos.d/elasticsearch-7.x.repo
zypper install -y elasticsearch

rpm --import https://dl.packager.io/srv/zammad/zammad/key

curl -o /etc/zypp/repos.d/zammad.repo \
https://dl.packager.io/srv/zammad/zammad/${CI_COMMIT_REF_NAME}/installer/sles/${DISTRIBUTION_VERSION}.repo

zypper update -y
zypper install -y --download-only zammad
12 changes: 12 additions & 0 deletions .gitlab/packager.io/dockerfiles/bootstrap.ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/bash

set -eu

export DEBIAN_FRONTEND=noninteractive

cd "$(dirname $0)"

bash ./shared.deb.sh

echo "deb [signed-by=/usr/share/keyrings/zammad-archive-keyring.gpg] https://dl.packager.io/srv/deb/zammad/zammad/${CI_COMMIT_REF_NAME}/ubuntu ${DISTRIBUTION_VERSION} main" > /etc/apt/sources.list.d/zammad.list
apt-get update && apt-get install -y --download-only zammad
18 changes: 18 additions & 0 deletions .gitlab/packager.io/dockerfiles/shared.deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/bash

set -ex

apt-get update && apt-get dist-upgrade -y
apt-get install -y systemd systemd-sysv
rm -f /usr/sbin/policy-rc.d

apt-get install -y curl gnupg2
echo "deb [signed-by=/etc/apt/trusted.gpg.d/elasticsearch.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | \
tee -a /etc/apt/sources.list.d/elastic-7.x.list > /dev/null
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | \
gpg --dearmor | tee /etc/apt/trusted.gpg.d/elasticsearch.gpg> /dev/null
apt-get update
apt-get -y install elasticsearch

curl -1sLf https://dl.packager.io/srv/zammad/zammad/key | \
gpg --dearmor -o /usr/share/keyrings/zammad-archive-keyring.gpg
26 changes: 26 additions & 0 deletions .gitlab/packager.io/run-scenarios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

set -eu

: "${DISTRIBUTION:=debian}"
: "${DISTRIBUTION_VERSION:=12}"
: "${CI_JOB_ID:=1}"
: "${CI_COMMIT_REF_NAME:=develop}"

export DISTRIBUTION DISTRIBUTION_VERSION CI_JOB_ID CI_COMMIT_REF_NAME

echo "Running tests for ${CI_COMMIT_REF_NAME} on ${DISTRIBUTION}-${DISTRIBUTION_VERSION}"

cd "$(dirname $0)"

docker compose build

# shellcheck disable=SC2043
for SCENARIO in $(cd scenarios; ls -1)
do
docker compose down --timeout 0
docker compose up -d
docker compose exec zammad bash "/scenarios/${SCENARIO}/${DISTRIBUTION}.sh"
docker compose down --timeout 0
done
./cleanup.sh
7 changes: 7 additions & 0 deletions .gitlab/packager.io/scenarios/internal-services/debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/bash

set -eu

cd "$(dirname $0)"

bash ./shared.deb.sh
11 changes: 11 additions & 0 deletions .gitlab/packager.io/scenarios/internal-services/rhel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/bash

set -eu

dnf install -y zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"

dnf reinstall -y zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"
13 changes: 13 additions & 0 deletions .gitlab/packager.io/scenarios/internal-services/shared.deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/bash

set -eu

export DEBIAN_FRONTEND=noninteractive

apt-get install -y zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"

apt-get install -y --reinstall zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"
17 changes: 17 additions & 0 deletions .gitlab/packager.io/scenarios/internal-services/sles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/bash

set -eu

# special handling for Redis on SuSE
zypper install -y redis7
cp /etc/redis/default.conf.example /etc/redis/zammad.conf
chown root:redis /etc/redis/zammad.conf
systemctl start [email protected]

zypper install -y zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"

zypper install -y -f zammad

curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:3000 | grep "Zammad Helpdesk"
7 changes: 7 additions & 0 deletions .gitlab/packager.io/scenarios/internal-services/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/bash

set -eu

cd "$(dirname $0)"

bash ./shared.deb.sh
4 changes: 4 additions & 0 deletions .pkgr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets:
- imlib2
- shared-mime-info
- redis
- findutils
build_dependencies:
- https://download.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/i/imlib2-1.4.9-8.el8.x86_64.rpm
- https://download.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/i/imlib2-devel-1.4.9-8.el8.x86_64.rpm
Expand Down Expand Up @@ -112,6 +113,9 @@ targets:
# Because on SUSE systems, this service is arbitrarily named (e.g.) [email protected]
# So we cannot hardcode the service name as we do for other supported distros.
- psmisc
- procps
- libopenssl1_1
- which
build_dependencies:
# Add packages required for build that are not in the official SLES repo.
# Direct URLs must be used since we cannot add repos on packager.io
Expand Down

0 comments on commit 25bdaa1

Please sign in to comment.