]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CI: Add package install tests.
authorDavid Petera <david.petera@nic.cz>
Wed, 7 May 2025 14:02:09 +0000 (16:02 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 23 May 2025 13:13:43 +0000 (15:13 +0200)
We are checking that generated BIRD packages can be installed and run.
Communication between bird and birdc is also tested.

This fixes #202

.gitlab-ci.yml
misc/gitlab/template.yml.j2
tools/test-install [new file with mode: 0755]

index df06e06087364d575c5c2edd897f7a15cf8065f1..dc252d36b7ac6c7f42799dcd3ec03b0bcc024ccb 100644 (file)
@@ -23,6 +23,7 @@ stages:
   - image
   - build
   - pkg
+  - install
   - test
 
 ## Common rules
@@ -618,7 +619,6 @@ build-release:
     - if python3 -m venv venv; then . venv/bin/activate; fi
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.deb
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -636,7 +636,6 @@ build-release:
     - pip3 install beautifulsoup4==4.11.2
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.deb
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -648,7 +647,6 @@ build-release:
   script:
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.rpm
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -663,7 +661,6 @@ build-release:
     - pip3 install beautifulsoup4==4.11.2
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.rpm
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -931,6 +928,232 @@ pkg-ubuntu-24.10-amd64:
   image: registry.nic.cz/labs/bird:ubuntu-24.10-amd64
 
 
+## Package installability checks
+
+.install-deb: &install-deb
+  <<: *test-job
+  stage: install
+  script:
+    # check that bird is _not_ installed now
+    - |
+      if bird --version >/dev/null 2>&1; then
+        echo "Error: bird unexpectedly installed"
+        exit 1
+      fi
+    # install packages
+    - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')'
+    # test that install is correct
+    - ./tools/test-install "$CI_COMMIT_MESSAGE"
+
+.install-rpm: &install-rpm
+  <<: *test-job
+  stage: install
+  script:
+    # check that bird is _not_ installed now
+    - |
+      if bird --version >/dev/null 2>&1; then
+        echo "Error: bird unexpectedly installed"
+        exit 1
+      fi
+    # install packages
+    - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')'
+    # test that install is correct
+    - ./tools/test-install "$CI_COMMIT_MESSAGE"
+
+
+install-centos-7-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-centos-7-amd64
+  image: registry.nic.cz/labs/bird:centos-7-amd64
+
+install-centos-8-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-centos-8-amd64
+  image: registry.nic.cz/labs/bird:centos-8-amd64
+
+install-fedora-32-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-32-amd64
+  image: registry.nic.cz/labs/bird:fedora-32-amd64
+
+install-fedora-33-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-33-amd64
+  image: registry.nic.cz/labs/bird:fedora-33-amd64
+
+install-opensuse-15.0-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.0-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.0-amd64
+
+install-opensuse-15.1-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.1-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.1-amd64
+
+install-opensuse-15.2-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.2-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.2-amd64
+
+install-opensuse-15.3-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.3-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.3-amd64
+
+install-opensuse-15.4-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.4-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.4-amd64
+
+install-opensuse-15.5-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-opensuse-15.5-amd64
+  image: registry.nic.cz/labs/bird:opensuse-15.5-amd64
+
+install-fedora-34-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-34-amd64
+  image: registry.nic.cz/labs/bird:fedora-34-amd64
+
+install-fedora-35-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-35-amd64
+  image: registry.nic.cz/labs/bird:fedora-35-amd64
+
+install-fedora-36-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-36-amd64
+  image: registry.nic.cz/labs/bird:fedora-36-amd64
+
+install-fedora-37-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-37-amd64
+  image: registry.nic.cz/labs/bird:fedora-37-amd64
+
+install-fedora-38-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-38-amd64
+  image: registry.nic.cz/labs/bird:fedora-38-amd64
+
+install-fedora-39-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-39-amd64
+  image: registry.nic.cz/labs/bird:fedora-39-amd64
+
+install-fedora-40-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-40-amd64
+  image: registry.nic.cz/labs/bird:fedora-40-amd64
+
+install-fedora-41-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-41-amd64
+  image: registry.nic.cz/labs/bird:fedora-41-amd64
+
+install-fedora-42-amd64:
+  <<: *install-rpm
+  needs:
+    - job: pkg-fedora-42-amd64
+  image: registry.nic.cz/labs/bird:fedora-42-amd64
+
+install-ubuntu-18.04-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-ubuntu-18.04-amd64
+  image: registry.nic.cz/labs/bird:ubuntu-18.04-amd64
+
+install-debian-10-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-10-amd64
+  image: registry.nic.cz/labs/bird:debian-10-amd64
+
+install-debian-10-i386:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-10-i386
+  image: registry.nic.cz/labs/bird:debian-10-i386
+
+install-debian-11-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-11-amd64
+  image: registry.nic.cz/labs/bird:debian-11-amd64
+
+install-debian-11-i386:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-11-i386
+  image: registry.nic.cz/labs/bird:debian-11-i386
+
+install-debian-12-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-12-amd64
+  image: registry.nic.cz/labs/bird:debian-12-amd64
+
+install-debian-12-i386:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-12-i386
+  image: registry.nic.cz/labs/bird:debian-12-i386
+
+install-debian-testing-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-testing-amd64
+  image: registry.nic.cz/labs/bird:debian-testing-amd64
+
+install-debian-testing-i386:
+  <<: *install-deb
+  needs:
+    - job: pkg-debian-testing-i386
+  image: registry.nic.cz/labs/bird:debian-testing-i386
+
+install-ubuntu-20.04-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-ubuntu-20.04-amd64
+  image: registry.nic.cz/labs/bird:ubuntu-20.04-amd64
+
+install-ubuntu-22.04-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-ubuntu-22.04-amd64
+  image: registry.nic.cz/labs/bird:ubuntu-22.04-amd64
+
+install-ubuntu-24.04-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-ubuntu-24.04-amd64
+  image: registry.nic.cz/labs/bird:ubuntu-24.04-amd64
+
+install-ubuntu-24.10-amd64:
+  <<: *install-deb
+  needs:
+    - job: pkg-ubuntu-24.10-amd64
+  image: registry.nic.cz/labs/bird:ubuntu-24.10-amd64
+
+
 ###################################
 ## Non-linux build tests in QEMU ##
 ###################################
index 046be964fc1c66adef3baef01c2083ce57da9660..e5619696ba6a04f841f35adae8021ebb6c2acebe 100644 (file)
@@ -23,6 +23,7 @@ stages:
   - image
   - build
   - pkg
+  - install
   - test
 
 ## Common rules
@@ -242,7 +243,6 @@ build-release:
     - if python3 -m venv venv; then . venv/bin/activate; fi
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.deb
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -260,7 +260,6 @@ build-release:
     - pip3 install beautifulsoup4==4.11.2
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.deb
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -272,7 +271,6 @@ build-release:
   script:
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.rpm
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -287,7 +285,6 @@ build-release:
     - pip3 install beautifulsoup4==4.11.2
     - pip3 install apkg
     - apkg build -a bird-$(cat VERSION)*.tar.gz
-    #- apkg install -y pkg/pkgs/*/*/*.rpm
   artifacts:
     paths:
       - pkg/pkgs/*
@@ -308,6 +305,51 @@ pkg-{{ dist["name"] }}:
 {%- endif %}
 {% endfor %}
 
+## Package installability checks
+
+.install-deb: &install-deb
+  <<: *test-job
+  stage: install
+  script:
+    # check that bird is _not_ installed now
+    - |
+      if bird --version >/dev/null 2>&1; then
+        echo "Error: bird unexpectedly installed"
+        exit 1
+      fi
+    # install packages
+    - find pkg/pkgs/ -type f -name '*.deb' '(' -ls -exec dpkg -i '{}' ';' ')'
+    # test that install is correct
+    - ./tools/test-install "$CI_COMMIT_MESSAGE"
+
+.install-rpm: &install-rpm
+  <<: *test-job
+  stage: install
+  script:
+    # check that bird is _not_ installed now
+    - |
+      if bird --version >/dev/null 2>&1; then
+        echo "Error: bird unexpectedly installed"
+        exit 1
+      fi
+    # install packages
+    - find pkg/pkgs/ -type f -name '*.rpm' '(' -ls -exec rpm -i '{}' ';' ')'
+    # test that install is correct
+    - ./tools/test-install "$CI_COMMIT_MESSAGE"
+
+{% for dist in distros %}
+install-{{ dist["name"] }}:
+  <<: *{{ {
+    "pkg-rpm": "install-rpm",
+    "pkg-rpm-wa": "install-rpm",
+    "pkg-deb": "install-deb",
+    "pkg-deb-legacy": "install-deb",
+  }[dist["type"]] }}
+  needs:
+    - job: pkg-{{ dist["name"] }}
+  image: registry.nic.cz/labs/bird:{{ dist["name"] }}
+{% endfor %}
+
 ###################################
 ## Non-linux build tests in QEMU ##
 ###################################
diff --git a/tools/test-install b/tools/test-install
new file mode 100755 (executable)
index 0000000..628c4a3
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+STABLE_VERSION=$(cat VERSION)
+CI_COMMIT_MESSAGE=$(echo "$1" | sed '$s/\r\{0,1\}$//') # trimming new line  
+
+bird --version 2>&1 | grep -F "$STABLE_VERSION"
+bird --version 2>version-reported
+
+if [ "$CI_COMMIT_MESSAGE" = "NEWS and version update" ]; then
+  echo "Processing a release commit"
+
+  echo "BIRD version ${STABLE_VERSION}" > version-expected
+  diff version-reported version-expected
+else
+  echo "Processing a non-release commit"
+
+  if ! grep -qF "BIRD version ${STABLE_VERSION}+branch" version-reported; then
+    echo "Error: Version mismatch!"
+    ( echo "Reported: "; cat version-reported )
+    ( echo "Expected: "; echo "BIRD version ${STABLE_VERSION}+branch.<branch-name>.<commit-hash>" )
+    exit 1
+  fi
+fi
+
+# Run BIRD with minimal config and test with simple birdc commands
+mkdir -p /run/bird
+echo "protocol device {}" > minimal.conf
+bird -c minimal.conf
+
+birdcl show proto > show-proto-out 2>&1
+birdcl down > down-out 2>&1
+birdcl show proto > show-proto-after-down-out 2>&1
+
+if ! grep -qE "BIRD .* ready\." show-proto-out || ! grep -qE "BIRD .* ready\." down-out; then
+  echo "Error: BIRD did not start correctly"
+  echo "Output:"
+  cat show-proto-out down-out
+  exit 1
+fi
+
+if ! grep -qE "device1\s*Device\s*---\s*up" show-proto-out; then
+  echo "Error: BIRD did not show protocols correcly"
+  echo "Output:"
+  cat show-proto-out
+  exit 1
+fi
+
+if ! grep -qF "Shutdown requested" down-out; then
+  echo "Error: BIRD did not shutdown correctly after DOWN command."
+  echo "Output:"
+  cat down-out
+  exit 1
+fi
+
+if ! grep -qF "Unable to connect to server control socket" show-proto-after-down-out; then
+  echo "Error: BIRD did not shutdown correctly after DOWN command."
+  echo "Output:"
+  cat show-proto-after-down-out
+  exit 1
+fi
+