From 1557d30cc54abd3741ba6f57947862d9f6d1ed39 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Thu, 18 Jul 2024 11:19:17 +0200 Subject: [PATCH] packages/ci: add separate lintian tests --- .../ci/pipelines/debian_repository_full.yml | 34 ++++++++++++ .../pipelines/debian_repository_partial.yml | 17 ++++++ ci/bin/debian_repository.ml | 30 +++++++++++ scripts/ci/lintian_debian_packages.sh | 52 +++++++++++++++++++ scripts/packaging/build-deb-local.sh | 6 ++- 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100755 scripts/ci/lintian_debian_packages.sh diff --git a/.gitlab/ci/pipelines/debian_repository_full.yml b/.gitlab/ci/pipelines/debian_repository_full.yml index 58952a32e311..71df1cb80cdf 100644 --- a/.gitlab/ci/pipelines/debian_repository_full.yml +++ b/.gitlab/ci/pipelines/debian_repository_full.yml @@ -202,6 +202,23 @@ apt_repo_ubuntu_current: ARCHITECTURES: amd64 GNUPGHOME: $CI_PROJECT_DIR/.gnupg +oc.lintian_debian: + image: debian:bookworm + stage: publishing_tests + tags: + - gcp + needs: + - oc.build-debian + dependencies: + - oc.build-debian + before_script: + - . ./scripts/version.sh + - export DEBIAN_FRONTEND=noninteractive + - apt-get update + - apt-get install lintian -y + script: + - ./scripts/ci/lintian_debian_packages.sh debian bookworm + oc.install_bin_debian_bookworm: image: debian:bookworm stage: publishing_tests @@ -213,6 +230,23 @@ oc.install_bin_debian_bookworm: script: - ./docs/introduction/install-bin-deb.sh debian bookworm +oc.lintian_ubuntu: + image: public.ecr.aws/lts/ubuntu:20.04_stable + stage: publishing_tests + tags: + - gcp + needs: + - oc.build-ubuntu + dependencies: + - oc.build-ubuntu + before_script: + - . ./scripts/version.sh + - export DEBIAN_FRONTEND=noninteractive + - apt-get update + - apt-get install lintian -y + script: + - ./scripts/ci/lintian_debian_packages.sh ubuntu jammy focal + oc.install_bin_ubuntu_focal: image: public.ecr.aws/lts/ubuntu:20.04_stable stage: publishing_tests diff --git a/.gitlab/ci/pipelines/debian_repository_partial.yml b/.gitlab/ci/pipelines/debian_repository_partial.yml index 700c93e7d3c0..44725c385558 100644 --- a/.gitlab/ci/pipelines/debian_repository_partial.yml +++ b/.gitlab/ci/pipelines/debian_repository_partial.yml @@ -101,6 +101,23 @@ apt_repo_debian_current: ARCHITECTURES: amd64 GNUPGHOME: $CI_PROJECT_DIR/.gnupg +oc.lintian_debian: + image: debian:bookworm + stage: publishing_tests + tags: + - gcp + needs: + - oc.build-debian + dependencies: + - oc.build-debian + before_script: + - . ./scripts/version.sh + - export DEBIAN_FRONTEND=noninteractive + - apt-get update + - apt-get install lintian -y + script: + - ./scripts/ci/lintian_debian_packages.sh debian bookworm + oc.install_bin_debian_bookworm: image: debian:bookworm stage: publishing_tests diff --git a/ci/bin/debian_repository.ml b/ci/bin/debian_repository.ml index 1cac7847ff00..54ca636a5991 100644 --- a/ci/bin/debian_repository.ml +++ b/ci/bin/debian_repository.ml @@ -204,10 +204,34 @@ let jobs pipeline_type = ~stage:Stages.publishing_tests script in + let job_lintian ~__POS__ ~name ~dependencies ~image ?allow_failure script = + job + ?allow_failure + ~__POS__ + ~name + ~image + ~dependencies + ~stage:Stages.publishing_tests + ~before_script: + (before_script + ~source_version:true + [ + "export DEBIAN_FRONTEND=noninteractive"; + "apt-get update"; + "apt-get install lintian -y"; + ]) + script + in let test_current_ubuntu_packages_jobs = (* in merge pipelines we tests only debian. release pipelines test the entire matrix *) [ + job_lintian + ~__POS__ + ~name:"oc.lintian_ubuntu" + ~dependencies:(Dependent [Artifacts job_build_ubuntu_package]) + ~image:Images.ubuntu_focal + ["./scripts/ci/lintian_debian_packages.sh ubuntu jammy focal"]; job_install_bin ~__POS__ ~name:"oc.install_bin_ubuntu_focal" @@ -224,6 +248,12 @@ let jobs pipeline_type = in let test_current_debian_packages_jobs = [ + job_lintian + ~__POS__ + ~name:"oc.lintian_debian" + ~dependencies:(Dependent [Artifacts job_build_debian_package]) + ~image:Images.debian_bookworm + ["./scripts/ci/lintian_debian_packages.sh debian bookworm"]; job_install_bin ~__POS__ ~name:"oc.install_bin_debian_bookworm" diff --git a/scripts/ci/lintian_debian_packages.sh b/scripts/ci/lintian_debian_packages.sh new file mode 100755 index 000000000000..b90a6f1e68ff --- /dev/null +++ b/scripts/ci/lintian_debian_packages.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -u + +if [ $# -lt 2 ]; then + cat << EOF +Usage: $0 + + +: The linux distribution, eg. debian or ubuntu + +: The release of the Linux distribution, e.g. 'jammy', 'focal', 'bookworm'. +This argument can be repeated to build for multiple releases. + +This script will fail with exitcode 1 if lintian finds any errors. + +EOF + exit 1 +fi + +# Array to store failed files +FAILED_FILES=() + +# Set trap to catch errors and store the failing file +trap 'FAILED_FILES+=("$file")' ERR + +# The linux distribution for which we are creating the apt repository +# E.g. 'ubuntu' or 'debian' +DISTRIBUTION=${1} +shift +# The release of the linux distribution for which +# we are creating the apt repository +# E.g. 'jammy focal', 'bookworm' +RELEASES=$* + +for release in $RELEASES; do # unstable, jammy, focal ... + for file in packages/"${DISTRIBUTION}/${release}"/*.deb; do + echo "Lintian package $file" + lintian "$file" --tag-display-limit 0 --verbose --allow-root + done +done + +if [ ${#FAILED_FILES[@]} -ne 0 ]; then + echo "Lintian check failed for the following files:" + for file in "${FAILED_FILES[@]}"; do + echo "- $file" + done + exit 1 +else + echo "All clean" + exit 0 +fi diff --git a/scripts/packaging/build-deb-local.sh b/scripts/packaging/build-deb-local.sh index 60174954b852..7d110db930fc 100755 --- a/scripts/packaging/build-deb-local.sh +++ b/scripts/packaging/build-deb-local.sh @@ -29,4 +29,8 @@ cd - echo "All packages are available in ./scripts/packaging" -lintian scripts/packaging/octez-*.deb --tag-display-limit 0 --verbose +# Run lintian only if building packages locally. +# On the CI we have a specific job for it +if [ -z "${CI:-}" ]; then + lintian scripts/packaging/octez-*.deb --tag-display-limit 0 --verbose +fi -- GitLab