diff --git a/.github/workflows/test-dotnet-samples.yml b/.github/workflows/test-dotnet-samples.yml deleted file mode 100644 index cafb7d6..0000000 --- a/.github/workflows/test-dotnet-samples.yml +++ /dev/null @@ -1,196 +0,0 @@ -name: test-samples - -on: - pull_request: - branches: - - develop - - main - push: - branches: - - develop - - main - -env: - DOTNET_VERSION: '6.x' - -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/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/AddQRCode/', - '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}} diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b1537a3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,155 @@ +@Library('jenkins-shared-libraries') _ +def ENV_LOC=[:] +pipeline { + parameters { + choice(name: 'PLATFORM_FILTER', choices: ['all', 'windows-dotnet-samples', 'linux-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples','linux-arm-dotnet-samples'], description: 'Run on specific platform') + booleanParam defaultValue: false, description: 'Completely clean the workspace before building, including the Conan cache', name: 'CLEAN_WORKSPACE' + booleanParam defaultValue: false, description: 'Run clean-samples', name: 'DISTCLEAN' + } + options{ + buildDiscarder logRotator(artifactDaysToKeepStr: '4', artifactNumToKeepStr: '10', daysToKeepStr: '7', numToKeepStr: '10') + disableConcurrentBuilds() + timeout(time: 4, unit: "HOURS") + } + agent none + triggers { + // From the doc: @midnight actually means some time between 12:00 AM and 2:59 AM. + // This gives us automatic spreading out of jobs, so they don't cause load spikes. + cron('@midnight') + } + stages { + stage('Matrix stage') { + matrix { + agent { + label "${NODE}" + } + when { anyOf { + expression { params.PLATFORM_FILTER == 'all' } + expression { params.PLATFORM_FILTER == env.NODE } + } } + axes { + axis { + name 'NODE' + values 'windows-dotnet-samples', 'linux-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples','linux-arm-dotnet-samples' + } + } + environment { + CONAN_USER_HOME = "${WORKSPACE}" + CONAN_NON_INTERACTIVE = '1' + CONAN_PRINT_RUN_COMMANDS = '1' + } + stages { + stage('Axis'){ + steps { + printPlatformNameInStep() + } + } + stage('Clean/reset Git checkout for release') { + when { + expression { + params.CLEAN_WORKSPACE + } + } + steps { + echo "Clean ${NODE}" + script { + // Ensure that the checkout is clean and any changes + // to .gitattributes and .gitignore have been taken + // into effect + if (isUnix()) { + sh """ + git rm -f -q -r . + git reset --hard HEAD + git clean -fdx + """ + } else { + // On Windows, 'git clean' can't handle long paths in .conan, + // so remove that first. + bat """ + if exist ${WORKSPACE}\\.conan\\ rmdir/s/q ${WORKSPACE}\\.conan + git rm -q -r . + git reset --hard HEAD + git clean -fdx + """ + } + } + } + } + stage('Set-Up Environment') { + steps { + echo "Set-Up Environment ${NODE}" + script { + if (isUnix()) { + sh './mkenv.py --verbose' + ENV_LOC[NODE] = sh ( + script: './mkenv.py --env-name', + returnStdout: true + ).trim() + } else { + // Using the mkenv.py script like this assumes the Python Launcher is + // installed on the Windows host. + // https://docs.python.org/3/using/windows.html#launcher + bat '.\\mkenv.py --verbose' + ENV_LOC[NODE] = bat ( + // The @ prevents Windows from echoing the command itself into the stdout, + // which would corrupt the value of the returned data. + script: '@.\\mkenv.py --env-name', + returnStdout: true + ).trim() + } + } + } + } + stage('Clean Samples') { + steps { + echo "Clean ${NODE}" + script { + if (isUnix()) { + sh """. ${ENV_LOC[NODE]}/bin/activate + invoke clean-samples + """ + } else { + bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate + invoke clean-samples + """ + } + } + } + } + stage('Build Samples') { + steps { + echo "Bootstrap ${NODE}" + script { + if (isUnix()) { + sh """. ${ENV_LOC[NODE]}/bin/activate + invoke build-samples + """ + } else { + bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate + invoke build-samples + """ + } + } + } + } + stage('Run Samples') { + steps { + echo "Show Conan dependencies ${NODE}" + script { + if (isUnix()) { + sh """. ${ENV_LOC[NODE]}/bin/activate + invoke run-samples + """ + } else { + bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate + invoke run-samples + """ + } + } + } + } + } + } + } + } +} \ No newline at end of file