From b29ff3c75bf6258a587617a2eb7fe5d4bb3741b2 Mon Sep 17 00:00:00 2001 From: snsaqua8 Date: Wed, 15 Oct 2025 21:16:47 +0200 Subject: [PATCH 1/2] add testscripts, docker file and jenkins --- Dockerfile | 133 ++++++++++++++++++++++++++++++ Jenkinsfile | 150 ++++++++++++++++++++++++++++++++++ test-scripts/run-all-tests.sh | 57 +++++++++++++ test-scripts/test-c.sh | 88 ++++++++++++++++++++ test-scripts/test-java.sh | 78 ++++++++++++++++++ test-scripts/test-nodejs.sh | 86 +++++++++++++++++++ test-scripts/test-python.sh | 78 ++++++++++++++++++ 7 files changed, 670 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100755 test-scripts/run-all-tests.sh create mode 100755 test-scripts/test-c.sh create mode 100755 test-scripts/test-java.sh create mode 100755 test-scripts/test-nodejs.sh create mode 100755 test-scripts/test-python.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..47c69c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,133 @@ + +FROM debian:bookworm-slim AS base + +# Build Arguments +ARG ARCH=linux-aarch64 +ARG SDK_VERSION=0.800.3 +ARG JAVA_VERSION=17 +ARG SCANBOT_LICENSE="" + +# Environment Variables +ENV ARCH=${ARCH} \ + SDK_VERSION=${SDK_VERSION} \ + JAVA_VERSION=${JAVA_VERSION} \ + VENV_PATH=/opt/venv \ + SDK_BASE_URL="https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv" \ + SCANBOT_LICENSE=${SCANBOT_LICENSE} + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + # Build tools + build-essential \ + cmake \ + make \ + # Languages + openjdk-${JAVA_VERSION}-jdk \ + python3 \ + python3-venv \ + python3-pip \ + # Utilities + curl \ + git \ + ca-certificates \ + # Add Node.js repository and install + && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 \ + PATH="/usr/lib/jvm/java-17-openjdk-arm64/bin:/opt/venv/bin:${PATH}" + +# Verify installation and create architecture-agnostic symlink as fallback +RUN set -eux; \ + if [ ! -d "$JAVA_HOME" ]; then \ + JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))"; \ + fi; \ + ln -sf "$JAVA_HOME" /usr/local/java; \ + java -version; \ + javac -version + +# Set up Python virtual environment +RUN python3 -m venv $VENV_PATH \ + && pip install --upgrade pip setuptools wheel \ + && pip install opencv-python + +# Install Python SDK +RUN if [ "${ARCH}" = "linux-aarch64" ]; then \ + PYTHON_ARCH="linux_aarch64"; \ + else \ + PYTHON_ARCH="linux_x86_64"; \ + fi && \ + pip install "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-py3-none-${PYTHON_ARCH}.whl" && \ + echo "Python SDK installed successfully" + +# Set working directory and copy source code +WORKDIR /workspaces/scanbot-sdk-example-linux +COPY . . + +# Download and install all remaining SDKs in optimal locations +RUN echo "Installing Node.js, Java, and C SDKs for architecture: ${ARCH}" && \ + # Download platform-dependent SDKs (Java and C) + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.jar" && \ + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz" && \ + # Install Node.js SDK + cd examples/nodejs && \ + npm install "${SDK_BASE_URL}${SDK_VERSION}/nodejs-scanbotsdk-${SDK_VERSION}.tgz" && \ + cd /workspaces/scanbot-sdk-example-linux && \ + # Install Java SDK + mkdir -p examples/java/build/libs && \ + cp "scanbotsdk-${SDK_VERSION}-${ARCH}.jar" examples/java/build/libs/scanbotsdk.jar && \ + # Install C SDK + mkdir -p examples/c/build/scanbotsdk && \ + tar -xzf "scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz" -C examples/c/build/scanbotsdk --strip-components=1 && \ + # Clean up downloads + rm -f *.tar.gz *.jar && \ + echo "All SDKs installed successfully" + +# Copy test scripts +COPY test-scripts/ /tests/ +RUN chmod +x /tests/*.sh + +# Base verification - ensure all SDKs can be imported/built +RUN echo "=== SDK Integration Verification ===" \ + && python3 -c "import scanbotsdk; print('Python SDK: OK')" \ + && cd examples/nodejs && npm install && node -e "console.log('Node.js SDK:', require('scanbotsdk') ? 'OK' : 'FAIL')" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/java && ./gradlew build --no-daemon && echo "Java SDK: OK" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/c && mkdir -p build && cd build && cmake -DSCANBOTSDK_VERSION=${SDK_VERSION} .. && make && echo "C SDK: OK" + +# SDK Verification Stage +FROM base AS sdk-verification +RUN echo "=== Comprehensive SDK Verification ===" \ + && python3 -c "import scanbotsdk; print('Python SDK: Verified')" \ + && cd examples/nodejs && npm install && node -e "const sdk = require('scanbotsdk'); console.log('Node.js SDK: Verified')" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/java && ./gradlew check --no-daemon && echo "Java SDK: Verified" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/c && cd build && echo "C SDK: Verified" + +# Python Tests Stage +FROM sdk-verification AS python-tests +RUN echo "=== Running Python Command Tests ===" \ + && /tests/test-python.sh + +# Java Tests Stage +FROM sdk-verification AS java-tests +RUN echo "=== Running Java Command Tests ===" \ + && /tests/test-java.sh + +# Node.js Tests Stage +FROM sdk-verification AS nodejs-tests +RUN echo "=== Running Node.js Command Tests ===" \ + && /tests/test-nodejs.sh + +# C Tests Stage +FROM sdk-verification AS c-tests +RUN echo "=== Running C Command Tests ===" \ + && /tests/test-c.sh + +# All Tests Stage +FROM sdk-verification AS all-tests +RUN echo "=== Running Complete Test Suite ===" \ + && /tests/run-all-tests.sh \ + && echo "Python import and commands verified" \ + && echo "Java compilation and commands verified" \ + && echo "Node.js compilation and commands verified" \ + && echo "C compilation and commands verified" \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..270ae81 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,150 @@ +pipeline { + agent { label 'venus' } + + options { + timestamps() + timeout(time: 25, unit: 'MINUTES') + } + + parameters { + string( + name: 'SDK_VERSION', + defaultValue: '0.800.3', + trim: true, + description: 'Specify the Scanbot SDK version to test with' + ) + string( + name: 'BRANCH', + defaultValue: 'main', + trim: true, + description: 'Specify the branch to checkout for testing' + ) + } + + environment { + BASE_IMAGE_NAME = "scanbot-sdk-base:${params.SDK_VERSION}" + CONTAINER_WORKDIR = '/workspaces/scanbot-sdk-example-linux' + } + + stages { + + stage('Checkout Code') { + steps { + checkout scm + } + } + + stage('Build Base Image') { + steps { + script { + withCredentials([string(credentialsId:'linux-sdk-license', variable: 'SCANBOT_SDK_LICENSE_KEY')]) { + // Detect the architecture of the Jenkins agent + def agentArch = sh(script: 'uname -m', returnStdout: true).trim() + def dockerArch = '' + + if (agentArch == 'x86_64') { + dockerArch = 'linux-x86-64' + } else if (agentArch == 'aarch64' || agentArch == 'arm64') { + dockerArch = 'linux-aarch64' + } else { + error "Unsupported agent architecture: ${agentArch}" + } + + echo "Detected agent architecture: ${agentArch}. Using Docker architecture: ${dockerArch}" + echo "Building base image with Scanbot SDK version: ${params.SDK_VERSION}" + + sh """ + docker build \\ + --build-arg SDK_VERSION='${params.SDK_VERSION}' \\ + --build-arg ARCH='${dockerArch}' \\ + --build-arg SCANBOT_LICENSE='${SCANBOT_SDK_LICENSE_KEY}' \\ + --target sdk-verification \\ + -t ${env.BASE_IMAGE_NAME} \\ + . + """ + } + } + } + } + + stage('Run Tests in Parallel') { + parallel { + stage('Python Tests') { + steps { + echo "Running Python tests..." + sh """ + docker run --rm \\ + --env CI_MODE=true \\ + --workdir ${env.CONTAINER_WORKDIR} \\ + ${env.BASE_IMAGE_NAME} \\ + /tests/test-python.sh + """ + } + } + + stage('Java Tests') { + steps { + echo "Running Java tests..." + sh """ + docker run --rm \\ + --env CI_MODE=true \\ + --workdir ${env.CONTAINER_WORKDIR} \\ + ${env.BASE_IMAGE_NAME} \\ + /tests/test-java.sh + """ + } + } + + stage('Node.js Tests') { + steps { + echo "Running Node.js tests..." + sh """ + docker run --rm \\ + --env CI_MODE=true \\ + --workdir ${env.CONTAINER_WORKDIR} \\ + ${env.BASE_IMAGE_NAME} \\ + /tests/test-nodejs.sh + """ + } + } + + stage('C Tests') { + steps { + echo "Running C tests..." + sh """ + docker run --rm \\ + --env CI_MODE=true \\ + --workdir ${env.CONTAINER_WORKDIR} \\ + ${env.BASE_IMAGE_NAME} \\ + /tests/test-c.sh + """ + } + } + } + } + } + + post { + success { + echo 'All platform tests PASSED!' + echo 'All 4 platforms validated successfully' + echo 'Code is ready for merge' + } + failure { + echo 'Some platform tests FAILED!' + echo 'Check individual stage logs above' + echo 'Fix failing platforms before merge' + } + always { + sh """ + echo "Cleaning up Docker resources..." + docker rmi ${env.BASE_IMAGE_NAME} || true + docker system prune -f --filter "until=2h" || true + echo "Cleanup complete" + """ + + echo "Job finished. Cleaning up workspace." + cleanWs() + } + } +} diff --git a/test-scripts/run-all-tests.sh b/test-scripts/run-all-tests.sh new file mode 100755 index 0000000..35791a0 --- /dev/null +++ b/test-scripts/run-all-tests.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +echo "========================================" +echo " Scanbot SDK - Full Test Suite" +echo "========================================" + +# Track test results +FAILED_TESTS="" +TOTAL_TESTS=0 +PASSED_TESTS=0 + +run_test() { + local test_name="$1" + local test_script="$2" + + echo "" + echo "Running $test_name tests..." + TOTAL_TESTS=$((TOTAL_TESTS + 1)) + + if bash "$test_script"; then + echo "PASS: $test_name tests PASSED" + PASSED_TESTS=$((PASSED_TESTS + 1)) + else + echo "✗ $test_name tests FAILED" + FAILED_TESTS="$FAILED_TESTS $test_name" + fi +} + +# Run all test suites +run_test "Python" "/tests/test-python.sh" +run_test "Java" "/tests/test-java.sh" +run_test "Node.js" "/tests/test-nodejs.sh" +run_test "C" "/tests/test-c.sh" + +# Final report +echo "" +echo "========================================" +echo " Test Summary" +echo "========================================" +echo "Total test suites: $TOTAL_TESTS" +echo "Passed: $PASSED_TESTS" +echo "Failed: $((TOTAL_TESTS - PASSED_TESTS))" + +if [ $PASSED_TESTS -eq $TOTAL_TESTS ]; then + echo "" + echo "ALL TESTS PASSED!" + echo "Scanbot SDK is working correctly across all platforms." + exit 0 +else + echo "" + echo "Some tests failed:" + echo "$FAILED_TESTS" + echo "" + echo "Please check the logs above for details." + exit 1 +fi \ No newline at end of file diff --git a/test-scripts/test-c.sh b/test-scripts/test-c.sh new file mode 100755 index 0000000..4740e0a --- /dev/null +++ b/test-scripts/test-c.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +echo "=== C SDK Command Tests ===" + +# Find the project root directory +if [[ -d "/workspaces/scanbot-sdk-example-linux/examples/c" ]]; then + cd /workspaces/scanbot-sdk-example-linux/examples/c +elif [[ -d "examples/c" ]]; then + cd examples/c +else + echo "ERROR: Cannot find C examples directory" + exit 1 +fi + +# Test basic build first +echo "Testing C compilation..." +mkdir -p build +cd build +if cmake -DSCANBOTSDK_VERSION=0.800.3 .. >/dev/null 2>&1 && make >/dev/null 2>&1; then + echo "PASS: C compilation: PASSED" +else + echo "FAIL: C compilation: FAILED" + exit 1 +fi + +echo "Testing executable exists..." +if [[ -x "./scanbotsdk_example" ]]; then + echo "PASS: C executable: EXISTS" + ls -la scanbotsdk_example +else + echo "FAIL: C executable: NOT FOUND" + exit 1 +fi + +# Check if license is available +if [[ -z "${SCANBOT_LICENSE}" ]]; then + echo "ERROR: No license available" + echo "SCANBOT_LICENSE environment variable is not set" + echo "Tests cannot run without a valid license" + exit 1 +fi + +LICENSE_KEY="${SCANBOT_LICENSE}" + +echo "Testing SCAN commands..." +commands=( + "scan barcode --file ../../images/qrcode.png --license \"${LICENSE_KEY}\"" + "scan document --file ../../images/Document.JPG --license \"${LICENSE_KEY}\"" + "scan check --file ../../images/check.jpg --license \"${LICENSE_KEY}\"" + "scan credit_card --file ../../images/credit_card.png --license \"${LICENSE_KEY}\"" + "scan mrz --file \"../../images/MEXico MRZ passport old-1.jpg\" --license \"${LICENSE_KEY}\"" + "scan vin --file ../../images/VIN.png --license \"${LICENSE_KEY}\"" + "classify document --file ../../images/Document.JPG --license \"${LICENSE_KEY}\"" + "analyze analyze_multi_page --file ../../images/multi_page_document.pdf --license \"${LICENSE_KEY}\"" + "analyze crop_analyze --file ../../images/Document.JPG --save /tmp/crop.jpg --license \"${LICENSE_KEY}\"" + "parse mrz --text \"P/dev/null 2>&1; then + echo "PASS: $name: PASSED" + elif [[ $? -eq 124 ]]; then + echo "FAIL: $name: TIMEOUT" + exit 1 + else + echo "FAIL: $name: FAILED" + exit 1 + fi +done + +echo "PASS: C tests PASSED" diff --git a/test-scripts/test-java.sh b/test-scripts/test-java.sh new file mode 100755 index 0000000..5d14547 --- /dev/null +++ b/test-scripts/test-java.sh @@ -0,0 +1,78 @@ +#!/bin/bash +set -e + +echo "=== Java SDK Command Tests ===" + +# Find the project root directory +if [[ -d "/workspaces/scanbot-sdk-example-linux/examples/java" ]]; then + cd /workspaces/scanbot-sdk-example-linux/examples/java +elif [[ -d "examples/java" ]]; then + cd examples/java +else + echo "ERROR: Cannot find Java examples directory" + exit 1 +fi + +# Test basic build first +echo "Testing Java compilation..." +if ./gradlew build --no-daemon >/dev/null 2>&1; then + echo "PASS: Java compilation: PASSED" +else + echo "FAIL: Java compilation: FAILED" + exit 1 +fi + +# Check if license is available +if [[ -z "${SCANBOT_LICENSE}" ]]; then + echo "ERROR: No license available" + echo "SCANBOT_LICENSE environment variable is not set" + echo "Tests cannot run without a valid license" + exit 1 +fi + +LICENSE_KEY="${SCANBOT_LICENSE}" + +echo "Testing SCAN commands..." +# All failures are actual failures - no exceptions for license errors +commands=( + "scan barcode --file ../images/qrcode.png --license \"${LICENSE_KEY}\"" + "scan document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "scan check --file ../images/check.jpg --license \"${LICENSE_KEY}\"" + "scan credit_card --file ../images/credit_card.png --license \"${LICENSE_KEY}\"" + "scan mrz --file \"../images/MEXico MRZ passport old-1.jpg\" --license \"${LICENSE_KEY}\"" + "scan vin --file ../images/VIN.png --license \"${LICENSE_KEY}\"" + "classify document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "analyze analyze_multi_page --file ../images/multi_page_document.pdf --license \"${LICENSE_KEY}\"" + "analyze crop_analyze --file ../images/Document.JPG --save /tmp/crop.jpg --license \"${LICENSE_KEY}\"" + "parse mrz --text \"P/dev/null 2>&1; then + echo "PASS: $name: PASSED" + elif [[ $? -eq 124 ]]; then + echo "FAIL: $name: TIMEOUT" + exit 1 + else + echo "FAIL: $name: FAILED" + exit 1 + fi +done + +echo "PASS: Java tests PASSED" diff --git a/test-scripts/test-nodejs.sh b/test-scripts/test-nodejs.sh new file mode 100755 index 0000000..e0d084b --- /dev/null +++ b/test-scripts/test-nodejs.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -e + +echo "=== Node.js SDK Command Tests ===" + +# Find the project root directory +if [[ -d "/workspaces/scanbot-sdk-example-linux/examples/nodejs" ]]; then + cd /workspaces/scanbot-sdk-example-linux/examples/nodejs +elif [[ -d "examples/nodejs" ]]; then + cd examples/nodejs +else + echo "ERROR: Cannot find Node.js examples directory" + exit 1 +fi + +# Test basic functionality first +echo "Testing Node.js SDK import..." +if node -e "console.log(require('scanbotsdk') ? 'Scanbot SDK loaded successfully' : 'Error')" >/dev/null 2>&1; then + echo "PASS: Node.js SDK import: PASSED" +else + echo "FAIL: Node.js SDK import: FAILED" + exit 1 +fi + +echo "Testing TypeScript compilation..." +if npx tsc --noEmit >/dev/null 2>&1; then + echo "PASS: TypeScript compilation: PASSED" +else + echo "FAIL: TypeScript compilation: FAILED" + exit 1 +fi + +# Check if license is available +if [[ -z "${SCANBOT_LICENSE}" ]]; then + echo "ERROR: No license available" + echo "SCANBOT_LICENSE environment variable is not set" + echo "Tests cannot run without a valid license" + exit 1 +fi + +LICENSE_KEY="${SCANBOT_LICENSE}" + +echo "Testing SCAN commands..." +# All failures are actual failures - no exceptions for license errors +commands=( + "scan barcode --file ../images/qrcode.png --license \"${LICENSE_KEY}\"" + "scan document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "scan check --file ../images/check.jpg --license \"${LICENSE_KEY}\"" + "scan credit_card --file ../images/credit_card.png --license \"${LICENSE_KEY}\"" + "scan mrz --file \"../images/MEXico MRZ passport old-1.jpg\" --license \"${LICENSE_KEY}\"" + "scan vin --file ../images/VIN.png --license \"${LICENSE_KEY}\"" + "classify document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "analyze analyze_multi_page --file ../images/multi_page_document.pdf --license \"${LICENSE_KEY}\"" + "analyze crop_analyze --file ../images/Document.JPG --save /tmp/crop.jpg --license \"${LICENSE_KEY}\"" + "parse mrz --text \"P/dev/null 2>&1; then + echo "PASS: $name: PASSED" + elif [[ $? -eq 124 ]]; then + echo "FAIL: $name: TIMEOUT" + exit 1 + else + echo "FAIL: $name: FAILED" + exit 1 + fi +done + +echo "PASS: Node.js tests PASSED" diff --git a/test-scripts/test-python.sh b/test-scripts/test-python.sh new file mode 100755 index 0000000..3aedb07 --- /dev/null +++ b/test-scripts/test-python.sh @@ -0,0 +1,78 @@ +#!/bin/bash +set -e + +echo "=== Python SDK Command Tests ===" + +# Find the project root directory +if [[ -d "/workspaces/scanbot-sdk-example-linux/examples/python" ]]; then + cd /workspaces/scanbot-sdk-example-linux/examples/python +elif [[ -d "examples/python" ]]; then + cd examples/python +else + echo "ERROR: Cannot find Python examples directory" + exit 1 +fi + +# Test basic functionality first +echo "Testing Python imports..." +if python3 -c "import scanbotsdk; print('Scanbot SDK imported successfully')" 2>/dev/null; then + echo "PASS: Python SDK import: PASSED" +else + echo "FAIL: Python SDK import: FAILED" + exit 1 +fi + +# Check if license is available +if [[ -z "${SCANBOT_LICENSE}" ]]; then + echo "ERROR: No license available" + echo "SCANBOT_LICENSE environment variable is not set" + echo "Tests cannot run without a valid license" + exit 1 +fi + +LICENSE_KEY="${SCANBOT_LICENSE}" + +echo "Testing SCAN commands..." +# All failures are actual failures - no exceptions for license errors +commands=( + "scan barcode --file ../images/qrcode.png --license \"${LICENSE_KEY}\"" + "scan document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "scan check --file ../images/check.jpg --license \"${LICENSE_KEY}\"" + "scan credit_card --file ../images/credit_card.png --license \"${LICENSE_KEY}\"" + "scan mrz --file \"../images/MEXico MRZ passport old-1.jpg\" --license \"${LICENSE_KEY}\"" + "scan vin --file ../images/VIN.png --license \"${LICENSE_KEY}\"" + "classify document --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "analyze analyze_multi_page --file ../images/multi_page_document.pdf --license \"${LICENSE_KEY}\"" + "analyze crop_analyze --file ../images/Document.JPG --license \"${LICENSE_KEY}\"" + "parse mrz --text \"P/dev/null 2>&1; then + echo "PASS: $name: PASSED" + elif [[ $? -eq 124 ]]; then + echo "FAIL: $name: TIMEOUT" + exit 1 + else + echo "FAIL: $name: FAILED" + exit 1 + fi +done + +echo "PASS: Python tests PASSED" From 2970dfa1b346f118078f807901b19deec91e6a98 Mon Sep 17 00:00:00 2001 From: snsaqua8 Date: Fri, 17 Oct 2025 17:37:12 +0200 Subject: [PATCH 2/2] add tests and update example images --- Dockerfile | 45 ++++++++++++++++++++----------------- Jenkinsfile | 4 ++-- test-scripts/test-c.sh | 18 +++++++++++---- test-scripts/test-java.sh | 35 ++++++++++++++++++++++++----- test-scripts/test-nodejs.sh | 20 ++++++++++++----- test-scripts/test-python.sh | 18 +++++++++++---- 6 files changed, 99 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index 47c69c0..b40dfed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,17 +35,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get install -y nodejs \ && apt-get clean && rm -rf /var/lib/apt/lists/* -ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 \ - PATH="/usr/lib/jvm/java-17-openjdk-arm64/bin:/opt/venv/bin:${PATH}" - -# Verify installation and create architecture-agnostic symlink as fallback -RUN set -eux; \ - if [ ! -d "$JAVA_HOME" ]; then \ - JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))"; \ - fi; \ - ln -sf "$JAVA_HOME" /usr/local/java; \ - java -version; \ - javac -version +# Set JAVA_HOME +RUN export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") && \ + echo "JAVA_HOME=$JAVA_HOME" >> /etc/environment + +ENV PATH="/opt/venv/bin:${PATH}" + +# Verify Java installation +RUN java -version && javac -version # Set up Python virtual environment RUN python3 -m venv $VENV_PATH \ @@ -55,8 +52,10 @@ RUN python3 -m venv $VENV_PATH \ # Install Python SDK RUN if [ "${ARCH}" = "linux-aarch64" ]; then \ PYTHON_ARCH="linux_aarch64"; \ + SDK_ARCH="linux-aarch64"; \ else \ PYTHON_ARCH="linux_x86_64"; \ + SDK_ARCH="linux-x86_64"; \ fi && \ pip install "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-py3-none-${PYTHON_ARCH}.whl" && \ echo "Python SDK installed successfully" @@ -66,20 +65,26 @@ WORKDIR /workspaces/scanbot-sdk-example-linux COPY . . # Download and install all remaining SDKs in optimal locations -RUN echo "Installing Node.js, Java, and C SDKs for architecture: ${ARCH}" && \ - # Download platform-dependent SDKs (Java and C) - curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.jar" && \ - curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz" && \ - # Install Node.js SDK +RUN echo "Installing Java and C SDKs for architecture: ${ARCH}" && \ + # Set the correct SDK architecture for downloads + if [ "${ARCH}" = "linux-aarch64" ]; then \ + SDK_ARCH="linux-aarch64"; \ + else \ + SDK_ARCH="linux-x86_64"; \ + fi && \ + # Download platform-dependent SDKs (Java and C only) + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" && \ + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" && \ + # Install Node.js SDK (platform-independent npm package) cd examples/nodejs && \ npm install "${SDK_BASE_URL}${SDK_VERSION}/nodejs-scanbotsdk-${SDK_VERSION}.tgz" && \ cd /workspaces/scanbot-sdk-example-linux && \ - # Install Java SDK + # Setup Java SDK mkdir -p examples/java/build/libs && \ - cp "scanbotsdk-${SDK_VERSION}-${ARCH}.jar" examples/java/build/libs/scanbotsdk.jar && \ - # Install C SDK + cp "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" examples/java/build/libs/scanbotsdk.jar && \ + # Setup C SDK mkdir -p examples/c/build/scanbotsdk && \ - tar -xzf "scanbotsdk-${SDK_VERSION}-${ARCH}.tar.gz" -C examples/c/build/scanbotsdk --strip-components=1 && \ + tar -xzf "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" -C examples/c/build/scanbotsdk --strip-components=1 && \ # Clean up downloads rm -f *.tar.gz *.jar && \ echo "All SDKs installed successfully" diff --git a/Jenkinsfile b/Jenkinsfile index 270ae81..20eaa1b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { options { timestamps() - timeout(time: 25, unit: 'MINUTES') + timeout(time: 35, unit: 'MINUTES') } parameters { @@ -43,7 +43,7 @@ pipeline { def dockerArch = '' if (agentArch == 'x86_64') { - dockerArch = 'linux-x86-64' + dockerArch = 'linux-x86_64' } else if (agentArch == 'aarch64' || agentArch == 'arm64') { dockerArch = 'linux-aarch64' } else { diff --git a/test-scripts/test-c.sh b/test-scripts/test-c.sh index 4740e0a..a327c9d 100755 --- a/test-scripts/test-c.sh +++ b/test-scripts/test-c.sh @@ -46,15 +46,20 @@ LICENSE_KEY="${SCANBOT_LICENSE}" echo "Testing SCAN commands..." commands=( "scan barcode --file ../../images/qrcode.png --license \"${LICENSE_KEY}\"" - "scan document --file ../../images/Document.JPG --license \"${LICENSE_KEY}\"" + "scan document --file ../../images/Document.png --license \"${LICENSE_KEY}\"" "scan check --file ../../images/check.jpg --license \"${LICENSE_KEY}\"" "scan credit_card --file ../../images/credit_card.png --license \"${LICENSE_KEY}\"" - "scan mrz --file \"../../images/MEXico MRZ passport old-1.jpg\" --license \"${LICENSE_KEY}\"" + "scan document_extractor --file ../../images/Document.png --license \"${LICENSE_KEY}\"" + "scan medical_certificate --file ../../images/medical_certificate.png --license \"${LICENSE_KEY}\"" + "scan mrz --file ../../images/MRZ_passport.png --license \"${LICENSE_KEY}\"" + "scan ocr --file ../../images/Document.png --license \"${LICENSE_KEY}\"" + "scan text_pattern --file ../../images/Document.png --license \"${LICENSE_KEY}\"" "scan vin --file ../../images/VIN.png --license \"${LICENSE_KEY}\"" - "classify document --file ../../images/Document.JPG --license \"${LICENSE_KEY}\"" + "classify document --file ../../images/toll_receipt.png --license \"${LICENSE_KEY}\"" "analyze analyze_multi_page --file ../../images/multi_page_document.pdf --license \"${LICENSE_KEY}\"" - "analyze crop_analyze --file ../../images/Document.JPG --save /tmp/crop.jpg --license \"${LICENSE_KEY}\"" + "analyze crop_analyze --file ../../images/Document.png --license \"${LICENSE_KEY}\"" "parse mrz --text \"P