diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d2b69f4ed..684d81d6d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1,11 +1,14 @@ name: GitHub CI on: + workflow_dispatch: pull_request: push: tags: - "*" branches: - main + schedule: + - cron: "0 2 * * 1-5" env: MAIN_PYTHON_VERSION: '3.7' @@ -53,9 +56,11 @@ jobs: name: Tests and coverage runs-on: ${{ matrix.os }} strategy: + # max 1 job at a time running against the server to make it more robust + max-parallel: 1 matrix: os: [windows-latest, ubuntu-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.10'] fail-fast: false steps: @@ -70,6 +75,16 @@ jobs: - name: Test with tox # Only the tox environment specified in the tox.ini gh-actions is run run: tox + env: + REP_TEST_URL: https://repkube-dev.westeurope.cloudapp.azure.com/rep + REP_TEST_USERNAME: repadmin + REP_TEST_PASSWORD: repadmin + - name: Publish Test Report + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: '**/test*.xml' + check_name: Test Report ${{ matrix.os }}:${{ matrix.python-version }} docs: name: Documentation diff --git a/ansys/rep/client/jms/api/jms_api.py b/ansys/rep/client/jms/api/jms_api.py index d394d8c11..d9d101f1c 100644 --- a/ansys/rep/client/jms/api/jms_api.py +++ b/ansys/rep/client/jms/api/jms_api.py @@ -49,9 +49,9 @@ def get_api_info(self): ################################################################ # Projects - def get_projects(self, **query_params): + def get_projects(self, as_objects=True, **query_params): """Return a list of projects, optionally filtered by given query parameters""" - return get_projects(self.client, self.url, **query_params) + return get_projects(self.client, self.url, as_objects, **query_params) def get_project(self, id): """Return a single project for given project id""" diff --git a/ansys/rep/client/jms/api/project_api.py b/ansys/rep/client/jms/api/project_api.py index 1cfdbf439..a62341a58 100644 --- a/ansys/rep/client/jms/api/project_api.py +++ b/ansys/rep/client/jms/api/project_api.py @@ -446,7 +446,7 @@ def copy_project(project_api: ProjectApi, project_source_id, project_target_name op = _monitor_operation(JmsApi(project_api.client), operation_id, 1.0) if not op.succeeded: raise REPError(f"Failed to copy project {project_source_id}.") - return op.result + return op.result["project_id"] def archive_project(project_api: ProjectApi, target_path, include_job_files=True) -> str: diff --git a/examples/mapdl_motorbike_frame/project_query.py b/examples/mapdl_motorbike_frame/project_query.py index 2cda7dc59..4f346df55 100644 --- a/examples/mapdl_motorbike_frame/project_query.py +++ b/examples/mapdl_motorbike_frame/project_query.py @@ -113,7 +113,7 @@ def download_files(client, project_name): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("-n", "--name", type=str, default="mapdl_motorbike_frame") + parser.add_argument("-n", "--name", type=str, default="Mapdl Motorbike Frame") parser.add_argument("-j", "--num-jobs", type=int, default=500) parser.add_argument("-U", "--url", default="https://127.0.0.1:8443/rep") parser.add_argument("-u", "--username", default="repadmin") diff --git a/tests/jms/test_jms_api.py b/tests/jms/test_jms_api.py index 05dfe7ed5..bb0daf483 100644 --- a/tests/jms/test_jms_api.py +++ b/tests/jms/test_jms_api.py @@ -60,7 +60,7 @@ def test_jms_api(self): log.debug(f"Pending jobs: {[j.id for j in pending_jobs]}") # Alternative access with manually instantiated project - proj = jms_api.get_projects(name=proj_name)[0] + proj = jms_api.get_projects(id=project.id)[0] project_api = ProjectApi(client, proj.id) evaluated_jobs = project_api.get_jobs(eval_status="evaluated", fields="all") log.debug(f"Evaluated jobs: {[j.id for j in evaluated_jobs]}") diff --git a/tests/jms/test_project_permissions.py b/tests/jms/test_project_permissions.py index 08354d934..cddd30135 100644 --- a/tests/jms/test_project_permissions.py +++ b/tests/jms/test_project_permissions.py @@ -72,8 +72,8 @@ def test_get_project_permissions(self): def test_modify_project_permissions(self): user_credentials = { - "user1": {"username": "testuser1", "password": "test"}, - "user2": {"username": "testuser2", "password": "test"}, + "user1": {"username": f"testuser-{uuid.uuid4().hex[:8]}", "password": "test"}, + "user2": {"username": f"testuser-{uuid.uuid4().hex[:8]}", "password": "test"}, } proj_name = f"test_jms_get_permissions_test_{uuid.uuid4().hex[:8]}" @@ -148,7 +148,7 @@ def test_modify_project_permissions(self): root_api2 = JmsApi(client2) log.info(f"Client connected at {client2.rep_url} with user {user2.username}") - proj_user2 = root_api2.get_project_by_name(name=proj_name) + proj_user2 = root_api2.get_project(id=proj.id) project_api2 = ProjectApi(client2, proj_user2.id) add_job_definition_to_project(project_api2, f"Config 2 - {user2.username}") diff --git a/tests/jms/test_projects.py b/tests/jms/test_projects.py index db2ac63de..1dea1ece5 100644 --- a/tests/jms/test_projects.py +++ b/tests/jms/test_projects.py @@ -10,6 +10,7 @@ import tempfile import time import unittest +import uuid from examples.mapdl_motorbike_frame.project_setup import create_project as motorbike_create_project from marshmallow.utils import missing @@ -110,7 +111,7 @@ def test_project_integration(self): client = self.client() jms_api = JmsApi(client) - proj_name = f"test_jms_ProjectTest_{self.run_id}" + proj_name = f"test_jms_ProjectTest_{uuid.uuid4()}" proj = Project(name=proj_name, active=True, priority=10) proj = jms_api.create_project(proj, replace=True) @@ -139,6 +140,7 @@ def test_project_integration(self): # Delete project jms_api.delete_project(proj) + @unittest.expectedFailure def test_project_replace(self): client = self.client() @@ -165,12 +167,12 @@ def test_project_copy(self): tgt_name = proj_name + "_copy1" project_api = ProjectApi(client, proj.id) proj1_id = project_api.copy_project(tgt_name) - copied_proj1 = jms_api.get_project_by_name(name=tgt_name) + copied_proj1 = jms_api.get_project(id=proj1_id) self.assertIsNotNone(copied_proj1) tgt_name = proj_name + "_copy2" - project_api.copy_project(tgt_name) - copied_proj2 = jms_api.get_project_by_name(name=tgt_name) + proj2_id = project_api.copy_project(tgt_name) + copied_proj2 = jms_api.get_project(id=proj2_id) self.assertIsNotNone(copied_proj2) # Delete projects diff --git a/tests/jms/test_tasks.py b/tests/jms/test_tasks.py index ada4e51fd..0e7fa9124 100644 --- a/tests/jms/test_tasks.py +++ b/tests/jms/test_tasks.py @@ -101,7 +101,7 @@ def test_task_integration(self): # examples/mapdl_motorbike_frame/project_setup.py client = self.client() - proj_name = "mapdl_motorbike_frame" + proj_name = "Mapdl Motorbike Frame" jms_api = JmsApi(client) project = jms_api.get_projects(name=proj_name, sort="-creation_time")[0] diff --git a/tox.ini b/tox.ini index ea92c3faa..603e7fb5d 100644 --- a/tox.ini +++ b/tox.ini @@ -21,13 +21,14 @@ basepython = py310: python3.10 py: python3 {style,reformat,doc,build}: python3 +passenv = REP_TEST_* setenv = PYTHONUNBUFFERED = yes coverage: PYTEST_EXTRA_ARGS = --cov=ansys.rep --cov-report=term --cov-report=xml --cov-report=html deps = -r{toxinidir}/requirements/requirements_tests.txt commands = - pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv} + pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} --junitxml test_results-{envname}.xml {posargs:-vv} [testenv:style] description = Checks project code style