diff --git a/.github/workflows/testing-pipeline.yml b/.github/workflows/testing-pipeline.yml index a8a916fa1..5d4adb2d3 100644 --- a/.github/workflows/testing-pipeline.yml +++ b/.github/workflows/testing-pipeline.yml @@ -116,3 +116,63 @@ jobs: uses: tj-actions/changed-files@v41 - name: Check for Version Change run: ci/check_version_bump.py ${{ steps.get_changed_files.outputs.all_changed_and_modified_files }} + + test_rqd_python_3_8: + name: Test RQD with python 3.8 + runs-on: ubuntu-latest + container: + image: python:3.8 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh + + test_rqd_python_3_9: + name: Test RQD with python 3.9 + runs-on: ubuntu-latest + container: + image: python:3.9 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh + + test_rqd_python_3_10: + name: Test RQD with python 3.10 + runs-on: ubuntu-latest + container: + image: python:3.10 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh + + test_rqd_python_3_11: + name: Test RQD with python 3.11 + runs-on: ubuntu-latest + container: + image: python:3.11 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh + + test_rqd_python_3_12: + name: Test RQD with python 3.12 + runs-on: ubuntu-latest + container: + image: python:3.12 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh + + test_rqd_python_3_13: + name: Test RQD with python 3.13 + runs-on: ubuntu-latest + container: + image: python:3.13 + steps: + - uses: actions/checkout@v4 + - name: Run Python Tests + run: ci/run_rqd_python_tests.sh diff --git a/ci/run_rqd_python_tests.sh b/ci/run_rqd_python_tests.sh new file mode 100755 index 000000000..1d5c2d079 --- /dev/null +++ b/ci/run_rqd_python_tests.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Script for running OpenCue RQD unit tests with vanilla python +# +# This script is written to be run within the OpenCue GitHub Actions environment. +# See `.github/workflows/testing-pipeline.yml`. + +set -e + +args=("$@") +python_version=$(python -V 2>&1) +echo "Will run tests using ${python_version}" + +pip install --user -r requirements/rqd.txt -r requirements/tests.txt + +# Protos need to have their Python code generated in order for tests to pass. +python -m grpc_tools.protoc -I=proto/ --python_out=pycue/opencue/compiled_proto --grpc_python_out=pycue/opencue/compiled_proto proto/*.proto +python -m grpc_tools.protoc -I=proto/ --python_out=rqd/rqd/compiled_proto --grpc_python_out=rqd/rqd/compiled_proto proto/*.proto + +# Fix imports to work in both Python 2 and 3. See +# for more info. +python ci/fix_compiled_proto.py pycue/opencue/compiled_proto +python ci/fix_compiled_proto.py rqd/rqd/compiled_proto + +python -m unittest discover -s pycue/tests -t pycue -p "*.py" +python -m pytest rqd/tests diff --git a/requirements/rqd.txt b/requirements/rqd.txt new file mode 100644 index 000000000..4bf32be84 --- /dev/null +++ b/requirements/rqd.txt @@ -0,0 +1,10 @@ +future==1.0.0 +docker==7.1.0 +grpcio==1.48.2;python_version<"3.7" +grpcio-tools==1.48.2;python_version<"3.7" +grpcio==1.53.2;python_version>="3.7" and python_version<"3.12" +grpcio-tools==1.53.0;python_version>="3.7" and python_version<"3.12" +grpcio==1.66.2;python_version>="3.12" +grpcio-tools==1.66.2;python_version>="3.12" +PyYAML==5.1 +psutil==5.9.8 diff --git a/requirements/tests.txt b/requirements/tests.txt new file mode 100644 index 000000000..2ea7e1f8f --- /dev/null +++ b/requirements/tests.txt @@ -0,0 +1,5 @@ +mock==2.0.0 +pyfakefs==3.6;python_version<"3.7" +pyfakefs==5.2.3;python_version>="3.7" +pynput==1.7.6 +pytest==8.3.3 \ No newline at end of file diff --git a/rqd/tests/rqconstants_test.py b/rqd/tests/rqconstants_test.py index 0503994a2..2a1553d81 100644 --- a/rqd/tests/rqconstants_test.py +++ b/rqd/tests/rqconstants_test.py @@ -91,7 +91,7 @@ class RqConstantTests(pyfakefs.fake_filesystem_unittest.TestCase): tempdir = tempfile.mkdtemp() def setUp(self): - self.setUpPyfakefs() + self.setUpPyfakefs(additional_skip_names=['shutil']) self.fs.add_real_directory(self.tempdir) self.fs.create_file("/proc/cpuinfo", contents=CPUINFO) self.loadavg = self.fs.create_file("/proc/loadavg", contents=LOADAVG_LOW_USAGE)