Skip to content

Merge pull request #70 from datalogics-aarroyo/maven_license #60

Merge pull request #70 from datalogics-aarroyo/maven_license

Merge pull request #70 from datalogics-aarroyo/maven_license #60

name: test-samples
on:
pull_request:
branches:
- develop
- main
push:
branches:
- develop
- main
env:
JAVA_VERSION: '11'
jobs:
run-samples:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-14]
dir: [
'Annotations/Annotations/',
'Annotations/InkAnnotations/',
'Annotations/LinkAnnotations/',
'Annotations/PolygonAnnotations/',
'Annotations/PolyLineAnnotations/',
'ContentCreation/AddElements/',
'ContentCreation/AddHeaderFooter/',
'ContentCreation/Clips/',
'ContentCreation/CreateBookmarks/',
'ContentCreation/GradientShade/',
'ContentCreation/MakeDocWithCalGrayColorSpace/',
'ContentCreation/MakeDocWithCalRGBColorSpace/',
'ContentCreation/MakeDocWithDeviceNColorSpace/',
'ContentCreation/MakeDocWithICCBasedColorSpace/',
'ContentCreation/MakeDocWithIndexedColorSpace/',
'ContentCreation/MakeDocWithLabColorSpace/',
'ContentCreation/MakeDocWithSeparationColorSpace/',
'ContentCreation/NameTrees/',
'ContentCreation/NumberTrees/',
'ContentCreation/RemoteGoToActions/',
'ContentCreation/WriteNChannelTiff/',
'ContentModification/Actions/',
'ContentModification/AddCollection/',
'ContentModification/AddQRCode/',
'ContentModification/ChangeLayerConfiguration/',
'ContentModification/ChangeLinkColors/',
'ContentModification/CreateLayer/',
'ContentModification/ExtendedGraphicStates/',
'ContentModification/FlattenTransparency/',
'ContentModification/LaunchActions/',
'ContentModification/MergePDF/',
'ContentModification/PageLabels/',
'ContentModification/PDFObject/',
'ContentModification/UnderlinesAndHighlights/',
'ContentModification/Watermark/',
'Display/DisplayPDF/',
'Display/ImageDisplay/',
'Display/JavaViewer/',
'Display/PDFObjectExplorer/',
'DocumentConversion/ColorConvertDocument/',
'DocumentConversion/ConvertToOffice/',
'DocumentConversion/CreateDocFromXPS/',
'DocumentConversion/FacturXConverter/',
'DocumentConversion/PDFAConverter/',
'DocumentConversion/PDFXConverter/',
'DocumentConversion/ZUGFeRDConverter/',
'DocumentOptimization/PDFOptimize/',
'Images/DocToImages/',
'Images/DrawSeparations/',
'Images/EPSSeparations/',
'Images/GetSeparatedImages/',
'Images/ImageDisplayByteArray/',
'Images/ImageEmbedICCProfile/',
'Images/ImageExport/',
'Images/ImageExtraction/',
'Images/ImageFromBufferedImage/',
'Images/ImageFromByteArray/',
'Images/ImageImport/',
'Images/ImageResampling/',
'Images/OutputPreview/',
'Images/RasterizePage/',
'InformationExtraction/ListBookmarks/',
'InformationExtraction/ListFonts/',
'InformationExtraction/ListInfo/',
'InformationExtraction/ListLayers/',
'InformationExtraction/ListPaths/',
'InformationExtraction/Metadata/',
'OpticalCharacterRecognition/AddTextToDocument/',
'OpticalCharacterRecognition/AddTextToImage/',
'Other/MemoryFileSystem/',
'Other/StreamIO/',
'Printing/PrintPDF/',
'Printing/PrintPDFGUI/',
'Security/AddRegexRedaction/',
'Security/Redactions/',
'Text/AddGlyphs/',
'Text/AddUnicodeText/',
'Text/AddVerticalText/',
'Text/ListWords/',
'Text/RegexExtractText/',
'Text/RegexTextSearch/',
'Text/TextExtract/'
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: Setup Microsoft Core Fonts
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if [ "${{ matrix.os }}" == 'ubuntu-latest' ]; then
case "$sample_name" in "AddHeaderFooter" | "AddElements")
echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | sudo debconf-set-selections
sudo apt-get install ttf-mscorefonts-installer
;;
esac
fi
- name: Unpack APDFL from Maven Central
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then
mvn -e process-resources
else
echo "Not available on this os"
fi
- name: Unpack APDFL resources ZIP file
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if [ "$sample_name" == "DocToImages" ] && [ "$RUNNER_OS" != "macOS" ] ; then
unzip $HOME/.m2/repository/com/datalogics/pdfl/pdfl/**/*-resources.zip
ls -la
fi
- name: Compile and assemble sample JAR files with dependencies
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then
mvn -e package
else
echo "Not available on this os"
fi
- name: Set up Windows system PATH
working-directory: ${{ matrix.dir }}
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "${{ github.workspace }}\${{ matrix.dir }}\target\lib" >> $GITHUB_PATH
fi
- name: Print PATH
run: echo $PATH
- name: Run samples
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if [ "$sample_name" == "DisplayPDF" ] || [ "$sample_name" == "ImageDisplay" ] || [ "$sample_name" == "JavaViewer" ] || [ "$sample_name" == "PDFObjectExplorer" ] || [ "$sample_name" == "PrintPDF" ] || [ "$sample_name" == "PrintPDFGUI" ] || [ "$sample_name" == "ImageDisplayByteArray" ]; then
echo "$sample_name will not be run due to GitHub runner limitations."
elif { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$sample_name" == "DocToImages" ]; then
java -Djava.library.path="$PATH" -Dfile.encoding=UTF-8 -jar target/$sample_name-1.0-SNAPSHOT-jar-with-dependencies.jar -format=png Sample_Input/ducky.pdf
else
java -Djava.library.path="$PATH" -Dfile.encoding=UTF-8 -jar target/$sample_name-1.0-SNAPSHOT-jar-with-dependencies.jar
fi
elif [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "macOS" ]; then
if [ "$sample_name" == "DocToImages" ]; then
java -Djava.library.path=./target/lib -Dfile.encoding=UTF-8 -jar target/$sample_name-1.0-SNAPSHOT-jar-with-dependencies.jar -format=png Sample_Input/ducky.pdf
else
java -Djava.library.path=./target/lib -Dfile.encoding=UTF-8 -jar target/$sample_name-1.0-SNAPSHOT-jar-with-dependencies.jar
fi
fi
else
echo "Not available on this os"
fi
- name: Set sample_name variable
id: set-sample-name
working-directory: ${{matrix.dir}}
run: echo "SAMPLE_NAME=$(basename "$PWD")" >> "$GITHUB_ENV"
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: output-${{ runner.os }}-${{ env.SAMPLE_NAME }}
path: |
${{matrix.dir}}*.docx
${{matrix.dir}}*.xslx
${{matrix.dir}}*.pptx
${{matrix.dir}}*.pdf
${{matrix.dir}}*.tif
${{matrix.dir}}*.png
${{matrix.dir}}*.jpg
${{matrix.dir}}*.eps
${{matrix.dir}}*.tiff
${{matrix.dir}}*.bmp
${{matrix.dir}}*.gif
${{matrix.dir}}*.json
${{matrix.dir}}*.txt
${{matrix.dir}}*.csv
- name: List files
run: |
ls ${{matrix.dir}}