[monitoring-plugins] migrate travis ci to github actions

Sven Nierlein git at monitoring-plugins.org
Fri Apr 30 10:00:13 CEST 2021


 Module: monitoring-plugins
 Branch: feature_github_actions
 Commit: fc71e3f9304ed51f3fd7ca544f38a30a590c8ba5
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Tue Apr 13 09:15:12 2021 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=fc71e3f

migrate travis ci to github actions

---

 .../t/NPTest.cache.travis => .github/NPTest.cache  |  8 +-
 .github/prepare_debian.sh                          | 99 ++++++++++++++++++++++
 .github/workflows/test.yml                         | 77 +++++++++++++++++
 .travis.yml                                        | 98 ---------------------
 4 files changed, 180 insertions(+), 102 deletions(-)

diff --git a/plugins/t/NPTest.cache.travis b/.github/NPTest.cache
similarity index 91%
rename from plugins/t/NPTest.cache.travis
rename to .github/NPTest.cache
index 9b9f805..232305a 100644
--- a/plugins/t/NPTest.cache.travis
+++ b/.github/NPTest.cache
@@ -11,7 +11,7 @@
   'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
   'NP_HOSTNAME_VALID' => 'monitoring-plugins.org',
   'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
-  'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
+  'NP_HOST_NONRESPONSIVE' => '192.168.1.2',
   'NP_HOST_RESPONSIVE' => 'localhost',
   'NP_HOST_SMB' => '',
   'NP_HOST_SNMP' => '',
@@ -27,12 +27,12 @@
   'NP_HOST_TCP_SMTP' => 'localhost',
   'NP_HOST_TCP_SMTP_NOTLS' => '',
   'NP_HOST_TCP_SMTP_TLS' => '',
-  'NP_HOST_TLS_CERT' => 'localhost,
+  'NP_HOST_TLS_CERT' => 'localhost',
   'NP_HOST_TLS_HTTP' => 'localhost',
   'NP_HOST_UDP_TIME' => 'none',
   'NP_INTERNET_ACCESS' => 'yes',
