Test Actions#

Test actions set up Python environments for SCADE and run the test suite for a SCADE Python library.

Create a SCADE Python virtual environment#

The create-scade-venv action creates a virtual Python environment in the target directory from a Python installation.

Source code for this action

Input

Description

Required

Default

python-dir

Directory containing a Python installation

True

target-dir

Target directory for the virtual environment

False

.

target-name

Target name of the virtual environment

False

.venv

Output

Description

scripts-dir

Directory containing the python.exe file

Examples#

Create Python virtual environment basic example
create-scade-venv:
  name: "Create Python virtual environment basic example"
  runs-on: [self-hosted, 'SCADE']
  steps:
    - name: "Create Python virtual environment"
      uses: ansys/scade-actions/create-scade-venv@v2.0
      with:
        python-dir: 'C:\Program Files\Ansys Inc\v232\SCADE\contrib\Python310'
        target-dir: '.venvs'
        target-name: 'Python310'

Run the test suite for a given Python interpreter#

The tests-pytest action runs the test suite for a Python library and a given Python interpreter using pytest. This action accepts markers, options, and post arguments to pass to pytest before executing the test session.

Source code for this action

Input

Description

Required

Default

python-dir

Directory of the Python interpreter.

True

library-dir

Directory of the library to test.

False

.

pytest-markers

Set of pytest markers in the form of a string. These markers are used to discretize tests when running the test session.

False

pytest-extra-args

Set of additional pytest arguments in the form of a string.

False

pytest-postargs

Directory of the test suite and the level of verbosity.

False

tests -vv

checkout

Whether to clone the repository in the CI/CD machine.

False

true

Example#

Run tests basic example
tests:
  name: "Run tests basic example"
  runs-on: [self-hosted, 'SCADE']
  steps:
    - name: "Run the tests"
      uses: ansys/scade-actions/tests-pytest@v2.0
      with:
        python-dir: '.venvs\Python310\Scripts'
        pytest-extra-args: "--cov=ansys --cov-report=term --cov-branch --cov-report=html:.cov/html"
        checkout: false

Run the test suite for a given SCADE version#

The scade-tests-pytest action runs the test suite for a Python library and a given version of Ansys SCADE using pytest. This action accepts markers, options, and post arguments to pass to pytest before executing the test session.

Source code for this action

Input

Description

Required

Default

scade-version

SCADE version used for installing and running pytest. For example, use '24.1' for Ansys SCADE 2024 R1.

True

library-dir

Directory of the library to test.

False

.

pytest-markers

Set of pytest markers in the form of a string. These markers are used to discretize tests when running the test session.

False

pytest-extra-args

Set of additional pytest arguments in the form of a string.

False

pytest-postargs

Directory of the test suite and the level of verbosity.

False

tests -vv

checkout

Whether to clone the repository on the CI/CD machine.

False

true

Example#

Run tests basic example
tests:
  name: "Run tests basic example"
  runs-on: [self-hosted, 'SCADE']
  steps:
    - name: "Run the tests for a given version of Ansys SCADE"
      uses: ansys/scade-actions/scade-tests-pytest@v2.0
      with:
        scade-version: '23.2'
        pytest-extra-args: "--cov=ansys --cov-report=term --cov-branch --cov-report=html:.cov/html"
        checkout: false