Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add embedding_scripts marker #662

Merged
merged 47 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2e740ec
add embedding_scripts marker
klmcadams Mar 26, 2024
431c1fd
update changelog
klmcadams Mar 26, 2024
48cae8c
Merge branch 'main' into feat/extra-marker
dipinknair Mar 27, 2024
553dff5
Merge branch 'main' into feat/extra-marker
klmcadams Mar 27, 2024
8fe2ed7
Adding changelog entry: 662.added.md
pyansys-ci-bot Mar 27, 2024
883361e
comment out warning_msg test
klmcadams Mar 27, 2024
a5e67b7
change pythonnet test to embedding mark
klmcadams Mar 27, 2024
db62c46
remove env activate from embedding scripts step
klmcadams Mar 27, 2024
349ae3f
Merge branch 'main' into feat/extra-marker
klmcadams Mar 27, 2024
594157f
add comments
klmcadams Mar 27, 2024
06f0bf7
Merge branch 'feat/extra-marker' of https://github.com/ansys/pymechan…
klmcadams Mar 27, 2024
5044216
change subprocess in warning message
klmcadams Mar 27, 2024
12e4b66
check embedded_py path
klmcadams Mar 27, 2024
ad4ceca
add embedding_scripts to conftest
klmcadams Mar 27, 2024
8fce8db
Merge branch 'main' into feat/extra-marker
klmcadams Mar 28, 2024
1f05afe
enable debug logging
klmcadams Mar 28, 2024
47aa029
Merge branch 'feat/extra-marker' of https://github.com/ansys/pymechan…
klmcadams Mar 28, 2024
04ce1d5
switch back to subprocess Popen for warning message
klmcadams Mar 28, 2024
16ca8d6
add print statements
klmcadams Mar 28, 2024
6075162
remove activating the env
klmcadams Mar 28, 2024
d508f34
install test dependencies
klmcadams Mar 28, 2024
97f12d7
Merge branch 'main' into feat/extra-marker
dipinknair Apr 1, 2024
c196095
Merge branch 'main' into feat/extra-marker
dipinknair Apr 1, 2024
a7d0ab5
see if subprocess works
klmcadams Apr 3, 2024
1457c69
fix workflow file
klmcadams Apr 3, 2024
2aa9641
enable display in _run
klmcadams Apr 3, 2024
24b1d9a
add apt-get update
klmcadams Apr 3, 2024
b24111a
add sudo
klmcadams Apr 3, 2024
d130e70
try to remove lock
klmcadams Apr 3, 2024
e7e9a87
remove line
klmcadams Apr 3, 2024
6ac34ab
remove sudo
klmcadams Apr 3, 2024
7e1ce8f
add sudo
klmcadams Apr 3, 2024
da0d07e
add code style section
klmcadams Apr 3, 2024
4816885
use setup python action
klmcadams Apr 3, 2024
5a9b725
use previous installs
klmcadams Apr 3, 2024
172ed3b
remove sudo
klmcadams Apr 3, 2024
2178402
Merge branch 'main' into feat/extra-marker
klmcadams Apr 11, 2024
88bb9d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 11, 2024
98878c7
uncomment everything
klmcadams Apr 11, 2024
e5f4777
remove print statements and logging
klmcadams Apr 11, 2024
15b0bfd
separate embedding-scripts tests
klmcadams Apr 11, 2024
194eecf
add embedding-scripts-tests references
klmcadams Apr 11, 2024
954638a
Merge branch 'main' into feat/extra-marker
klmcadams Apr 11, 2024
938a290
change style to smoke-tests
klmcadams Apr 11, 2024
9e95933
Merge branch 'feat/extra-marker' of https://github.com/ansys/pymechan…
klmcadams Apr 11, 2024
82d21a7
Merge branch 'main' into feat/extra-marker
klmcadams Apr 11, 2024
37c78c7
remove xvfb-run from embedding-scripts
klmcadams Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 82 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
name: Embedding testing and coverage
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [style, revn-variations]
needs: [smoke-tests, revn-variations]
container:
image: ${{ needs.revn-variations.outputs.test_container }}
options: --entrypoint /bin/bash
Expand Down Expand Up @@ -278,6 +278,80 @@ jobs:
include_passed: true
fail_on_failure: true

embedding-scripts-tests:
name: Embedding scripts testing and coverage
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [smoke-tests, revn-variations]
container:
image: ${{ needs.revn-variations.outputs.test_container }}
options: --entrypoint /bin/bash
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up python and pip
run: |
apt update
apt install --reinstall ca-certificates
apt install lsb-release xvfb software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa -y
apt install -y python${{ matrix.python-version }} python${{ matrix.python-version }}-venv
python${{ matrix.python-version }} -m venv /env

- name: Install dependencies
run: |
. /env/bin/activate
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools
pip install --upgrade pip flit

- name: Install packages for testing
run: |
. /env/bin/activate
pip install -e .[tests]

- name: Embedding scripts unit testing and coverage
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
NUM_CORES: 1
PYTHONUNBUFFERED: 1
run: |
. /env/bin/activate
mechanical-env pytest -m embedding_scripts -s --junitxml test_results_embedding_scripts${{ matrix.python-version }}.xml

- name: Upload coverage results
uses: actions/upload-artifact@v4
if: env.MAIN_PYTHON_VERSION == matrix.python-version
with:
name: coverage-tests-embedding-scripts
path: .cov
retention-days: 7

- name: Upload coverage results (as .coverage)
uses: actions/upload-artifact@v4
if: env.MAIN_PYTHON_VERSION == matrix.python-version
with:
name: coverage-file-tests-embedding-scripts
path: .coverage
retention-days: 7

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: '**/test_results*.xml'
check_name: Test Report ${{ matrix.python-version }}
detailed_summary: true
include_passed: true
fail_on_failure: true

