From 8be89ae74bda0264ec71c9130ca71551c7f80f3a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 28 May 2024 12:03:32 +0200 Subject: [PATCH 1/2] Allow to "make test-deps" and install modules needed for "make check" Impacts also GitHub build flows, as well as developer iterations Signed-off-by: Jim Klimov --- .github/workflows/build_deb_packages.yaml | 2 +- .github/workflows/test.yml | 2 +- .gitignore | 4 +++- CHANGES | 7 ++++--- Makefile.am | 11 +++++++++-- cpanfile => cpanfile.common | 2 +- thirdparty/Makefile.am | 14 ++++++++++++++ 7 files changed, 33 insertions(+), 9 deletions(-) rename cpanfile => cpanfile.common (60%) diff --git a/.github/workflows/build_deb_packages.yaml b/.github/workflows/build_deb_packages.yaml index 12400a77..eaaf0cfc 100644 --- a/.github/workflows/build_deb_packages.yaml +++ b/.github/workflows/build_deb_packages.yaml @@ -45,7 +45,7 @@ jobs: uses: actions/cache@v3 with: path: thirdparty - key: ${{ matrix.distribution }}-cpan-${{ matrix.version }}-${{ hashFiles('cpanfile', '*/cpanfile', 'Makefile.am', '*/Makefile.am') }} + key: ${{ matrix.distribution }}-cpan-${{ matrix.version }}-${{ hashFiles('cpanfile.common', '*/cpanfile', 'Makefile.am', '*/Makefile.am') }} - name: Build package id: build_package run: bash build_deb.sh ${{ matrix.distribution }} ${{ matrix.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95960695..8b138e2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: perl-version: ${{ matrix.perl }} - run: ./bootstrap.sh - run: ./configure --prefix=$HOME/znapzend - - run: cat cpanfile.test >> cpanfile && make + - run: make test-deps - run: ./test.sh - run: make install - run: "echo \"repo_token: ${{ secrets.GITHUB_TOKEN }}\" > .coveralls.yml" diff --git a/.gitignore b/.gitignore index ec9f01cb..6f16dac0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,8 @@ pm_to_blib autom4te.cache/ config.log config.status +/cpanfile +/cpanfile.snapshot thirdparty/* !thirdparty/Makefile.am !thirdparty/cpanfile*snapshot @@ -36,4 +38,4 @@ znapzend*.pid dump.dmp *.selftest-rewritten *~ -conftools \ No newline at end of file +conftools diff --git a/CHANGES b/CHANGES index 7a83d0d3..5bcfab49 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ -0.22.1 2024-05-03 10:20:29 +0200 Tobias Oetiker - - - + * Updated recipes for `make check` to install Perl modules it needs + (previously was only done as part of GitHub checks); renamed the + `cpanfile` to `cpanfile.common` to avoid changing the Git-tracked + resource file during build -- @jimklimov znapzend (0.22.0) unstable; urgency=medium diff --git a/Makefile.am b/Makefile.am index 2ff95cb9..e8e6cce3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,7 @@ POD = doc/znapzend.pod doc/znapzendzetup.pod doc/znapzendztatz.pod RM_F = $(RM) -f GENERATED_EXTRADIST = $(MAN) -EXTRA_DIST = VERSION COPYRIGHT README.md LICENSE CHANGES AUTHORS cpanfile $(BIN) $(PM) \ +EXTRA_DIST = VERSION COPYRIGHT README.md LICENSE CHANGES AUTHORS cpanfile.common $(BIN) $(PM) \ $(GENERATED_EXTRADIST) init/README.md init/org.znapzend.plist.in init/znapzend.default \ init/znapzend.service.in init/znapzend.sysv.in init/znapzend.upstart.in init/znapzend.xml.in \ t/autoscrub.t t/ssh t/znapzend.t t/znapzendztatz.t t/mbuffer \ @@ -62,8 +62,15 @@ install-exec-hook: cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^use .*# LIBDIR}{use lib qw($(libdir)); # LIBDIR}' $(BIN) cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN) +cpanfile: cpanfile.common + cp "$?" "$@" + +test-deps: + +cd thirdparty && $(MAKE) $(AM_MAKEFLAGS) test-deps + if !DEB_BUILD -check: +check: test-deps + @echo "NOTE: You may want to also/instead run test.sh" >&2 $(PERL) -Ithirdparty/lib/perl5 "-MExtUtils::Command::MM" "-e" "test_harness(1, 'lib','thirdparty/lib/perl5')" $(srcdir)/t/*.t endif diff --git a/cpanfile b/cpanfile.common similarity index 60% rename from cpanfile rename to cpanfile.common index f0cf3184..58fcc92d 100644 --- a/cpanfile +++ b/cpanfile.common @@ -1,3 +1,3 @@ requires 'Mojolicious'; requires 'Scalar::Util', '>= 1.45'; -requires 'Mojo::Log::Role::Clearable'; \ No newline at end of file +requires 'Mojo::Log::Role::Clearable'; diff --git a/thirdparty/Makefile.am b/thirdparty/Makefile.am index 320e53f7..2fb5ed4d 100644 --- a/thirdparty/Makefile.am +++ b/thirdparty/Makefile.am @@ -1,6 +1,7 @@ # Copyright (C) 2019 Tobias Oetiker AUTOMAKE_OPTIONS = foreign +CLEANFILES = THIRDPARTY_DIR = $(abs_builddir) @@ -15,6 +16,9 @@ EXTRA_DIST = bin/cpanm cpanfile*snapshot all-local: touch +../cpanfile: + +cd .. && $(MAKE) $(AM_MAKEFLAGS) cpanfile + touch: bin/cpanm carton/bin/carton $(CPANSNAPV) $(AM_V_at)echo "** Installing Dependencies using $(CPANSNAPV)" cp $(CPANSNAPV) ../cpanfile.snapshot @@ -31,6 +35,16 @@ bin/cpanm: carton/bin/carton: bin/cpanm test -x carton/bin/carton || PERL_CPANM_OPT= PERL_CPANM_HOME=$(THIRDPARTY_DIR) $(PERL) bin/cpanm -q --notest --local-lib-contained $(THIRDPARTY_DIR)/carton Carton Date::Parse +test-deps: ../cpanfile.common ../cpanfile.test carton/bin/carton + $(AM_V_at)echo "** Installing Test Dependencies using Carton install" + $(AM_V_at)cat ../cpanfile.common ../cpanfile.test > ../cpanfile + $(AM_V_at)rm -f ../cpanfile.snapshot + $(AM_V_at)PERL_CPANM_OPT= PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL5LIB=$(THIRDPARTY_DIR)/carton/lib/perl5 PERL_CARTON_PATH=$(THIRDPARTY_DIR) $(PERL) $(THIRDPARTY_DIR)/carton/bin/carton install + $(AM_V_at)rm -f ../cpanfile ../cpanfile.snapshot + $(AM_V_at)touch "$@" + +CLEANFILES += test-deps + $(CPANSNAPV): ../cpanfile carton/bin/carton $(AM_V_at)echo "** Installing Dependencies using Carton install" test -f $(CPANSNAPV) && cp $(CPANSNAPV) ../cpanfile.snapshot || true From 6e51683f574d704f6524a954bd9ee22ff00fced6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 28 May 2024 12:23:00 +0200 Subject: [PATCH 2/2] thirdparty/Makefile.am: apply same fix for "make test-deps" as in PR #652 --- thirdparty/Makefile.am | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/thirdparty/Makefile.am b/thirdparty/Makefile.am index 0a55c2ce..00a156dc 100644 --- a/thirdparty/Makefile.am +++ b/thirdparty/Makefile.am @@ -66,7 +66,14 @@ test-deps: ../cpanfile.common ../cpanfile.test carton/bin/carton $(AM_V_at)echo "** Installing Test Dependencies using Carton install" $(AM_V_at)cat ../cpanfile.common ../cpanfile.test > ../cpanfile $(AM_V_at)rm -f ../cpanfile.snapshot - $(AM_V_at)PERL_CPANM_OPT= PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL5LIB=$(THIRDPARTY_DIR)/carton/lib/perl5 PERL_CARTON_PATH=$(THIRDPARTY_DIR) $(PERL) $(THIRDPARTY_DIR)/carton/bin/carton install + +$(AM_V_at)TRIES=5 ; unset DESTDIR || true ; unset MAKEFLAGS || true ; \ + while test "$${TRIES}" -gt 0 ; do \ + PERL_CPANM_OPT= PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL5LIB=$(THIRDPARTY_DIR)/carton/lib/perl5 PERL_CARTON_PATH=$(THIRDPARTY_DIR) $(PERL) $(THIRDPARTY_DIR)/carton/bin/carton install \ + && exit ; \ + TRIES="`expr $${TRIES} - 1`" ; \ + echo "** RETRY Installing Test Dependencies using Carton install (attempts left: $${TRIES})" ; \ + MAKEFLAGS="" ; export MAKEFLAGS ; \ + done $(AM_V_at)rm -f ../cpanfile ../cpanfile.snapshot $(AM_V_at)touch "$@"