Skip to content

Commit

Permalink
[perl] build, test and release improvements (#1728)
Browse files Browse the repository at this point in the history
* [perl] Make sure CHANGELOG.md is included in Perl dists

Since the [Git::GatherDir] plugin for Dist::Zilla *only* gathers
versioned files and the CHANGELOG.md file is *not* versioned, but rather
copied into the project directory upon release, it needs to be explicitly
included in the distribution tar file.

Also, in order to reduce the number of files a developer needs to get
to know, move the ignore patterns from `MANIFEST.SKIP` to `dist.ini`,
eliminating the need to have `MANIFEST.SKIP` at all.

* [perl] Centralize setting PERL5LIB and PATH; reusing in default.mk and Makefile

In case of Gherkin, use this centralization to add the in-repository
path for Cucumber::Messages in case we're running in the CI environment.

* [perl] Align makefile targets

 1. `clobber` target removes generated files (`clean` does not)
 2. `clean` target removes "imported" `CHANGELOG.md`

Note that the CHANGES file hasn't existed for a long time...

* [gherkin] Update CHANGELOG.md
  • Loading branch information
ehuelsmann authored Sep 7, 2021
1 parent 89e4482 commit e2e0520
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 39 deletions.
12 changes: 6 additions & 6 deletions .templates/perl/default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ CHANGELOG.md: ../CHANGELOG.md
cp ../CHANGELOG.md CHANGELOG.md

distribution: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil test --release
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil build
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil test --release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil build
.PHONY: distribution

publish: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil release
.PHONY: publish

update-version:
Expand All @@ -43,16 +43,16 @@ endif
.PHONY: update-version

.cpanfile_dependencies: cpanfile
cpanm --notest --local-lib ./perl5 --installdeps .
PERL5LIB=${PERL5LIB} cpanm --notest --local-lib ./perl5 --installdeps .
touch $@

predistribution: dist-clean test CHANGELOG.md
# --notest to keep the number of dependencies low: it doesn't install the
# testing dependencies of the dependencies.
cpanm --notest --local-lib ./perl5 --installdeps --with-develop .
cpanm --notest --local-lib ./perl5 'Dist::Zilla'
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil clean
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil clean
@(git status --porcelain 2>/dev/null | grep "^??" | perl -ne\
'die "The `release` target includes all files in the working directory. Please remove [$$_], or add it to .gitignore if it should be included\n" if s!.+ perl/(.+?)\n!$$1!')
.PHONY: predistribution
Expand Down
3 changes: 3 additions & 0 deletions gherkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt

### Fixed

* [Perl] Failure to include CHANGELOG.md in the release tarball
([#1728](https://github.com/cucumber/common/pull/1728) [ehuelsmann])

## [21.0.0] - 2021-09-01

### Added
Expand Down
10 changes: 0 additions & 10 deletions gherkin/perl/MANIFEST.SKIP

This file was deleted.

19 changes: 13 additions & 6 deletions gherkin/perl/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
include default.mk

ifeq ($(CI),)
PERL5LIB = $$PWD/../../messages/perl/lib:$$PWD/perl5/lib/perl5
else
PERL5LIB = $$PWD/perl5/lib/perl5
endif
PERL5PATH = $$PWD/perl5/bin

GOOD_FEATURE_FILES = $(shell find testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find testdata/bad -name "*.feature")

Expand All @@ -11,7 +18,7 @@ ERRORS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.errors.nd
.DELETE_ON_ERROR:

test: .built $(TOKENS) $(ASTS) $(PICKLES)
PERL5LIB=./perl5/lib/perl5 prove -l
PERL5LIB=${PERL5LIB} prove -l

.built: .cpanfile_dependencies lib/Gherkin/Generated/Parser.pm lib/Gherkin/Generated/Languages.pm bin/gherkin-generate-tokens LICENSE.txt
@$(MAKE) --no-print-directory show-version-info
Expand All @@ -24,22 +31,22 @@ show-version-info:

acceptance/testdata/%.feature.tokens: testdata/%.feature testdata/%.feature.tokens .built
mkdir -p $(@D)
PERL5LIB=./perl5/lib/perl5 bin/gherkin-generate-tokens $< > $@
PERL5LIB=${PERL5LIB} bin/gherkin-generate-tokens $< > $@
diff --unified $<.tokens $@

acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.ast.ndjson .built
mkdir -p $(@D)
PERL5LIB=./perl5/lib/perl5 bin/gherkin --predictable-ids --no-source --no-pickles $< > $@
PERL5LIB=${PERL5LIB} bin/gherkin --predictable-ids --no-source --no-pickles $< > $@
diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@)

acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature testdata/%.feature.pickles.ndjson .built
mkdir -p $(@D)
PERL5LIB=./perl5/lib/perl5 bin/gherkin --predictable-ids --no-source --no-ast $< > $@
PERL5LIB=${PERL5LIB} bin/gherkin --predictable-ids --no-source --no-ast $< > $@
diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@)

acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature testdata/%.feature.errors.ndjson .built
mkdir -p $(@D)
PERL5LIB=./perl5/lib/perl5 bin/gherkin --predictable-ids --no-source --no-pickles $< > $@
PERL5LIB=${PERL5LIB} bin/gherkin --predictable-ids --no-source --no-pickles $< > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)

post-release:
Expand All @@ -50,7 +57,7 @@ update-dependencies:
.PHONY: update-dependencies