-  'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain',
-  'NP_MOUNTPOINT2_VALID' => '/media/ramdisk',
+  'NP_LDAP_BASE_DN' => 'dc=nodomain',
+  'NP_MOUNTPOINT2_VALID' => '/media/ramdisk1',
   'NP_MOUNTPOINT_VALID' => '/',
   'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test',
   'NP_MYSQL_SERVER' => 'localhost',
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
new file mode 100755
index 0000000..4005320
--- /dev/null
+++ b/.github/prepare_debian.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+set -x
+set -e
+
+export DEBIAN_FRONTEND=noninteractive
+
+apt-get update
+apt-get -y install software-properties-common
+if [ $(lsb_release -is) = "Debian" ]; then
+  apt-add-repository non-free
+  apt-get update
+fi
+apt-get -y install perl autotools-dev libdbi-dev libldap2-dev libpq-dev libradcli-dev libnet-snmp-perl procps
+apt-get -y install libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
+apt-get -y install fping snmp netcat smbclient vsftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl
+apt-get -y install libdbd-sybase-perl libnet-dns-perl
+apt-get -y install slapd ldap-utils
+apt-get -y install gcc make autoconf automake gettext
+apt-get -y install faketime
+apt-get -y install libmonitoring-plugin-perl
+apt-get -y install libcurl4-openssl-dev
+apt-get -y install liburiparser-dev
+apt-get -y install squid
+apt-get -y install openssh-server
+apt-get -y install mariadb-server mariadb-client libmariadb-dev
+apt-get -y install cron iputils-ping
+apt-get -y install iproute2
+
+# remove ipv6 interface from hosts
+if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then
+    sed '/^::1/d' /etc/hosts > /tmp/hosts
+    cp -f /tmp/hosts /etc/hosts
+fi
+
+ip addr show
+
+cat /etc/hosts
+
+
+# apache
+a2enmod ssl
+a2ensite default-ssl
+make-ssl-cert generate-default-snakeoil --force-overwrite
+service apache2 start
+
+# squid
+cp tools/squid.conf /etc/squid/squid.conf
+service squid start
+
+# mariadb
+service mariadb start
+mysql -e "create database IF NOT EXISTS test;" -uroot
+
+# ldap
+sed -e 's/cn=admin,dc=nodomain/'$(/usr/sbin/slapcat|grep ^dn:|awk '{print $2}')'/' -i .github/NPTest.cache
+service slapd start
+
+# sshd
+ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
+cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
+service ssh start
+sleep 1
+ssh-keyscan localhost >> ~/.ssh/known_hosts
+touch ~/.ssh/config
+
+# start one login session, required for check_users
+( ssh -n -tt root at localhost "top" < /dev/null >/dev/null 2>&1 & )
+sleep 1
+who
+ssh root at localhost "top -b -n 1"
+
+# snmpd
+for DIR in /usr/share/snmp/mibs /usr/share/mibs; do
+    rm -f $DIR/ietf/SNMPv2-PDU \
+          $DIR/ietf/IPSEC-SPD-MIB \
+          $DIR/ietf/IPATM-IPMC-MIB \
+          $DIR/iana/IANA-IPPM-METRICS-REGISTRY-MIB
+done
+mkdir -p /var/lib/snmp/mib_indexes
+sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf
+service snmpd start
+
+# start cron, will be used by check_nagios
+cron
+
+# start postfix
+service postfix start
+
+# start ftpd
+service vsftpd start
+
+# hostname
+sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i /src/.github/NPTest.cache
+
+# create some test files to lower inodes
+for i in $(seq 10); do
+    touch /media/ramdisk2/test.$1
+done
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..4c3497d
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,77 @@
+name: Test
+
+on:
+  push:
+    branches:
+      - '*'
+  pull_request:
+
+jobs:
+#  macos:
+#    name: Running tests on ${{ matrix.os }}
+#    strategy:
+#      fail-fast: false
+#      matrix:
+#        os:
+#          - macos-10.15
+#    runs-on: ${{ matrix.os }}
+#    steps:
+#
+#      - name: Git clone repository
+#        uses: actions/checkout at v2
+#      #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
+#      #  uses: mxschmitt/action-tmate at v3
+#      - name: Prepare machine
+#        run:  |
+#          brew install automake
+#      - name: Run the tests
+#        run:  |
+#          tools/setup \
+#          && ./configure --enable-libtap \
+#          && make \
+#          && make test
+
+  linux:
+    runs-on: ubuntu-latest
+    name: Running tests on ${{ matrix.distro }}
+    strategy:
+      fail-fast: false
+      matrix:
+        distro:
+          #- 'debian:10'
+          - 'debian:testing'
+          #- 'ubuntu:20.10'
+          #- 'centos:7'
+          #- 'centos:8'
+        include:
+          #- distro: 'debian:10'
+          #  prepare: .github/prepare_debian.sh
+          - distro: 'debian:testing'
+            prepare: .github/prepare_debian.sh
+          #- distro: 'ubuntu:20.10'
+          #  prepare: .github/prepare_debian.sh
+          #- distro: 'centos:7'
+          #  prepare: .github/prepare_centos.sh
+          #- distro: 'centos:8'
+          #  prepare: .github/prepare_centos.sh
+    steps:
+      - name: Git clone repository
+        uses: actions/checkout at v2
+      #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
+      #  uses: mxschmitt/action-tmate at v3
+      - name: Run the tests on ${{ matrix.distro }}
+        run: |
+          docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 tmp-vol
+          docker run \
+              -e NPTEST_ACCEPTDEFAULT=1 \
+              -e NPTEST_CACHE="/src/.github/NPTest.cache" \
+              -w /src -v ${PWD}:/src \
+              --tmpfs /media/ramdisk1 \
+              --mount source=tmp-vol,destination=/src,target=/media/ramdisk2 \
+              ${{ matrix.distro }} \
+              /bin/sh -c '${{ matrix.prepare }} && \
+                tools/setup && \
+                ./configure --enable-libtap && \
+                make && \
+                make test'
+          docker volume rm tmp-vol
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 3d9fe64..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,98 +0,0 @@
-sudo: required
-dist: xenial
-language: c
-
-env:
-  global:
-    # This is the encrypted COVERITY_SCAN_TOKEN, created via the "travis
-    # encrypt" command using the project repository's public key.
-    - secure: "ggJ9c/VfKcwtrwz/My+ne4My7D8g3qi3vz5Hh+yLiri0+oIXCy313ZD6ssIEY/5beQZEOnuHhBgBJd/Y3clSQNc2M9fRNc+wxOkIO992lgnY0MZJN3y9MLfpqUbTClhU9Fst0qXQqGpI6UI8yz1tj7yKi7DPrycJLRrjMpyTfyo="
-
-matrix:
-  include:
-    - compiler: "gcc"
-      os: linux
-      env:
-        - PLATFORM=linux BITS=64 HOST=x86_64
-      addons:
-        coverity_scan:
-          project:
-            name: "monitoring-plugins/monitoring-plugins"
-            description: "Monitoring Plugins"
-          notification_email: team at monitoring-plugins.org
-          build_command_prepend: tools/setup && ./configure
-          build_command: make
-          branch_pattern: coverity.*
-    - compiler: "clang"
-      os: linux
-      env:
-        - PLATFORM=linux BITS=64 HOST=x86_64
-
-before_install:
-  # Trusty related fixed
-  # multiverse is no on trusty activated (https://github.com/travis-ci/travis-ci/issues/4979)
-  - sudo apt-get install -qq --no-install-recommends software-properties-common
-  - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-updates multiverse"
-  # /etc/hosts has IPv6 hosts (https://github.com/travis-ci/travis-ci/issues/4978)
-  - sudo [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ] || sudo sed -i '/^::1/d' /etc/hosts
-  # Trusty has running ntpd on localhost, but we don't like that for our tests
-  - "sudo killall -9 ntpd ||:"
-  # Trusty has no swap, lets create some
-  - sudo fallocate -l 20M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile
-  - sudo apt-get update -qq
-  - sudo apt-get purge -qq gawk
-
-install:
-  - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps
-  - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
-  - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl
-  - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl
-  - sudo apt-get install -qq --no-install-recommends slapd ldap-utils
-  - sudo apt-get install -qq --no-install-recommends autoconf automake
-  - sudo apt-get install -qq --no-install-recommends faketime
-  - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl
-  - sudo apt-get install -qq --no-install-recommends libcurl4-openssl-dev
-  - sudo apt-get install -qq --no-install-recommends liburiparser-dev
-  - sudo apt-get install -qq --no-install-recommends squid
-  # Trusty related dependencies (not yet provided)
-  - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server
-  # enable ssl apache
-  - sudo a2enmod ssl
-  - sudo a2ensite default-ssl
-  - sudo make-ssl-cert generate-default-snakeoil --force-overwrite
-  - sudo service apache2 reload
-  - sudo cp tools/squid.conf /etc/squid/squid.conf
-  - sudo service squid reload
-  - sudo service mysql restart
-
-before_script:
-  # ensure we have a test database in place for tests
-  - mysql -e "create database IF NOT EXISTS test;" -uroot
-  # Detect LDAP configuration (seems  volatile on trusty env)
-  - sed -e 's/cn=admin,dc=nodomain/'$(sudo /usr/sbin/slapcat|grep ^dn:|grep cn=|awk '{print $2}')'/' -i plugins/t/NPTest.cache.travis
-  - tools/setup
-  - ./configure --enable-libtap
-  - make
-  - export NPTEST_ACCEPTDEFAULT=1
-  - export NPTEST_CACHE="$(pwd)/plugins/t/NPTest.cache.travis"
-  - ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
-  - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
-  - ssh-keyscan localhost >> ~/.ssh/known_hosts
-  - touch ~/.ssh/config
-  - sudo rm -f /usr/share/mibs/ietf/SNMPv2-PDU /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
-  - sudo mkdir -p /var/lib/snmp/mib_indexes
-  - sudo mkdir /media/ramdisk && sudo chmod 777 /media/ramdisk && sudo mount -t tmpfs -o size=20% none /media/ramdisk
-  - sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i $NPTEST_CACHE
-
-script:
-  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make test; fi
-
-notifications:
-  irc:
-    channels:
-      - "chat.freenode.net#Monitoring-Plugins"
-    on_success: change
-    on_failure: always
-    skip_join: true
-  email:
-    # - team at monitoring-plugins.org



More information about the Commits mailing list