From c77b1c48f2b3cd17653b7edd4e949d5b0517e569 Mon Sep 17 00:00:00 2001 From: Casey Jao Date: Mon, 20 Jan 2025 15:06:10 -0500 Subject: [PATCH] Fix tests breaking on macos Reorder test steps to prevent side effects from unit tests affecting the functional tests Trigger local executor tests for PRs --- .github/workflows/test_matrix.json | 6 +-- .github/workflows/tests.yml | 48 +++++++++---------- CHANGELOG.md | 2 + .../_cli/service_test.py | 10 ++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/.github/workflows/test_matrix.json b/.github/workflows/test_matrix.json index 8ffad5265..229830491 100644 --- a/.github/workflows/test_matrix.json +++ b/.github/workflows/test_matrix.json @@ -13,7 +13,7 @@ "container": "ghcr.io/agnostiqhq/covalent-dev/debian12-py310:latest", "backend": "local", "experimental": false, - "trigger": ["schedule", "workflow_dispatch"] + "trigger": ["schedule", "workflow_dispatch", "pull_request"] }, { "name": "Debian 12 / Python 3.11 / Dask", @@ -29,7 +29,7 @@ "container": "ghcr.io/agnostiqhq/covalent-dev/debian12-py311:latest", "backend": "local", "experimental": false, - "trigger": ["schedule", "workflow_dispatch"] + "trigger": ["schedule", "workflow_dispatch", "pull_request"] }, { "name": "Debian 12 / Python 3.12 / Dask", @@ -45,7 +45,7 @@ "container": "ghcr.io/agnostiqhq/covalent-dev/debian12-py312:latest", "backend": "local", "experimental": false, - "trigger": ["schedule", "workflow_dispatch"] + "trigger": ["schedule", "workflow_dispatch", "pull_request"] }, { "name": "MacOS 13 / Python 3.10 / Dask", diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cd2339c5d..482daf94b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -204,6 +204,30 @@ jobs: if: steps.build-dist.outcome == 'success' run: pip install dist/covalent-*.tar.gz + - name: Run SDK tests and measure coverage + id: sdk-tests + if: > + steps.modified-files.outputs.sdk == 'true' + || env.BUILD_AND_RUN_ALL + run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/covalent_tests --cov=covalent --cov-config=.coveragerc + + - name: Generate SDK coverage report + id: sdk-coverage + if: steps.sdk-tests.outcome == 'success' + run: coverage xml -o sdk_coverage.xml + + - name: Run dispatcher tests and measure coverage + id: dispatcher-tests + if: > + steps.modified-files.outputs.dispatcher == 'true' + || env.BUILD_AND_RUN_ALL + run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/covalent_dispatcher_tests --cov=covalent_dispatcher --cov-config=.coveragerc + + - name: Generate dispatcher coverage report + id: dispatcher-coverage + if: steps.dispatcher-tests.outcome == 'success' + run: coverage xml -o dispatcher_coverage.xml + - name: Start Covalent dispatcher server if: env.BUILD_AND_RUN_ALL id: covalent_start @@ -230,30 +254,6 @@ jobs: covalent cluster --info covalent cluster --logs - - name: Run SDK tests and measure coverage - id: sdk-tests - if: > - steps.modified-files.outputs.sdk == 'true' - || env.BUILD_AND_RUN_ALL - run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/covalent_tests --cov=covalent --cov-config=.coveragerc - - - name: Generate SDK coverage report - id: sdk-coverage - if: steps.sdk-tests.outcome == 'success' - run: coverage xml -o sdk_coverage.xml - - - name: Run dispatcher tests and measure coverage - id: dispatcher-tests - if: > - steps.modified-files.outputs.dispatcher == 'true' - || env.BUILD_AND_RUN_ALL - run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/covalent_dispatcher_tests --cov=covalent_dispatcher --cov-config=.coveragerc - - - name: Generate dispatcher coverage report - id: dispatcher-coverage - if: steps.dispatcher-tests.outcome == 'success' - run: coverage xml -o dispatcher_coverage.xml - - name: Run functional tests and measure coverage id: functional-tests if: env.BUILD_AND_RUN_ALL diff --git a/CHANGELOG.md b/CHANGELOG.md index 20961cd8c..3ac75a4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Disabled codecov in CI - Removed qelectron tests from CI - Updated recommended platform to Python 3.12 +- Run local executor tests for PRs ### Fixed - `get_result(wait=True)` no longer times out +- Fixed tests on mac ### Changed diff --git a/tests/covalent_dispatcher_tests/_cli/service_test.py b/tests/covalent_dispatcher_tests/_cli/service_test.py index 891c9cba7..e24bc06e0 100644 --- a/tests/covalent_dispatcher_tests/_cli/service_test.py +++ b/tests/covalent_dispatcher_tests/_cli/service_test.py @@ -100,11 +100,15 @@ def test_python_path_in_venv(): venv.create(tmp_dir, with_pip=False) custom_env = os.environ.copy() # equivalent of source venv/bin/activate - custom_env["VIRTUAL_ENV"] = tmp_dir + custom_env["VIRTUAL_ENV"] = os.path.realpath(tmp_dir) custom_env["PATH"] = f"{tmp_dir}/bin:$PATH" - check_path_cmd = ["python", "-c", "import sys; print(sys.executable)"] + check_path_cmd = [ + "python", + "-c", + "import os; import sys; print(os.path.realpath(sys.executable))", + ] res = subprocess.run(check_path_cmd, check=True, capture_output=True, env=custom_env) - assert res.stdout.decode().startswith(tmp_dir) + assert res.stdout.decode().startswith(os.path.realpath(tmp_dir)) def test_read_pid_nonexistent_file():