- 
                Notifications
    You must be signed in to change notification settings 
- Fork 23
Feat: tox implementation #1989
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
          
     Merged
      
      
    
  
     Merged
                    Feat: tox implementation #1989
Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c3a2914
              
                feat: first commit
              
              
                moe-ad 5eb81dc
              
                feat: more modification
              
              
                moe-ad 78fb2cd
              
                feat: added more config
              
              
                moe-ad ca39597
              
                feat: fixed some mistakes
              
              
                moe-ad 71568c5
              
                feat: overhauled initial configuration
              
              
                moe-ad 08579b4
              
                Merge branch 'master' into feat/tox-implementation
              
              
                moe-ad 44a48dd
              
                feat: cross-platform detection logic
              
              
                moe-ad cf74a02
              
                feat: removed allowlist_externals
              
              
                moe-ad File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # This is work in progress, testing workflow in local/CI is gradually being transferred to tox | ||
|  | ||
| # Usage instructions: | ||
| # `tox` will run all tests sequentially, `tox --parallel` will run all tests in parallel (much faster). | ||
| # Run specific selection of tests with `tox -e pretest,<list-of-tests>,posttest` e.g., `tox -e pretest,test-api,test-launcher,posttest` | ||
| # `--parallel` flag can be passed when running specific selections | ||
|  | ||
| [tox] | ||
| description = Default tox environment list and core configurations | ||
|  | ||
| # List all tests to run in parallel or sequential mode here | ||
| # So invocation can be specified as `tox`/`tox --parallel` to run all tests in sequential/parallel mode | ||
| envlist = pretest,test-{api,launcher,server,local_server,multi_server,remote_workflow,remote_operator,workflow,service,operators},posttest | ||
|  | ||
| isolated_build_env = build | ||
|  | ||
| [testenv] | ||
| description = Default configuration for test environments, unless overridden | ||
|  | ||
| pass_env = | ||
| PACKAGE_NAME | ||
| MODULE | ||
| ANSYS_DPF_ACCEPT_LA | ||
| ANSYSLMD_LICENSE_FILE | ||
| AWP_ROOT242 | ||
|  | ||
| package = external # To allow custom wheel builds | ||
|  | ||
| [testenv:build_external] | ||
| description = Environment for custom build of package wheels, solves PyDPF custom wheel building requirement | ||
|  | ||
| allowlist_externals = | ||
| bash | ||
|  | ||
| package_glob = {toxinidir}{/}dist{/}ansys_dpf_core* | ||
|  | ||
| # {on_platform} substitution to automatically detect os type. | ||
| commands = | ||
| python .ci/build_wheel.py -p {on_platform} -w | ||
|  | ||
| [testenv:pretest] | ||
| description = Environment to kill servers and organize test files prior to testing | ||
|  | ||
| deps = | ||
| psutil | ||
|  | ||
| skip_install = True | ||
|  | ||
| commands = | ||
| # Clear any running servers that may be locking resources | ||
| python -c "import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \ | ||
| print(f'Killed \{nb_procs} \{proc_name} processes.')" | ||
|  | ||
| # Organize test files | ||
| python -c "\ | ||
| import os, shutil; \ | ||
| test_data=['test_launcher','test_server','test_local_server','test_multi_server','test_workflow','test_remote_workflow','test_remote_operator','test_service','test_custom_type_field']; \ | ||
| [(os.makedirs(d, exist_ok=True), shutil.copy('tests/conftest.py', d), shutil.copy(f'tests/\{d}.py', d) if os.path.exists(f'tests/\{d}.py') else None) for d in test_data]; \ | ||
| [os.remove(f'tests/\{d}.py') for d in test_data if os.path.exists(f'tests/\{d}.py')]" | ||
|  | ||
| [testenv:posttest] | ||
| description = Environment to kill servers and revert test files to original state after testing | ||
|  | ||
| depends = pretest, test-{api,launcher,server,local_server,multi_server,remote_workflow,remote_operator,workflow,service,operators} | ||
|  | ||
| deps = | ||
| psutil | ||
|  | ||
| skip_install = True | ||
|  | ||
| commands = | ||
| # Revert project layout to previous state | ||
| python -c "\ | ||
| import os, shutil; \ | ||
| test_data=['test_launcher','test_server','test_local_server','test_multi_server','test_workflow','test_remote_workflow','test_remote_operator','test_service', 'test_custom_type_field']; \ | ||
| [shutil.move(f'\{d}/\{d}.py', f'tests/\{d}.py') for d in test_data if os.path.exists(f'\{d}/\{d}.py')]; \ | ||
| [shutil.rmtree(d) for d in test_data if os.path.exists(d)]" | ||
|  | ||
| # Clear any running servers that may be locking resources | ||
| python -c "import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \ | ||
| print(f'Killed \{nb_procs} \{proc_name} processes.')" | ||
|  | ||
| [testenv:test-{api,launcher,server,local_server,multi_server,remote_workflow,remote_operator,workflow,service,operators}] | ||
| description = Environment where project testing configuration is defined | ||
|  | ||
| depends = pretest | ||
|  | ||
| setenv = | ||
| # Pytest extra arguments | ||
| COVERAGE = --cov=ansys.dpf.core --cov-report=xml --cov-report=html --log-level=ERROR --cov-append | ||
| RERUNS = --reruns=2 --reruns-delay=1 | ||
| DEBUG = -v -s --durations=10 --durations-min=1.0 | ||
|  | ||
| api: JUNITXML = --junitxml=tests/junit/test-results.xml | ||
| launcher: JUNITXML = --junitxml=tests/junit/test-results2.xml | ||
| server: JUNITXML = --junitxml=tests/junit/test-results3.xml | ||
| local_server: JUNITXML = --junitxml=tests/junit/test-results4.xml | ||
| multi_server: JUNITXML = --junitxml=tests/junit/test-results5.xml | ||
| remote_workflow: JUNITXML = --junitxml=tests/junit/test-results6.xml | ||
| remote_operator: JUNITXML = --junitxml=tests/junit/test-results7.xml | ||
| workflow: JUNITXML = --junitxml=tests/junit/test-results8.xml | ||
| service: JUNITXML = --junitxml=tests/junit/test-results9.xml | ||
| operators: JUNITXML = --junitxml=../tests/junit/test-results12.xml | ||
|  | ||
| # Tests sets | ||
| api: PYTEST_PYTHON_FILES = tests | ||
| launcher: PYTEST_PYTHON_FILES = test_launcher | ||
| server: PYTEST_PYTHON_FILES = test_server | ||
| local_server: PYTEST_PYTHON_FILES = test_local_server | ||
| multi_server: PYTEST_PYTHON_FILES = test_multi_server | ||
| remote_workflow: PYTEST_PYTHON_FILES = test_remote_workflow | ||
| remote_operator: PYTEST_PYTHON_FILES = test_remote_operator | ||
| workflow: PYTEST_PYTHON_FILES = test_workflow | ||
| service: PYTEST_PYTHON_FILES = test_service | ||
| operators: PYTEST_PYTHON_FILES = tests/operators | ||
|  | ||
| deps = | ||
| -r requirements/requirements_test.txt | ||
|  | ||
| commands = | ||
| pytest {env:PYTEST_PYTHON_FILES} {env:DEBUG} {env:COVERAGE} {env:RERUNS} {env:JUNITXML} | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is no longer required if we are calling a Python script in the
commandssection, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. Thanks for catching that.