Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to "make test-deps" and install modules needed for "make check" #654

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_deb_packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pm_to_blib
autom4te.cache/
config.log
config.status
/cpanfile
/cpanfile.snapshot
thirdparty/*
!thirdparty/Makefile.am
!thirdparty/cpanfile*snapshot
Expand All @@ -36,4 +38,4 @@ znapzend*.pid
dump.dmp
*.selftest-rewritten
*~
conftools
conftools
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 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
* Fix `make install` of Perl modules with a custom `DESTDIR` and/or when
applying `configure --libdir=...` requirements -- @jimklimov
* Applied same markup style to older CHANGES logged entries -- @jimklimov
Expand Down
11 changes: 9 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cpanfile → cpanfile.common
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requires 'Mojolicious';
requires 'Scalar::Util', '>= 1.45';
requires 'Mojo::Log::Role::Clearable';
requires 'Mojo::Log::Role::Clearable';
21 changes: 21 additions & 0 deletions thirdparty/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2019 Tobias Oetiker

AUTOMAKE_OPTIONS = foreign
CLEANFILES =

THIRDPARTY_DIR = $(abs_builddir)

Expand All @@ -15,6 +16,9 @@ EXTRA_DIST = bin/cpanm cpanfile*snapshot

all-local: touch

../cpanfile:
+cd .. && $(MAKE) $(AM_MAKEFLAGS) cpanfile

# NOTE: CPANM pulls a number of dependencies which seem to get installed in
# parallel - in a random chaotic order (pun intended), so a few iterations
# may be required - up to the amount of dependencies in the worst case.
Expand Down Expand Up @@ -58,6 +62,23 @@ carton/bin/carton: bin/cpanm
done
test -x carton/bin/carton

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)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 "$@"

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
Expand Down
Loading