Skip to content

Commit 04c8b38

Browse files
committed
Add python workflow
1 parent fb7e7c4 commit 04c8b38

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed
+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Python SDK Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
tags: ["v*"]
8+
paths:
9+
- 'sdks/python/test-optimization-sdk/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- 'sdks/python/test-optimization-sdk/**'
14+
15+
jobs:
16+
linux-amd64-test:
17+
name: Run Python SDK Tests on Linux AMD64
18+
runs-on: ubuntu-latest
19+
defaults:
20+
run:
21+
working-directory: sdks/python/test-optimization-sdk
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.10'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -e .
36+
pip install pytest
37+
38+
- name: Run tests
39+
run: pytest --capture=no
40+
41+
linux-arm64-test:
42+
name: Run Python SDK Tests on Linux ARM64
43+
runs-on: ubuntu-latest
44+
defaults:
45+
run:
46+
working-directory: sdks/python/test-optimization-sdk
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Build and run tests
59+
run: |
60+
docker buildx build --platform linux/arm64 -t python-test-optimization-sdk-test . --load
61+
docker run python-test-optimization-sdk-test
62+
63+
macos-test:
64+
name: Run Python SDK Tests on macOS
65+
runs-on: macos-latest
66+
defaults:
67+
run:
68+
working-directory: sdks/python/test-optimization-sdk
69+
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v4
73+
74+
- name: Set up Python
75+
uses: actions/setup-python@v4
76+
with:
77+
python-version: '3.10'
78+
79+
- name: Install dependencies
80+
run: |
81+
python -m pip install --upgrade pip
82+
pip install -e .
83+
pip install pytest
84+
85+
- name: Run tests
86+
run: pytest --capture=no
87+
88+
windows-test:
89+
name: Run Python SDK Tests on Windows
90+
runs-on: windows-latest
91+
defaults:
92+
run:
93+
working-directory: sdks/python/test-optimization-sdk
94+
95+
steps:
96+
- name: Checkout repository
97+
uses: actions/checkout@v4
98+
99+
- name: Set up Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: '3.10'
103+
104+
- name: Install dependencies
105+
run: |
106+
python -m pip install --upgrade pip
107+
pip install -e .
108+
pip install pytest
109+
110+
- name: Run tests
111+
run: pytest --capture=no
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use the official Python image as the base
2+
FROM python:3.10-slim-bullseye
3+
4+
# Set the working directory
5+
WORKDIR /usr/src/test-optimization-sdk
6+
7+
# Install build dependencies
8+
RUN apt-get update && apt-get install -y pkg-config libssl-dev
9+
10+
# Copy the setup files first to leverage Docker cache
11+
COPY setup.py ./
12+
13+
# Copy the source code
14+
COPY src ./src
15+
COPY tests ./tests
16+
17+
# Install the package in development mode and install pytest
18+
RUN pip install --upgrade pip && \
19+
pip install -e . && \
20+
pip install pytest
21+
22+
# Run the tests
23+
CMD ["pytest", "--capture=no"]

0 commit comments

Comments
 (0)