Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
138 changes: 138 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

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/*

# 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 \
&& pip install --upgrade pip setuptools wheel \
&& pip install opencv-python

# 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"

# 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 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 && \
# Setup Java SDK
mkdir -p examples/java/build/libs && \
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}-${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"

# 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"
150 changes: 150 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
pipeline {
agent { label 'venus' }

options {
timestamps()
timeout(time: 35, 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()
}
}
}
57 changes: 57 additions & 0 deletions test-scripts/run-all-tests.sh
Original file line number Diff line number Diff line change
@@ -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
Loading