launch-tests:
name: Launch testing and coverage
runs-on: public-ubuntu-latest-8-cores
Expand Down Expand Up @@ -455,7 +529,7 @@ jobs:

coverage:
name: Merging coverage
needs: [remote-connect, embedding-tests, launch-tests]
needs: [remote-connect, embedding-tests, embedding-scripts-tests, launch-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -480,6 +554,11 @@ jobs:
name: coverage-file-tests-embedding
path: cov-dir/embedding

- uses: actions/download-artifact@v4
with:
name: coverage-file-tests-embedding-scripts
path: cov-dir/embedding-scripts

- uses: actions/download-artifact@v4
with:
name: coverage-file-tests-remote-session-launch
Expand Down Expand Up @@ -539,7 +618,7 @@ jobs:

package:
name: Package library
needs: [smoke-tests, remote-connect, embedding-tests, doc-build]
needs: [smoke-tests, remote-connect, embedding-tests, embedding-scripts-tests, doc-build]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/662.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add embedding_scripts marker
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ testpaths = [
]
markers = [
"embedding: tests that embed Mechanical in the python process",
"embedding_scripts: embedding tests that use subprocess",
"python_env: tests that check for an appropriate python environment",
"remote_session_launch: tests that launch Mechanical and work with gRPC server inside it",
"remote_session_connect: tests that connect to Mechanical and work with gRPC server inside it",
Expand Down
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ def pytest_collection_modifyitems(config, items):

# skip embedding tests unless the mark is specified
skip_embedding = pytest.mark.skip(
reason="embedding not selected for pytest run (`pytest -m embedding`). Skip by default"
reason="""embedding not selected for pytest run
(`pytest -m embedding` or `pytest -m embedding_scripts`). Skip by default"""
)
[item.add_marker(skip_embedding) for item in items if "embedding" in item.keywords]
[
item.add_marker(skip_embedding)
for item in items
if ("embedding" or "embedding_scripts") in item.keywords
]

# TODO - skip python_env tests unless the mark is specified. (The below doesn't work!)
# skip_python_env = pytest.mark.skip(
Expand Down
6 changes: 3 additions & 3 deletions tests/embedding/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_app_getters_notstale(embedded_app):
assert model.Name != "b"


@pytest.mark.embedding
@pytest.mark.embedding_scripts
@pytest.mark.python_env
def test_warning_message(test_env, pytestconfig, run_subprocess, rootdir):
"""Test Python.NET warning of the embedded instance using a test-scoped Python environment."""
Expand Down Expand Up @@ -190,7 +190,7 @@ def test_warning_message(test_env, pytestconfig, run_subprocess, rootdir):
assert warning, "UserWarning should appear in the output of the script"


@pytest.mark.embedding
@pytest.mark.embedding_scripts
@pytest.mark.python_env
def test_private_appdata(pytestconfig, run_subprocess, rootdir):
"""Test embedded instance does not save ShowTriad using a test-scoped Python environment."""
Expand All @@ -204,7 +204,7 @@ def test_private_appdata(pytestconfig, run_subprocess, rootdir):
assert "ShowTriad value is True" in stdout


@pytest.mark.embedding
@pytest.mark.embedding_scripts
@pytest.mark.python_env
def test_normal_appdata(pytestconfig, run_subprocess, rootdir):
"""Test embedded instance saves ShowTriad value using a test-scoped Python environment."""
Expand Down
10 changes: 5 additions & 5 deletions tests/embedding/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _run_embedding_log_test(
return stderr


@pytest.mark.embedding
@pytest.mark.embedding_scripts
def test_logging_write_log_before_init(rootdir, run_subprocess, pytestconfig):
"""Test that an error is thrown when trying to log before initializing"""
stderr = _run_embedding_log_test(
Expand All @@ -107,7 +107,7 @@ def test_logging_write_log_before_init(rootdir, run_subprocess, pytestconfig):
assert "Can't log to the embedding logger until Mechanical is initialized" in stderr


@pytest.mark.embedding
@pytest.mark.embedding_scripts
def test_logging_write_info_after_initialize_with_error_level(
rootdir, run_subprocess, pytestconfig
):
Expand All @@ -119,7 +119,7 @@ def test_logging_write_info_after_initialize_with_error_level(


@pytest.mark.parametrize("addin_configuration", ["Mechanical", "WorkBench"])
@pytest.mark.embedding
@pytest.mark.embedding_scripts
@pytest.mark.minimum_version(241)
def test_addin_configuration(rootdir, run_subprocess, pytestconfig, addin_configuration):
"""Test that mechanical can start with both the Mechanical and WorkBench configuration."""
Expand All @@ -129,7 +129,7 @@ def test_addin_configuration(rootdir, run_subprocess, pytestconfig, addin_config
assert f"{addin_configuration} configuration!" in stderr


@pytest.mark.embedding
@pytest.mark.embedding_scripts
def test_logging_write_error_after_initialize_with_info_level(
rootdir, run_subprocess, pytestconfig
):
Expand All @@ -140,7 +140,7 @@ def test_logging_write_error_after_initialize_with_info_level(
assert "Will no one rid me of this turbulent priest?" in stderr


@pytest.mark.embedding
@pytest.mark.embedding_scripts
def test_logging_level_before_and_after_initialization(rootdir, run_subprocess, pytestconfig):
"""Test logging level API before and after initialization."""
stdout, stderr = _run_embedding_log_test_process(
Expand Down
Loading