diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 584b1920b..54c0bb9c1 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -7,9 +7,11 @@ on: revn: type: choice options: + - '252' - '251' - '242' - '241' + - '232' description: 'The Mechanical revision number to run tests on.' default: '242' #stable version is 242, must match $stable_container schedule: @@ -35,8 +37,8 @@ env: DOCUMENTATION_CNAME: mechanical.docs.pyansys.com MAIN_PYTHON_VERSION: '3.10' # DEV_REVN & its Docker image are used in scheduled or registry package runs - DEV_REVN: '251' - DEV_DOCKER_IMAGE_VERSION: '25.1_candidate' + STABLE_REVN: '242' + DEV_REVN: '252' LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }} @@ -124,39 +126,41 @@ jobs: name: Save variations of revn runs-on: ubuntu-latest outputs: - # ghcr.io/ansys/mechanical:24.2.0 stable_container: ${{ steps.save-versions.outputs.stable_container }} - # '242' or '251' test_revn: '${{ steps.save-versions.outputs.test_revn }}' - # ghcr.io/ansys/mechanical:24.2.0 or ghcr.io/ansys/mechanical:25.1.0 test_container: ${{ steps.save-versions.outputs.test_container }} - # '24.2.0' or '25.1.0' test_docker_image_version: '${{ steps.save-versions.outputs.test_docker_image_version }}' steps: - id: save-versions run: | if ${{ github.event_name == 'schedule' }}; then - # 251 echo "test_revn=${{ env.DEV_REVN}}" >> $GITHUB_OUTPUT - # ghcr.io/ansys/mechanical:24.2_candidate - echo "test_container=${{ env.DOCKER_PACKAGE }}:${{ env.DEV_DOCKER_IMAGE_VERSION }}" >> $GITHUB_OUTPUT - # 25.1_candidate - echo "test_docker_image_version=${{ env.DEV_DOCKER_IMAGE_VERSION }}" >> $GITHUB_OUTPUT + test_mech_revn=${{ env.DEV_REVN}} + test_mech_image_version=${test_mech_revn:0:2}.${test_mech_revn:2}_candidate + echo "test_container=${{ env.DOCKER_PACKAGE }}:$test_mech_image_version" >> $GITHUB_OUTPUT + echo "test_docker_image_version=$test_mech_image_version" >> $GITHUB_OUTPUT else if [[ -z "${{inputs.revn}}" ]]; then - export mech_revn=242 + mech_revn=${{ env.STABLE_REVN }} else - export mech_revn=${{inputs.revn}} + mech_revn=${{inputs.revn}} fi export mech_image_version=${mech_revn:0:2}.${mech_revn:2}.0 echo "test_revn=$mech_revn" >> $GITHUB_OUTPUT - # ghcr.io/ansys/mechanical:24.2.0 echo "test_container=${{ env.DOCKER_PACKAGE }}:$mech_image_version" >> $GITHUB_OUTPUT - # 24.2.0 echo "test_docker_image_version=$mech_image_version" >> $GITHUB_OUTPUT fi - echo "stable_container=${{ env.DOCKER_PACKAGE }}:24.2.0" >> $GITHUB_OUTPUT + stable_mech_revn=${{ env.STABLE_REVN }} + stable_mech_image_version=${mech_revn:0:2}.${mech_revn:2}.0 + echo "stable_container=${{ env.DOCKER_PACKAGE }}:$stable_mech_image_version" >> $GITHUB_OUTPUT + + echo $GITHUB_OUTPUT + + # --- Help ---- + # schedule nightly uses DEV_REVN candidate + # PRs and merges use STABLE_REVN + # Workflow dispatch can use any revision number config-matrix: runs-on: ubuntu-latest @@ -166,9 +170,7 @@ jobs: steps: - id: set-matrix run: | - # Run all stable mechanical versions release tags - # For nightly scheduled runs use pre-release (25.1_candidate) - # For pull requests and merges use latest stable version (242) + # if a tag(release) is pushed, test all versions if ${{ github.event_name == 'push' }} && ${{ contains(github.ref, 'refs/tags') }}; then echo "matrix={\"mechanical-version\":['23.2.0', '24.1.0', '24.2.0'],\"experimental\":[false]}" >> $GITHUB_OUTPUT else @@ -184,8 +186,8 @@ jobs: run: | sudo apt update sudo apt install bc -y - CONTAINER_VERSION=$(echo "${{ needs.revn-variations.outputs.test_docker_image_version }}" | grep -o -E '[0-9]+(\.[0-9]+)?' | head -n 1) - if (( $(echo "$CONTAINER_VERSION > 24.2" | bc -l) )); then + container_version=$(echo "${{ needs.revn-variations.outputs.test_docker_image_version }}" | grep -o -E '[0-9]+(\.[0-9]+)?' | head -n 1) + if (( $(echo "$container_version > 24.2" | bc -l) )); then echo "container_stable_exit=true" >> $GITHUB_OUTPUT else echo "container_stable_exit=false" >> $GITHUB_OUTPUT diff --git a/doc/changelog.d/1022.added.md b/doc/changelog.d/1022.added.md new file mode 100644 index 000000000..fe71d4afa --- /dev/null +++ b/doc/changelog.d/1022.added.md @@ -0,0 +1 @@ +Add project directory property \ No newline at end of file diff --git a/doc/changelog.d/1023.maintenance.md b/doc/changelog.d/1023.maintenance.md new file mode 100644 index 000000000..398f0d3a9 --- /dev/null +++ b/doc/changelog.d/1023.maintenance.md @@ -0,0 +1 @@ +Update ngihtly for pre-release version \ No newline at end of file diff --git a/doc/changelog.d/1029.fixed.md b/doc/changelog.d/1029.fixed.md new file mode 100644 index 000000000..7996cc7e0 --- /dev/null +++ b/doc/changelog.d/1029.fixed.md @@ -0,0 +1 @@ +Process return code \ No newline at end of file diff --git a/src/ansys/mechanical/core/embedding/app.py b/src/ansys/mechanical/core/embedding/app.py index 43d16cd83..80e79524b 100644 --- a/src/ansys/mechanical/core/embedding/app.py +++ b/src/ansys/mechanical/core/embedding/app.py @@ -433,6 +433,11 @@ def version(self): """Returns the version of the app.""" return self._version + @property + def project_directory(self): + """Returns the current project directory.""" + return self.DataModel.Project.ProjectDirectory + def _share(self, other) -> None: """Shares the state of self with other. diff --git a/src/ansys/mechanical/core/embedding/ui.py b/src/ansys/mechanical/core/embedding/ui.py index af631b460..77418039a 100644 --- a/src/ansys/mechanical/core/embedding/ui.py +++ b/src/ansys/mechanical/core/embedding/ui.py @@ -59,7 +59,7 @@ def save_temp_copy( A Mechanical embedding application. """ # Identify the mechdb of the saved session from save_original() - project_directory = Path(app.DataModel.Project.ProjectDirectory) + project_directory = Path(app.project_directory) project_directory_parent = project_directory.parent mechdb_file = ( project_directory_parent / f"{project_directory.parts[-1].split('_')[0]}.mechdb" diff --git a/tests/conftest.py b/tests/conftest.py index be8cafc65..cd4565b9a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -181,10 +181,15 @@ def mke_app_reset(request): @pytest.fixture() -def run_subprocess(): +def run_subprocess(pytestconfig): + version = pytestconfig.getoption("ansys_version") + def func(args, env=None, check: bool = None): if check is None: check = True + if os.name != "nt": + if int(version) < 251: + check = False process, output = ansys.mechanical.core.run._run( args, env, check, _PRINT_SUBPROCESS_OUTPUT_TO_CONSOLE ) diff --git a/tests/embedding/test_app.py b/tests/embedding/test_app.py index 60ea66c2e..4d4f01a90 100644 --- a/tests/embedding/test_app.py +++ b/tests/embedding/test_app.py @@ -67,6 +67,10 @@ def test_app_save_open(embedded_app, tmp_path: pytest.TempPathFactory): embedded_app.DataModel.Project.Name = "PROJECT 1" project_file = os.path.join(tmp_path, f"{NamedTemporaryFile().name}.mechdat") embedded_app.save_as(project_file) + + project_file_directory = os.path.splitext(project_file)[0] + "_Mech_Files" + assert project_file_directory == os.path.normpath(embedded_app.project_directory) + with pytest.raises(Exception): embedded_app.save_as(project_file) embedded_app.save_as(project_file, overwrite=True) @@ -293,7 +297,7 @@ def test_rm_lockfile(embedded_app, tmp_path: pytest.TempPathFactory): embedded_app.save(mechdat_path) embedded_app.close() - lockfile_path = os.path.join(embedded_app.DataModel.Project.ProjectDirectory, ".mech_lock") + lockfile_path = os.path.join(embedded_app.project_directory, ".mech_lock") # Assert lock file path does not exist assert not os.path.exists(lockfile_path) @@ -446,7 +450,7 @@ def test_app_lock_file_open(embedded_app, tmp_path: pytest.TempPathFactory): embedded_app.save_as(project_file) embedded_app.save_as(project_file, overwrite=True) - lock_file = Path(embedded_app.DataModel.Project.ProjectDirectory) / ".mech_lock" + lock_file = Path(embedded_app.project_directory) / ".mech_lock" # Assert the lock file exists after saving it assert lock_file.exists()