-
Notifications
You must be signed in to change notification settings - Fork 0
Test linux example and github workflow #3
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
Open
sns8aqua
wants to merge
2
commits into
main
Choose a base branch
from
test-github-action-linux
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # GitHub Actions workflow for testing the Linux SDK example project | ||
| # Supports both x86_64 and ARM64 architectures running in parallel | ||
| name: Linux SDK Example CI Test | ||
|
|
||
| # Trigger conditions | ||
| on: | ||
| # Run on pushes to main branches affecting examples | ||
| push: | ||
| branches: [ "main", "develop" ] | ||
| paths: | ||
| - 'examples/**' | ||
| - 'test-scripts/**' | ||
| - 'Dockerfile' | ||
| - '.github/workflows/linux-test.yml' | ||
| # Run on pull requests to main branches affecting examples | ||
| pull_request: | ||
| branches: [ "main", "develop" ] | ||
| paths: | ||
| - 'examples/**' | ||
| - 'test-scripts/**' | ||
| - 'Dockerfile' | ||
| - '.github/workflows/linux-test.yml' | ||
| # Allow manual triggering with custom parameters | ||
| # TODO: we could remove test suite option later its just for testing purposes | ||
| workflow_dispatch: | ||
| inputs: | ||
| sdk_version: | ||
| description: 'SDK Version to test' | ||
| required: false | ||
| default: '0.800.5' | ||
| type: string | ||
| test_suite: | ||
| description: 'Test suite to run' | ||
| required: false | ||
| default: 'all' | ||
| type: choice | ||
| options: | ||
| - all | ||
| - python | ||
| - java | ||
| - nodejs | ||
| - c | ||
|
|
||
| # Global environment variables | ||
| # TODO: This needs to be checked out from github or the app itself centralized | ||
| env: | ||
| DEFAULT_SDK_VERSION: '0.800.5' | ||
|
|
||
| jobs: | ||
| test-x86_64: | ||
| name: Test x86_64 Architecture | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| # Get the source code | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| # Configure Docker Buildx | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| # Build the Docker image using the existing Dockerfile | ||
| - name: Build Docker image (x86_64) | ||
| run: | | ||
| docker build \ | ||
| --build-arg SDK_VERSION=${{ inputs.sdk_version || env.DEFAULT_SDK_VERSION }} \ | ||
| --build-arg ARCH=linux-x86_64 \ | ||
| --target base \ | ||
| -t scanbot-linux-x86_64:latest . | ||
|
|
||
| # Run the test suite using dedicated script | ||
| - name: Run test suite (x86_64) | ||
| env: | ||
| SCANBOT_LICENSE: ${{ secrets.SCANBOT_LICENSE_KEY }} | ||
| run: | | ||
| # Run tests inside the Docker container | ||
| case "${{ inputs.test_suite || 'all' }}" in | ||
| "python") | ||
| docker run --rm --env SCANBOT_LICENSE="${SCANBOT_LICENSE}" scanbot-linux-x86_64:latest /tests/test-python.sh | ||
| ;; | ||
| "java") | ||
| docker run --rm --env SCANBOT_LICENSE="${SCANBOT_LICENSE}" scanbot-linux-x86_64:latest /tests/test-java.sh | ||
| ;; | ||
| "nodejs") | ||
| docker run --rm --env SCANBOT_LICENSE="${SCANBOT_LICENSE}" scanbot-linux-x86_64:latest /tests/test-nodejs.sh | ||
| ;; | ||
| "c") | ||
| docker run --rm --env SCANBOT_LICENSE="${SCANBOT_LICENSE}" scanbot-linux-x86_64:latest /tests/test-c.sh | ||
| ;; | ||
| "all"|*) | ||
| docker run --rm --env SCANBOT_LICENSE="${SCANBOT_LICENSE}" scanbot-linux-x86_64:latest /tests/run-all-tests.sh | ||
| ;; | ||
| esac | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
|
|
||
| FROM debian:bookworm-slim AS base | ||
|
|
||
| # Build Arguments | ||
| ARG ARCH | ||
| ARG SDK_VERSION | ||
| ARG JAVA_VERSION=17 | ||
| ARG SCANBOT_LICENSE | ||
|
|
||
| # Environment Variables | ||
| ENV ARCH=${ARCH} \ | ||
| SDK_VERSION=${SDK_VERSION} \ | ||
| JAVA_VERSION=${JAVA_VERSION} \ | ||
| PYENV_ROOT="/opt/pyenv" \ | ||
| PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ | ||
| 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 \ | ||
| libssl-dev \ | ||
| zlib1g-dev \ | ||
| libbz2-dev \ | ||
| libreadline-dev \ | ||
| libsqlite3-dev \ | ||
| libffi-dev \ | ||
| liblzma-dev \ | ||
| # Languages | ||
| openjdk-${JAVA_VERSION}-jdk \ | ||
| # 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/* | ||
|
|
||
| # Install pyenv and Python 3.6.15 | ||
| RUN git clone --depth=1 https://github.com/pyenv/pyenv.git $PYENV_ROOT \ | ||
| && pyenv install 3.6.15 \ | ||
| && pyenv global 3.6.15 \ | ||
| && pyenv rehash | ||
|
|
||
| # 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 packages | ||
| RUN export PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ | ||
| && eval "$(/opt/pyenv/bin/pyenv init -)" \ | ||
| && python -m pip install --upgrade pip setuptools wheel \ | ||
| # The opencv-python version is specified to ensure compatibility with Python 3.6 and speed up docker builds | ||
| # Once the python is upgraded to 3.7+, this can be changed to just `opencv-python` | ||
| && python -m pip install opencv-python==4.5.5.64 numpy pillow | ||
|
|
||
| # 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 && \ | ||
| python -m 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 | ||
|
|
||
| # SDK Verification Stage | ||
| FROM base AS sdk-verification | ||
| RUN echo "=== Comprehensive SDK Verification ===" \ | ||
| && python -c "import scanbotsdk; print('Python SDK: Verified')" \ | ||
| && cd examples/nodejs && npm install && node -e "const sdk = require('scanbotsdk'); console.log(sdk ? 'OK' : 'FAIL');" \ | ||
| && cd /workspaces/scanbot-sdk-example-linux/examples/java && ./gradlew check --no-daemon && echo "Java SDK: Verified" \ | ||
| && cd /workspaces/scanbot-sdk-example-linux/examples/c && mkdir -p build && cd build && cmake -DSCANBOTSDK_VERSION=${SDK_VERSION} .. && make && echo "C SDK: OK" | ||
|
|
||
| # 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" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still insist on using commit hash, instead of tag version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AH, my bad , defenitely agree with you. Will push the changes.