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

[Perl] Generated Languages.pm as part of the build process #176

Merged
merged 14 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 5 additions & 4 deletions .github/workflows/test-perl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ jobs:
install-modules-with: cpanm
working-directory: perl

# Run acceptance tests first! They build Languages.pm
- name: run acceptance tests
run: make acceptance
working-directory: perl

- name: run tests
run: |
prove -l
AUTHOR_TESTS=1 prove -l
working-directory: perl

- name: run acceptance tests
run: make acceptance
working-directory: perl
1 change: 1 addition & 0 deletions perl/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ perl5/
.cpanfile_dependencies
cpanfile.snapshot
CHANGELOG.md
lib/Gherkin/Generated/Languages.pm
32 changes: 20 additions & 12 deletions perl/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
SHELL := /usr/bin/env bash

GHERKIN_PARSER = lib/Gherkin/Generated/Parser.pm
GHERKIN_LANGUAGES = lib/Generated/Languages.pm
GHERKIN_RAZOR = gherkin-perl.razor
SOURCE_FILES = $(shell find . -name "*.pm" | grep -v $(GHERKIN_PARSER))
SOURCE_FILES = $(shell find lib -name "*.pm" | grep -v $(GHERKIN_PARSER) | grep -v $(GHERKIN_LANGUAGES) )

GHERKIN = bin/gherkin
GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens
Expand All @@ -17,6 +18,11 @@ SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GO
ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES))

.DEFAULT_GOAL = help

ARTIFACT_DIR = Gherkin-latest
ARTIFACT_DIR_VERSIONED = Gherkin-$(shell cat VERSION)
ARTIFACT_TAR_GZ = Gherkin-$(shell cat VERSION).tar.gz

PERL5LIB = $$PWD/perl5/lib/perl5
GHERKIN = PERL5LIB=${PERL5LIB} bin/gherkin
GHERKIN_GENERATE_TOKENS = PERL5LIB=${PERL5LIB} bin/gherkin-generate-tokens
Expand All @@ -29,30 +35,32 @@ generate: $(GHERKIN_PARSER) ## Generate gherkin parser files
clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files
rm -f $(GHERKIN_PARSER)

copy-gherkin-languages: # lib/Gherkin/Generated/Languages.pm ## Copy gherkin-languages.json and/or generate derived files
echo "TODO: Depends on perl, this task should only depend on jq"
copy-gherkin-languages:
echo "Nothing to do"

clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files
# rm -f lib/Gherkin/Generated/Languages.pm
echo "TODO: Depends on perl, this task should only depend on jq"
echo "Nothing to do"

clean: ## Remove all build artifacts and files generated by the acceptance tests
rm -f .built
rm -rf $(ARTIFACT_DIR_VERSIONED)
rm -rf $(ARTIFACT_DIR)
rm -f $(ARTIFACT_TAR_GZ)
rm -rf acceptance
rm -rf perl5

.DELETE_ON_ERROR:

acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(SOURCES) $(ERRORS) ## Build acceptance test dir and compare results with reference
acceptance: $(ARTIFACT_DIR) $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference

.built: perl5 $(SOURCE_FILES)
touch $@
$(ARTIFACT_DIR): $(ARTIFACT_DIR_VERSIONED)
cp -r $(ARTIFACT_DIR_VERSIONED) $@

$(ARTIFACT_DIR_VERSIONED): perl5 $(SOURCE_FILES)
PATH=$$PATH:perl5/bin PERL5LIB=${PERL5LIB} dzil build

perl5:
cpanm --notest --local-lib ./perl5 --installdeps --with-develop .

lib/Gherkin/Generated/Languages.pm:
perl helper-scripts/build_languages.pl > $@
PATH=$$PATH:perl5/bin PERL5LIB=${PERL5LIB} dzil authordeps --missing | cpanm --notest --local-lib ./perl5

$(GHERKIN_PARSER): $(GHERKIN_RAZOR) ../gherkin.berp
berp -g ../gherkin.berp -t $< -o $@ --noBOM
Expand Down
2 changes: 1 addition & 1 deletion perl/bin/gherkin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use lib 'lib';
use lib 'Gherkin-latest/lib';

use App::gherkin;

Expand Down
2 changes: 1 addition & 1 deletion perl/bin/gherkin-generate-tokens
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use lib 'lib';
use lib 'Gherkin-latest/lib';

use Gherkin::Parser;
use Gherkin::TokenFormatterBuilder;
Expand Down
2 changes: 1 addition & 1 deletion perl/cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ on 'test' => sub {
};

on 'develop' => sub {
# there are no specific development dependencies...
requires "Dist::Zilla";
};
8 changes: 7 additions & 1 deletion perl/dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ exclude_filename=gherkin-perl.razor
exclude_filename=Makefile
exclude_filename=VERSION

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

[GatherFile / GeneratedLanguages]
filename=lib/Gherkin/Generated/Languages.pm

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

[Run::BeforeBuild]
run = helper-scripts/build_languages.pl >lib/Gherkin/Generated/Languages.pm
7 changes: 0 additions & 7 deletions perl/lib/Gherkin/Generated/Languages.pm

This file was deleted.

Loading