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

APDFL-5452: Add CI for samples #32

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dc9bd09
Modify workflow to setup env and build Annotation sample
datalogics-saharay Feb 27, 2024
4553056
Remove macos-14 from os list
datalogics-saharay Feb 27, 2024
9d6294a
Try listing files
datalogics-saharay Feb 27, 2024
94a9d2e
List files in its own step
datalogics-saharay Feb 28, 2024
09b8a04
Use wildcard operator to find .csproj filesfor samples
datalogics-saharay Feb 28, 2024
a52c664
Fix dotnet build command
datalogics-saharay Feb 28, 2024
b98819f
Add step to run samples
datalogics-saharay Feb 28, 2024
b49b56d
Fix sample run commands
datalogics-saharay Feb 28, 2024
bdc288b
Add logic to run all Annotations samples
datalogics-saharay Feb 28, 2024
86ad47e
Modify logic for running samples
datalogics-saharay Feb 28, 2024
9ee3cd4
Add macos-14 runner to matrix.os
datalogics-saharay Feb 29, 2024
6ea7e67
Run the ContentCreation samples in CI
datalogics-saharay Feb 29, 2024
56711d1
Disable AddHeaderFooter sample in CI
datalogics-saharay Feb 29, 2024
efa1427
Rename MakeDocWithCalRGBColorSpace csproj to match the sample directo…
datalogics-saharay Feb 29, 2024
770232e
Run the ContentModification samples in CI
datalogics-saharay Mar 1, 2024
4317d9f
Run DocumentConversion samples in CI
datalogics-saharay Mar 1, 2024
817e4c8
Add logic to prevent running the ConvertToOffice sample on Mac
datalogics-saharay Mar 1, 2024
748837f
Add logic to prevent running the CreateDocFromXPS sample on Mac
datalogics-saharay Mar 1, 2024
9639920
Set the fail-fast key so other jobs keep running after failure
datalogics-saharay Mar 4, 2024
700dbf1
Run sample exe on Windows instead of DLL
datalogics-saharay Mar 5, 2024
6971b10
Run DocumentOptimization samples in CI
datalogics-saharay Mar 5, 2024
1a6d9a0
Run the Image samples in CI
datalogics-saharay Mar 5, 2024
10ed46c
Run InformationExtraction samples in CI
datalogics-saharay Mar 5, 2024
bbeb4cd
Run OpticalCharacterRecognition samples in CI
datalogics-saharay Mar 6, 2024
9c89a11
Run Other samples in CI
datalogics-saharay Mar 6, 2024
2748cac
Run Security samples in CI
datalogics-saharay Mar 6, 2024
8ae9b79
Run the Text samples in CI
datalogics-saharay Mar 6, 2024
c8d16b9
Install Microsoft Core fonts on Linux for samples that require it
datalogics-saharay Mar 6, 2024
9b7699c
Try setting DEBIAN_FRONTEND to get fonts installed
datalogics-saharay Mar 7, 2024
41a64a0
Set debconf frontend to be noninteractive
datalogics-saharay Mar 7, 2024
13b3a05
Set debconf to be noninteractive via dpkg-reconfigure
datalogics-saharay Mar 7, 2024
7eb7a85
List fonts on system for Linux
datalogics-saharay Mar 7, 2024
a78ca34
Try installing fonts another way
datalogics-saharay Mar 7, 2024
d302400
Only install fonts for Linux samples that require it
datalogics-saharay Mar 7, 2024
3697a92
Run the samples that don't work in CI yet
datalogics-saharay Mar 8, 2024
2b11ae3
Attempt to get DocToImages sample running in CI
datalogics-saharay Mar 8, 2024
10f0583
List files in HOME directory
datalogics-saharay Mar 8, 2024
50a5dd4
Correct input file path for DocToImages sample
datalogics-saharay Mar 8, 2024
0ee5f37
Remove debugging statement
datalogics-saharay Mar 8, 2024
2eccdb0
Disable Redactions sample on Ubuntu
datalogics-saharay Mar 11, 2024
db34e3e
Add step for archiving sample output
datalogics-saharay Mar 12, 2024
15c4801
List sample output files
datalogics-saharay Mar 12, 2024
795725f
Correct save artifacts step in workflow
datalogics-saharay Mar 12, 2024
815fe08
Specify save artifacts in a different way
datalogics-saharay Mar 12, 2024
51c22c4
Fix warnings about use of deprecated set-output function
datalogics-saharay Mar 13, 2024
3a1d23c
Fix the ImageExtraction sample's output file extension
datalogics-saharay Mar 13, 2024
3faa40a
Archive sample output that gets put in the parent directory
datalogics-saharay Mar 13, 2024
c4c3950
Try to add a workaround for archiving sample output in parent dir
datalogics-saharay Mar 13, 2024
36e2cf1
Modify output paths for samples
datalogics-saharay Mar 13, 2024
346423f
Refactor GitHub Actions workflow file
datalogics-saharay Mar 14, 2024
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
172 changes: 171 additions & 1 deletion .github/workflows/test-dotnet-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,176 @@ jobs:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-14]
dir: []
dir: [
'Annotations/Annotations/',
'Annotations/InkAnnotations/',
'Annotations/LinkAnnotation/',
'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/Action/',
'ContentModification/AddCollection/',
'ContentModification/ChangeLayerConfiguration/',
'ContentModification/ChangeLinkColors/',
'ContentModification/CreateLayer/',
'ContentModification/ExtendedGraphicStates/',
'ContentModification/FlattenTransparency/',
'ContentModification/LaunchActions/',
'ContentModification/MergePDF/',
'ContentModification/PageLabels/',
'ContentModification/PDFObject/',
'ContentModification/UnderlinesAndHighlights/',
'ContentModification/Watermark/',
'DocumentConversion/ColorConvertDocument/',
'DocumentConversion/ConvertToOffice/',
'DocumentConversion/CreateDocFromXPS/',
'DocumentConversion/Factur-XConverter/',
'DocumentConversion/PDFAConverter/',
'DocumentConversion/PDFXConverter/',
'DocumentConversion/ZUGFeRDConverter/',
'DocumentOptimization/PDFOptimize/',
'Images/DocToImages/',
'Images/DrawSeparations/',
'Images/DrawToBitmap/',
'Images/EPSSeparations/',
'Images/GetSeparatedImages/',
'Images/ImageEmbedICCProfile/',
'Images/ImageExport/',
'Images/ImageExtraction/',
'Images/ImageFromStream/',
'Images/ImageImport/',
'Images/ImageResampling/',
'Images/ImageSoftMask/',
'Images/OutputPreview/',
'Images/RasterizePage/',
'InformationExtraction/ListBookmarks/',
'InformationExtraction/ListInfo/',
'InformationExtraction/ListLayers/',
'InformationExtraction/ListPaths/',
'InformationExtraction/Metadata/',
'OpticalCharacterRecognition/AddTextToDocument/',
'OpticalCharacterRecognition/AddTextToImage/',
'Other/MemoryFileSystem/',
'Other/StreamIO/',
'Security/AddRegexRedaction/',
'Security/Redactions/',
'Text/AddGlyphs/',
'Text/AddUnicodeText/',
'Text/AddVerticalText/',
'Text/ExtractAcroFormFieldData/',
'Text/ExtractCJKTextByPatternMatch/',
'Text/ExtractTextByPatternMatch/',
'Text/ExtractTextByRegion/',
'Text/ExtractTextFromAnnotations/',
'Text/ExtractTextFromMultiRegions/',
'Text/ExtractTextPreservingStyleAndPositionInfo/',
'Text/ListWords/',
'Text/RegexExtractText/',
'Text/RegexTextSearch/',
'Text/TextExtract/'
]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- 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" | "MakeDocWithCalGrayColorSpace" | "MakeDocWithCalRGBColorSpace" | "MakeDocWithDeviceNColorSpace" | "MakeDocWithICCBasedColorSpace" | "MakeDocWithIndexedColorSpace" | "MakeDocWithLabColorSpace" | "MakeDocWithSeparationColorSpace" | "ExtendedGraphicStates" | "AddGlyphs" | "AddUnicodeText")
echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | sudo debconf-set-selections
sudo apt-get install ttf-mscorefonts-installer
;;
esac
fi