clean:
rm -rf Gherkin-* .cpanfile_dependencies .built acceptance CHANGES
rm -rf Gherkin-* .cpanfile_dependencies .built acceptance CHANGELOG.md
.PHONY: clean

clobber: clean
Expand Down
12 changes: 6 additions & 6 deletions gherkin/perl/default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ CHANGELOG.md: ../CHANGELOG.md
cp ../CHANGELOG.md CHANGELOG.md

distribution: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil test --release
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil build
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil test --release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil build
.PHONY: distribution

publish: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil release
.PHONY: publish

update-version:
Expand All @@ -43,16 +43,16 @@ endif
.PHONY: update-version

.cpanfile_dependencies: cpanfile
cpanm --notest --local-lib ./perl5 --installdeps .
PERL5LIB=${PERL5LIB} cpanm --notest --local-lib ./perl5 --installdeps .
touch $@

predistribution: dist-clean test CHANGELOG.md
# --notest to keep the number of dependencies low: it doesn't install the
# testing dependencies of the dependencies.
cpanm --notest --local-lib ./perl5 --installdeps --with-develop .
cpanm --notest --local-lib ./perl5 'Dist::Zilla'
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil clean
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil clean
@(git status --porcelain 2>/dev/null | grep "^??" | perl -ne\
'die "The `release` target includes all files in the working directory. Please remove [$$_], or add it to .gitignore if it should be included\n" if s!.+ perl/(.+?)\n!$$1!')
.PHONY: predistribution
Expand Down
11 changes: 10 additions & 1 deletion gherkin/perl/dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ repository.type = git
[PkgVersion]
[Prereqs::FromCPANfile]
[Git::GatherDir]
exclude_filename=VERSION
exclude_match=^helper-scripts/
exclude_filename=gherkin.berp
exclude_filename=gherkin-perl.razor
exclude_filename=gherkin-languages.json
exclude_filename=default.mk
exclude_filename=Makefile
exclude_filename=VERSION

[GatherFile]
; explicitly add unversioned files
filename=CHANGELOG.md

[Hook::VersionProvider]
. = my $v = `cat ./VERSION`; chomp( $v ); $v;
13 changes: 10 additions & 3 deletions messages/perl/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
include default.mk

PERL5LIB = $$PWD/perl5/lib/perl5
PERL5PATH = $$PWD/perl5/bin



JSONSCHEMAS = $(shell find ../jsonschema -name "*.json")

test: lib/Cucumber/Messages.pm .cpanfile_dependencies
PERL5LIB=./perl5/lib/perl5 AUTHOR_TESTS=1 prove -l
.PHONY: test
PERL5LIB=${PERL5LIB} AUTHOR_TESTS=1 prove -l
.PHONY: test clean clobber

lib/Cucumber/Messages.pm: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/perl.pm.erb ../jsonschema/scripts/templates/perl.enum.pm.erb
ruby ../jsonschema/scripts/codegen.rb Perl ../jsonschema > $@

clean:
rm -f lib/Cucumber/Messages.pm .cpanfile_dependencies .built
rm -rf Cucumber-* .cpanfile_dependencies .built CHANGELOG.md

clobber: clean
rm -f lib/Cucumber/Messages.pm
12 changes: 6 additions & 6 deletions messages/perl/default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ CHANGELOG.md: ../CHANGELOG.md
cp ../CHANGELOG.md CHANGELOG.md

distribution: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil test --release
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil build
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil test --release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil build
.PHONY: distribution

publish: predistribution
PERL5LIB=$$PWD/perl5/lib/perl5 PATH=$$PATH:$$PWD/perl5/bin dzil release
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil release
.PHONY: publish

update-version:
Expand All @@ -43,16 +43,16 @@ endif
.PHONY: update-version

.cpanfile_dependencies: cpanfile
cpanm --notest --local-lib ./perl5 --installdeps .
PERL5LIB=${PERL5LIB} cpanm --notest --local-lib ./perl5 --installdeps .
touch $@

predistribution: dist-clean test CHANGELOG.md
# --notest to keep the number of dependencies low: it doesn't install the
# testing dependencies of the dependencies.
cpanm --notest --local-lib ./perl5 --installdeps --with-develop .
cpanm --notest --local-lib ./perl5 'Dist::Zilla'
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=./perl5/lib/perl5 PATH=$$PATH:./perl5/bin dzil clean
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil authordeps --missing | cpanm --notest --local-lib ./perl5
PERL5LIB=${PERL5LIB} PATH=$$PATH:${PERL5PATH} dzil clean
@(git status --porcelain 2>/dev/null | grep "^??" | perl -ne\
'die "The `release` target includes all files in the working directory. Please remove [$$_], or add it to .gitignore if it should be included\n" if s!.+ perl/(.+?)\n!$$1!')
.PHONY: predistribution
Expand Down
7 changes: 6 additions & 1 deletion messages/perl/dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ repository.type = git
[PkgVersion]
[Prereqs::FromCPANfile]
[Git::GatherDir]
exclude_filename=VERSION
exclude_filename=default.mk
exclude_filename=Makefile
exclude_filename=VERSION

[GatherFile]
; explicitly add unversioned files
filename=CHANGELOG.md

[Hook::VersionProvider]
. = my $v = `cat ./VERSION`; chomp( $v ); $v;

0 comments on commit e2e0520

Please sign in to comment.