diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..684004c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,35 @@ +name: python-sdk + +on: + push: + branches: + - '**' + + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + test-bindings: + name: Test python SDK bindings + runs-on: + - self-hosted + - Linux + - X64 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Prep calibration files + run: cp /mnt/jenkins/python-sdk-ci-test/calibration_*.json . + + - name: Build docker image + run: docker build . --tag ci_rust_$GITHUB_SHA -f ci/Dockerfile + + - name: Run tests + run: | + docker run --rm -v /mnt/jenkins/python-sdk-ci-test:/root/Documents/cepton ci_rust_$GITHUB_SHA bash -ex -c ' + cd /app + python3 -m unittest discover -s tests + ' diff --git a/.gitignore b/.gitignore index 311a5b3..4c739c2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/ __pycache__/ *.egg-info *.egg -data/ \ No newline at end of file +data/ +calibration_*.json diff --git a/cepton_sdk3/lib/linux-x64/libcepton_sdk2.so b/cepton_sdk3/lib/linux-x64/libcepton_sdk2.so index 06d41a5..620465e 100755 Binary files a/cepton_sdk3/lib/linux-x64/libcepton_sdk2.so and b/cepton_sdk3/lib/linux-x64/libcepton_sdk2.so differ diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..fbccfad --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,14 @@ +# Use official Python 3.12 base image +FROM python:3.12-slim + + +WORKDIR /app + +COPY . . +RUN pip install --upgrade pip && pip install . + +# Copy all calibration files from the mounted folder into the +# sdk directory so it can find them. +COPY calibration_*.json /app/cepton_sdk3/lib/linux-x64/ + +CMD ["/bin/bash"] diff --git a/tests/test_basic.py b/tests/test_basic.py index 8e05bfa..6b57aef 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -5,13 +5,25 @@ import cepton_sdk3 as sdk -class SdkApiTest(unittest.TestCase): - """API tests""" +class BasicTests(unittest.TestCase): + """Basic tests""" def test_initialize(self): """Test initialize and deinitialize""" sdk.initialize() sdk.deinitialize() - def test_read_frames(self): - """No-op""" + def test_replay(self): + """Test that replay works""" + sdk.initialize() + sdk.enable_frame_fifo(0, 10) + sdk.load_pcap("/root/Documents/cepton/lobby-1.pcap") + + frame_counts = [] + for _ in range(10): + frame = sdk.frame_fifo_get_frame(2000) + frame_counts.append(frame.positions.shape[0]) + + self.assertTrue(all(count > 0 for count in frame_counts)) + + sdk.deinitialize()