- name: Build samples
working-directory: ${{ matrix.dir }}
run: |
sample_name=$(basename "$PWD")
if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{ matrix.os }}" != 'macos-14' ]; then
dotnet build -c Release *.csproj
else
echo "Not available on this os"
fi

- name: Run samples
working-directory: ${{matrix.dir}}
run: |
sample_name=$(basename "$PWD")

if [ "$sample_name" == "Redactions" ] && [ "${{matrix.os}}" == 'ubuntu-latest' ]; then
echo "Not available on this os"
else
if { [ "$sample_name" != "ConvertToOffice" ] && [ "$sample_name" != "CreateDocFromXPS" ]; } || [ "${{matrix.os}}" != 'macos-14' ]; then
if [ "${{matrix.os}}" == 'windows-latest' ]; then
if [ "$sample_name" == "DocToImages" ]; then
bin/Release/net6.0/$sample_name.exe -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf
else
bin/Release/net6.0/$sample_name.exe
fi
else
if [ "$sample_name" == "DocToImages" ]; then
dotnet bin/Release/net6.0/$sample_name.dll -format=png $HOME/.nuget/packages/adobe.pdf.library.sampleinput/1.0.0/build/Resources/Sample_Input/ducky.pdf
else
dotnet bin/Release/net6.0/$sample_name.dll
fi
fi
else
echo "Not available on this os"
fi
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}}
2 changes: 1 addition & 1 deletion ContentCreation/AddHeaderFooter/AddHeaderFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void Main(string[] args)

