Skip to content

Commit

Permalink
Add docker wrappers of a few YAML parsers for easy testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Jan 15, 2021
1 parent c36f5bb commit eae8f8f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/parsers/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

dir -Attributes Directory | % {
docker build $_.Name -t "aaubry/yaml-$($_.Name)"
}

dir -Attributes Directory | % {
Write-Host "echo a:b | docker run --rm -i aaubry/yaml-$($_.Name)"
}
7 changes: 7 additions & 0 deletions tools/parsers/perl-yaml-pp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ubuntu:20.04

RUN apt-get update && apt-get install -y libyaml-pp-perl
COPY parse.pl /app/
WORKDIR /app

ENTRYPOINT [ "/usr/bin/perl", "-w", "/app/parse.pl" ]
9 changes: 9 additions & 0 deletions tools/parsers/perl-yaml-pp/parse.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use YAML::PP qw/ Load Dump /;

my $input;
while(<>) {
$input .= $_;
}

my $doc = Load($input);
print(Dump($doc));
6 changes: 6 additions & 0 deletions tools/parsers/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:20.04

RUN apt-get update && apt-get install -y python3 python3-yaml
WORKDIR /app

ENTRYPOINT [ "/usr/bin/python3", "-c", "import sys, yaml, json; print(json.dumps(yaml.load(sys.stdin.read(), Loader=yaml.SafeLoader)))" ]
13 changes: 13 additions & 0 deletions tools/parsers/reference/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:20.04

WORKDIR /app

RUN apt-get update && apt-get install -y cabal-install git
RUN cabal update
RUN git clone https://github.com/orenbenkiki/yamlreference.git .
RUN cabal install --only-dependencies
RUN cabal configure
RUN cabal build
COPY run.sh /app/

ENTRYPOINT [ "/usr/bin/bash", "/app/run.sh" ]
7 changes: 7 additions & 0 deletions tools/parsers/reference/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

if [ "$1" == "--html" ]; then
/app/dist/build/yaml2yeast/yaml2yeast <&0 | /app/yeast2html
else
echo "Use --html for HTML output"
/app/dist/build/yaml2yeast/yaml2yeast <&0 | grep --color -E '^!.*|$'
fi

0 comments on commit eae8f8f

Please sign in to comment.