using (Library lib = new Library())
{
String sOutput = "../AddHeaderFooter-out.pdf";
String sOutput = "AddHeaderFooter-out.pdf";

Console.WriteLine("Output file: " + sOutput);

Expand Down
2 changes: 1 addition & 1 deletion DocumentOptimization/PDFOptimize/PDFOptimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void Main(string[] args)
Console.WriteLine("Initialized the library.");

String sInput = Library.ResourceDirectory + "Sample_Input/sample.pdf"; ;
String sOutput = "../PDFOptimizer-out.pdf";
String sOutput = "PDFOptimizer-out.pdf";

if (args.Length > 0)
sInput = args[0];
Expand Down
4 changes: 2 additions & 2 deletions Images/ImageExtraction/ImageExtraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
Datalogics.PDFL.Image img = (Datalogics.PDFL.Image)e;
using (SKBitmap sKBitmap = img.SKBitmap)
{
using (FileStream f = File.OpenWrite("ImageExtraction-extract-out" + (next) + ".Png"))
using (FileStream f = File.OpenWrite("ImageExtraction-extract-out" + (next) + ".png"))
sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(f);
}

Datalogics.PDFL.Image newimg = img.ChangeResolution(500);
using (SKBitmap sKBitmap = newimg.SKBitmap)
{
using (FileStream f = File.OpenWrite("ImageExtraction-extract-Resolution-500-out" + (next) + ".Png"))
using (FileStream f = File.OpenWrite("ImageExtraction-extract-Resolution-500-out" + (next) + ".png"))
sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(f);
}
next++;
Expand All @@ -47,15 +47,15 @@
}
else if (e is Datalogics.PDFL.Container)
{
ExtractImages((e as Datalogics.PDFL.Container).Content);

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 50 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.
}
else if (e is Datalogics.PDFL.Group)
{
ExtractImages((e as Datalogics.PDFL.Group).Content);

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 54 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.
}
else if (e is Form)
{
ExtractImages((e as Form).Content);

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (ubuntu-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (macos-14, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.

Check warning on line 58 in Images/ImageExtraction/ImageExtraction.cs

View workflow job for this annotation

GitHub Actions / run-samples (windows-latest, Images/ImageExtraction/)

Dereference of a possibly null reference.
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Text/ExtractAcroFormFieldData/ExtractAcroFormFieldData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExtractAcroFormFieldData
{
// Set Defaults
static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractAcroFormFieldData.pdf";
static String sOutput = "../ExtractAcroFormFieldData-out.json";
static String sOutput = "ExtractAcroFormFieldData-out.json";

static void Print(AcroFormTextFieldObject t)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void Main(string[] args)

// Set Defaults
String sInput = Library.ResourceDirectory + "Sample_Input/ExtractUnicodeText.pdf";
String sOutput = "../ExtractCJKTextByPatternMatch-out.txt";
String sOutput = "ExtractCJKTextByPatternMatch-out.txt";
String sPattern = "『世界人権宣言』";

using (Document doc = new Document(sInput))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void Main(string[] args)

// Set Defaults
String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextByPatternMatch.pdf";
String sOutput = "../ExtractTextByPatternMatch-out.txt";
String sOutput = "ExtractTextByPatternMatch-out.txt";
String sPattern = "((1-)?(\\()?\\d{3}(\\))?(\\s)?(-)?\\d{3}-\\d{4})"; // phone numbers

using (Document doc = new Document(sInput))
Expand Down
2 changes: 1 addition & 1 deletion Text/ExtractTextByRegion/ExtractTextByRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ExtractTextByRegion
{
// Set Defaults
static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextByRegion.pdf";
static String sOutput = "../ExtractTextByRegion-out.txt";
static String sOutput = "ExtractTextByRegion-out.txt";

// Rectangular region to extract text in points (origin of the page is bottom left)
// (545,576,694,710) is a rectangle encompassing the invoice entry for this sample.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ExtractTextFromAnnotations

// Set Defaults
static String sInput = Library.ResourceDirectory + "Sample_Input/sample_annotations.pdf";
static String sOutput = "../ExtractTextFromAnnotations-out.json";
static String sOutput = "ExtractTextFromAnnotations-out.json";

static void Print(AnnotationTextObject t)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExtractTextFromMultiRegions
{
// Set Defaults
static String sInput = Library.ResourceDirectory + "Sample_Input/ExtractTextFromMultiRegions";
static String sOutput = "../ExtractTextFromMultiRegions-out.csv";
static String sOutput = "ExtractTextFromMultiRegions-out.csv";

// Rectangular regions to extract text in points (origin of the page is bottom left)
// (Left, Right, Bottom, Top)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ExtractTextPreservingStyleAndPositionInfo
{
// Set Defaults
static String sInput = Library.ResourceDirectory + "Sample_Input/sample.pdf";
static String sOutput = "../ExtractTextPreservingStyleAndPositionInfo-out.json";
static String sOutput = "ExtractTextPreservingStyleAndPositionInfo-out.json";

static void Main(string[] args)
{
Expand Down
Loading