idf_ci package

Subpackages

Submodules

class idf_ci.scripts.ProcessedArgs(modified_files: List[str] | None, modified_components: List[str] | None, filter_expr: str | None, default_build_targets: List[str], test_related_apps: List[App] | None, non_test_related_apps: List[App] | None)

Bases: object

Container for processed arguments with meaningful field names.

default_build_targets: List[str]
filter_expr: str | None
modified_components: List[str] | None
modified_files: List[str] | None
idf_ci.scripts.build(*, paths: List[str] | None = None, target: str = 'all', parallel_count: int = 1, parallel_index: int = 1, modified_files: List[str] | None = None, modified_components: List[str] | None = None, only_test_related: bool | None = None, only_non_test_related: bool | None = None, dry_run: bool = False, build_system: UndefinedType | str = __UNDEF__, marker_expr: UndefinedType | str = __UNDEF__, filter_expr: str | None = None) Tuple[List[App], int]

Build applications based on specified parameters.

Parameters:
  • paths – List of paths to search for applications

  • target – Target device(s) separated by commas

  • parallel_count – Total number of parallel jobs

  • parallel_index – Index of current parallel job (1-based)

  • modified_files – List of modified files

  • modified_components – List of modified components

  • only_test_related – Only build test-related applications

  • only_non_test_related – Only build non-test-related applications

  • dry_run – Do not actually build, just simulate

  • build_system – Filter the apps by build system. Can be “cmake”, “make” or a custom App class path

  • marker_expr – Pytest marker expression

  • filter_expr – Filter expression

Returns:

Tuple of (built apps, build return code)

idf_ci.scripts.get_all_apps(*, paths: List[str] | None = None, target: str = 'all', modified_files: List[str] | None = None, modified_components: List[str] | None = None, filter_expr: str | None = None, default_build_targets: List[str] | None = None, marker_expr: UndefinedType | str | None = __UNDEF__, compare_manifest_sha_filepath: str | None = None, build_system: UndefinedType | str | None = __UNDEF__) Tuple[List[App], List[App]]

Get test-related and non-test-related applications.

Parameters:
  • paths – List of paths to search for applications

  • target – Target device(s) separated by commas

  • modified_files – List of modified files

  • modified_components – List of modified components

  • filter_expr – Pytest filter expression -k

  • default_build_targets – Default build targets to use

  • marker_expr – Pytest marker expression -m

  • compare_manifest_sha_filepath – Path to the manifest SHA file generated by idf-build-apps dump-manifest-sha

  • build_system – Filter the apps by build system. Can be “cmake”, “make” or a custom App class path

Returns:

Tuple of (test_related_apps, non_test_related_apps)

idf_ci.scripts.preprocess_args(modified_files: List[str] | None = None, modified_components: List[str] | None = None, filter_expr: str | None = None, default_build_targets: List[str] | None = None) ProcessedArgs

Set values according to the environment variables, .toml settings, and defaults.

Parameters:
  • modified_files – List of modified files

  • modified_components – List of modified components

  • filter_expr – Pytest filter expression

  • default_build_targets – Default build targets to use

Returns:

Processed arguments as a ProcessedArgs object

idf_ci.utils.get_current_branch() str

Get the current Git branch by running git command.

Returns:

The current Git ref (branch name or commit SHA)

Raises:

RuntimeError – If not in a Git repository or git command fails

idf_ci.utils.remove_subfolders(paths: List[str]) List[Path]

Remove paths that are subfolders of other paths in the list.

Parameters:

paths – List of directory paths as strings

Returns:

Filtered list of paths with no subfolder/parent folder relationships, absolute and sorted

idf_ci.utils.setup_logging(level: int | None = 20) None

Setup logging

Parameters:

level – logging level

idf_ci.utils.to_list(s: None) None
idf_ci.utils.to_list(s: Iterable[_T]) List[_T]
idf_ci.utils.to_list(s: _T) List[_T]

Turn all objects to lists

Parameters:

s – anything

Returns:

  • None, if s is None

  • itself, if s is a list

  • list(s), if s is a tuple or a set

  • [s], if s is other type

Module contents

class idf_ci.CiSettings(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, *, component_mapping_regexes: List[str] = ['/components/(.+?)/', '/common_components/(.+?)/'], extend_component_mapping_regexes: List[str] = [], component_mapping_exclude_regexes: List[str] = ['/test_apps/'], component_ignored_file_extensions: List[str] = ['.md', '.rst', '.yaml', '.yml', '.py'], extend_component_ignored_file_extensions: List[str] = [], built_app_list_filepatterns: List[str] = ['app_info_*.txt'], collected_test_related_apps_filepath: str = 'test_related_apps.txt', collected_non_test_related_apps_filepath: str = 'non_test_related_apps.txt', preserve_test_related_apps: bool = True, preserve_non_test_related_apps: bool = True, extra_default_build_targets: List[str] = [], exclude_dirs: List[str] = [], ci_detection_envs: List[str] = ['CI', 'GITHUB_ACTIONS', 'CIRCLECI', 'TRAVIS', 'JENKINS_URL', 'DRONE', 'APPVEYOR', 'BITBUCKET_COMMIT', 'SEMAPHORE', 'TEAMCITY_VERSION'], local_runtime_envs: Dict[str, Any] = {}, ci_runtime_envs: Dict[str, Any] = {}, gitlab: GitlabSettings = GitlabSettings(project='espressif/esp-idf', known_failure_cases_bucket_name='ignore-test-result-files', artifacts=ArtifactSettings(s3=ArtifactSettingsS3(enable=False, configs={'debug': S3ArtifactConfig(bucket='idf-artifacts', is_public=False, zip_first=True, base_dir_pattern='**/build*/', file_patterns=['bootloader/*.map', 'bootloader/*.elf', '*.map', '*.elf', 'build.log'], if_clause=None), 'flash': S3ArtifactConfig(bucket='idf-artifacts', is_public=False, zip_first=True, base_dir_pattern='**/build*/', file_patterns=['bootloader/*.bin', '*.bin', 'partition_table/*.bin', 'flasher_args.json', 'flash_project_args', 'config/sdkconfig.json', 'sdkconfig', 'project_description.json'], if_clause=None)}), native=ArtifactSettingsNative(enable=True, build_job_filepatterns=['**/build*/bootloader/*.map', '**/build*/bootloader/*.elf', '**/build*/*.map', '**/build*/*.elf', '**/build*/bootloader/*.bin', '**/build*/*.bin', '**/build*/partition_table/*.bin', '**/build*/flasher_args.json', '**/build*/flash_project_args', '**/build*/config/sdkconfig.json', '**/build*/sdkconfig', '**/build*/project_description.json', '**/build*/build.log', 'app_info_*.txt', 'build_summary_*.xml'], test_job_filepatterns=['pytest-embedded/', 'XUNIT_RESULT*.xml'])), build_pipeline=BuildPipelineSettings(workflow_name='Build Child Pipeline', presigned_json_job_name='generate_presigned_json', job_template_name='.default_build_settings', job_image='espressif/idf:latest', job_stage='build', job_template_jinja='{{ settings.gitlab.build_pipeline.job_template_name }}:\n  stage: "{{ settings.gitlab.build_pipeline.job_stage }}"\n  tags: {{ settings.gitlab.build_pipeline.job_tags }}\n  image: "{{ settings.gitlab.build_pipeline.job_image }}"\n  timeout: "1h"\n  artifacts:\n    paths:\n    {%- for path in settings.gitlab.artifacts.native.build_job_filepatterns %}\n      - "{{ path }}"\n    {%- endfor %}\n    expire_in: "1 week"\n    when: "always"\n  before_script:\n    - pip install -U idf-ci\n  script:\n    - idf-ci build run\n      --parallel-count ${CI_NODE_TOTAL:-1}\n      --parallel-index ${CI_NODE_INDEX:-1}', job_tags=['build'], runs_per_job=60, parent_pipeline_job_suffix='', jobs_jinja='{%- if test_related_apps_count > 0 %}\nbuild_test_related_apps:\n  extends: "{{ settings.gitlab.build_pipeline.job_template_name }}"\n{%- if test_related_parallel_count > 1 %}\n  parallel: {{ test_related_parallel_count }}\n{%- endif %}\n  needs:\n    - pipeline: "$PARENT_PIPELINE_ID"\n      job: "generate_build_child_pipeline{{ settings.gitlab.build_pipeline.parent_pipeline_job_suffix }}"\n    - pipeline: "$PARENT_PIPELINE_ID"\n      job: "pipeline_variables{{ settings.gitlab.build_pipeline.parent_pipeline_job_suffix }}"\n  variables:\n    IDF_CI_BUILD_ONLY_TEST_RELATED_APPS: "1"\n\n{% endif %}\n{%- if non_test_related_apps_count > 0 %}\nbuild_non_test_related_apps:\n  extends: "{{ settings.gitlab.build_pipeline.job_template_name }}"\n{%- if non_test_related_parallel_count > 1 %}\n  parallel: {{ non_test_related_parallel_count }}\n{%- endif %}\n  needs:\n    - pipeline: "$PARENT_PIPELINE_ID"\n      job: "generate_build_child_pipeline{{ settings.gitlab.build_pipeline.parent_pipeline_job_suffix }}"\n    - pipeline: "$PARENT_PIPELINE_ID"\n      job: "pipeline_variables{{ settings.gitlab.build_pipeline.parent_pipeline_job_suffix }}"\n  variables:\n    IDF_CI_BUILD_ONLY_NON_TEST_RELATED_APPS: "1"\n\n{% endif %}', pre_yaml_jinja='', yaml_jinja='{{ settings.gitlab.build_pipeline.pre_yaml_jinja }}\n\nworkflow:\n  name: "{{ settings.gitlab.build_pipeline.workflow_name }}"\n  rules:\n    - when: "always"\n\n{% if settings.gitlab.build_pipeline.job_template_jinja %}\n{{ job_template }}\n{%- endif %}\n\n{{ jobs }}\n\n{%- if test_related_apps_count > 0 %}\ngenerate_test_child_pipeline:\n  extends: "{{ settings.gitlab.build_pipeline.job_template_name }}"\n  needs:\n    - "build_test_related_apps"\n  artifacts:\n    paths:\n      - "{{ settings.gitlab.test_pipeline.yaml_filename }}"\n  script:\n    - idf-ci\n      --config \'gitlab.test_pipeline.job_image="{{ settings.gitlab.test_pipeline.job_image }}"\'\n      gitlab test-child-pipeline\n\ntest-child-pipeline:\n  stage: ".post"\n  needs:\n    - "generate_test_child_pipeline"\n  variables:\n    PARENT_PIPELINE_ID: "$CI_PIPELINE_ID"\n  trigger:\n    include:\n      - artifact: "{{ settings.gitlab.test_pipeline.yaml_filename }}"\n        job: "generate_test_child_pipeline"\n    strategy: "depend"\n{%- endif %}', yaml_filename='build_child_pipeline.yml'), test_pipeline=TestPipelineSettings(workflow_name='Test Child Pipeline', presigned_json_job_name='generate_presigned_json', job_template_name='.default_test_settings', job_image='python:3-slim', job_stage='test', job_template_jinja='{{ settings.gitlab.test_pipeline.job_template_name }}:\n  stage: "{{ settings.gitlab.test_pipeline.job_stage }}"\n  image: "{{ settings.gitlab.test_pipeline.job_image }}"\n  timeout: "1h"\n  artifacts:\n    paths:\n    {%- for path in settings.gitlab.artifacts.native.test_job_filepatterns %}\n      - "{{ path }}"\n    {%- endfor %}\n    expire_in: "1 week"\n    when: "always"\n  variables:\n    PYTEST_EXTRA_FLAGS: ""\n  needs:\n    - pipeline: "$PARENT_PIPELINE_ID"\n      job: "build_test_related_apps"\n  before_script:\n    - pip install -U idf-ci\n  script:\n    - eval pytest $nodes\n      --parallel-count ${CI_NODE_TOTAL:-1}\n      --parallel-index ${CI_NODE_INDEX:-1}\n      --junitxml "XUNIT_RESULT_${CI_JOB_NAME_SLUG}.xml"\n      ${PYTEST_EXTRA_FLAGS}', job_tags=[], runs_per_job=30, parent_pipeline_job_suffix='', jobs_jinja='{% for job in jobs %}\n{{ job[\'name\'] }}:\n  extends:\n    - "{{ settings.gitlab.test_pipeline.job_template_name }}"\n    {%- for extra_extend in job.get(\'extra_extends\', []) %}\n    - "{{ extra_extend }}"\n    {%- endfor %}\n  tags: {{ job[\'tags\'] }}\n{%- if job[\'parallel_count\'] > 1 %}\n  parallel: {{ job[\'parallel_count\'] }}\n{%- endif %}\n  variables:\n    nodes: {{ job[\'nodes\'] }}\n{% endfor %}', pre_yaml_jinja='', yaml_jinja='{{ settings.gitlab.test_pipeline.pre_yaml_jinja }}\n\nworkflow:\n  name: "{{ settings.gitlab.test_pipeline.workflow_name }}"\n  rules:\n    - when: "always"\n\n{% if settings.gitlab.test_pipeline.job_template_jinja %}\n{{ default_template }}\n{%- endif %}\n\n{{ jobs }}', yaml_filename='test_child_pipeline.yml')))

Bases: BaseSettings

CLI_OVERRIDES: ClassVar[Dict[str, Any]] = {}

Inline CLI overrides (class variable).

CONFIG_FILE_PATH: ClassVar[Path | None] = None

Path to the configuration file to be used (class variable).

property all_component_mapping_exclude_regexes: Set[Pattern]

Get all component mapping exclude regexes as compiled pattern objects.

Returns:

Set of compiled regex patterns

property all_component_mapping_regexes: Set[Pattern]

Get all component mapping regexes as compiled pattern objects.

Returns:

Set of compiled regex patterns

built_app_list_filepatterns: List[str]

Glob patterns for files containing built app information.

ci_detection_envs: List[str]

Environment variables used to detect if running in CI.

ci_runtime_envs: Dict[str, Any]

Environment variables to set in CI environment.

Path to file containing non-test-related apps.

Path to file containing test-related apps.

component_ignored_file_extensions: List[str]

File extensions to ignore when mapping files to components.

component_mapping_exclude_regexes: List[str]

List of regex patterns to exclude certain paths from component mapping.

component_mapping_regexes: List[str]

List of regex patterns to extract component names from file paths.

exclude_dirs: List[str]

Directories to ignore when searching for apps.

extend_component_ignored_file_extensions: List[str]

Additional file extensions to ignore.

extend_component_mapping_regexes: List[str]

Additional component mapping regex patterns to extend the default list.

extra_default_build_targets: List[str]

Additional build targets to include by default.

get_built_apps_list() List[App] | None

Get the list of successfully built applications from the app info files.

Returns:

List of App objects representing successfully built applications, or None if no files found

get_modified_components(modified_files: Iterable[str]) Set[str]

Get the set of components that have been modified based on the provided files.

Parameters:

modified_files – Iterable of file paths that have been modified

Returns:

Set of component names that have been modified

gitlab: GitlabSettings

GitLab-specific settings.

property is_in_ci: bool

Check if the code is running in a CI environment.

Returns:

True if in CI environment, False otherwise

local_runtime_envs: Dict[str, Any]

Environment variables to set in local development.

model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'use_attribute_docstrings': True, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(_CiSettings__context: Any) None

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Whether to preserve non-test-related apps.

Whether to preserve test-related apps.

classmethod read_apps_from_filepatterns(patterns: List[str]) List[App] | None

Helper method to read apps from files matching given patterns.

Parameters:

patterns – List of file patterns to search for

Returns:

List of App objects read from the files, or None if no files found

classmethod read_apps_from_files(filepaths: Sequence[str | PathLike]) List[App] | None

Helper method to read apps from files.

Parameters:

filepaths – List of file paths to read

Returns:

List of App objects read from the files, or None if no files found

classmethod settings_customise_sources(settings_cls: Type[BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) Tuple[PydanticBaseSettingsSource, ...]

Define the sources and their order for loading the settings values.

Args:

settings_cls: The Settings class. init_settings: The InitSettingsSource instance. env_settings: The EnvSettingsSource instance. dotenv_settings: The DotEnvSettingsSource instance. file_secret_settings: The SecretsSettingsSource instance.

Returns:

A tuple containing the sources and their order for loading the settings values.

class idf_ci.GitlabEnvVars(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, *, CHANGED_FILES_SEMICOLON_SEPARATED: str | None = None, GITLAB_HTTPS_SERVER: str = 'https://gitlab.com', GITLAB_ACCESS_TOKEN: str | None = None, IDF_S3_SERVER: str | None = None, IDF_S3_ACCESS_KEY: str | None = None, IDF_S3_SECRET_KEY: str | None = None, IDF_S3_TIMEOUT_TOTAL: float = 300.0, IDF_PATH: str = '', IDF_CI_IS_DEBUG_PIPELINE: bool | None = None, IDF_CI_SELECT_BY_FILTER_EXPR: str | None = None, IDF_CI_SELECT_ALL_PYTEST_CASES: bool | None = None, IDF_CI_SELECT_BY_TARGETS: str | None = None, IDF_CI_BUILD_ONLY_TEST_RELATED_APPS: bool | None = None, IDF_CI_BUILD_ONLY_NON_TEST_RELATED_APPS: bool | None = None)

Bases: BaseSettings

CHANGED_FILES_SEMICOLON_SEPARATED: str | None

Semicolon-separated list of changed files in the pipeline.

GITLAB_ACCESS_TOKEN: str | None

Access token for GitLab API authentication.

GITLAB_HTTPS_SERVER: str

GitLab server URL for API calls.

Flag indicating whether to build only non-test-related apps.

Flag indicating whether to build only test-related apps.

IDF_CI_IS_DEBUG_PIPELINE: bool | None

Flag indicating whether this is a debug pipeline.

IDF_CI_SELECT_ALL_PYTEST_CASES: bool | None

Flag indicating whether to select all pytest cases.

IDF_CI_SELECT_BY_FILTER_EXPR: str | None

Filter expression for selecting pytest cases.

IDF_CI_SELECT_BY_TARGETS: str | None

comma-separated list of targets to be built and tested.

IDF_PATH: str

Path to the ESP-IDF directory.

IDF_S3_ACCESS_KEY: str | None

S3 access key for authentication.

IDF_S3_SECRET_KEY: str | None

S3 secret key for authentication.

IDF_S3_SERVER: str | None

S3 server endpoint URL.

IDF_S3_TIMEOUT_TOTAL: float

S3 total request timeout in seconds.

model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(_GitlabEnvVars__context: Any) None

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

property select_all_pytest_cases: bool

Determine if all pytest cases should be selected.

Returns:

True if this is a full pipeline run, False otherwise

property select_by_filter_expr: str | None

Get the filter expression for pytest cases.

Returns:

The filter expression if set, None otherwise

property select_by_targets: List[str] | None

Get the list of targets to be built and tested.

Returns:

List of targets if set, None otherwise

class idf_ci.IdfPytestPlugin(*, cli_target: str, sdkconfig_name: str | None = None)

Bases: object

build_dir(request: FixtureRequest, app_path: str, target: str | None, config: str | None) str

Find a valid build directory based on priority rules.

Checks local build directories in the following order:

  1. build_<target>_<config>

  2. build_<target>

  3. build_<config>

  4. build

Parameters:
  • request – Pytest fixture request

  • app_path – Path to the application

  • target – Target being used

  • config – Configuration being used

Returns:

Valid build directory name

Raises:

ValueError – If no valid build directory is found

config(request: FixtureRequest) str

Fixture that provides the configuration for tests.

Parameters:

request – Pytest fixture request

Returns:

Configuration string, defaults to ‘default’ if not specified

static get_case_by_item(item: Item) PytestCase | None

Get the test case associated with a pytest item.

Parameters:

item – The pytest test item

Returns:

PytestCase object or None if not found

pytest_collection_modifyitems(config: Config, items: List[Function])

Filter test cases based on target, sdkconfig, and available apps.

Parameters:
  • config – Pytest configuration

  • items – Collected test items

pytest_pycollect_makemodule(module_path: Path)

Handle module collection for pytest, mocking any missing modules.

This hook runs before module collection to prevent errors from missing dependencies by automatically mocking them.

Parameters:

module_path – Path to the module being collected

pytest_report_collectionfinish(items: List[Function]) None
target(request: FixtureRequest) str

Fixture that provides the target for tests.

Parameters:

request – Pytest fixture request

Returns:

Target string

Raises:

ValueError – If target parameter is not defined

class idf_ci.PytestApp(path: str, target: str, config: str)

Bases: object

Represents a pytest app.

property build_dir: str

Returns the build directory for the app.

Note

Matches the build_dir (by default build_@t_@w) in the idf-build-apps config file.

Returns:

The build directory for the app.

class idf_ci.PytestCase(apps: List[PytestApp], item: Function)

Bases: object

Represents a pytest test case.

KNOWN_ENV_MARKERS: ClassVar[Set[str]] = {}
property all_markers: Set[str]
property caseid: str
property configs: List[str]
property env_markers: Set[str]
property env_selector: str
classmethod from_item(item: Function) PytestCase | None

Create a PytestCase from a pytest item.

Parameters:

item – Pytest function item

Returns:

PytestCase instance or None if targets not defined

classmethod get_param(item: Function, key: str, default: Any = None) Any

Get parameter value from pytest item.

Parameters:
  • item – Pytest function item

  • key – Parameter key to retrieve

  • default – Default value if key not found

Returns:

Parameter value or default

get_skip_reason_if_not_built(app_dirs: List[str] | None = None) str | None

Check if all binaries of the test case are built in the app lists.

Parameters:

app_dirs – App folder paths to check

Returns:

Skip reason string if not all binaries are built, None otherwise

property is_host_test: bool
property is_single_dut: bool
property name: str
property path: str
property runner_tags: Tuple[str, ...]
skipped_targets() Dict[str, str]

Get targets that are marked with skip markers for current test case.

Returns:

Dictionary of targets with skip reason

property target_selector: str
property targets: List[str]
idf_ci.build(*, paths: List[str] | None = None, target: str = 'all', parallel_count: int = 1, parallel_index: int = 1, modified_files: List[str] | None = None, modified_components: List[str] | None = None, only_test_related: bool | None = None, only_non_test_related: bool | None = None, dry_run: bool = False, build_system: UndefinedType | str = __UNDEF__, marker_expr: UndefinedType | str = __UNDEF__, filter_expr: str | None = None) Tuple[List[App], int]

Build applications based on specified parameters.

Parameters:
  • paths – List of paths to search for applications

  • target – Target device(s) separated by commas

  • parallel_count – Total number of parallel jobs

  • parallel_index – Index of current parallel job (1-based)

  • modified_files – List of modified files

  • modified_components – List of modified components

  • only_test_related – Only build test-related applications

  • only_non_test_related – Only build non-test-related applications

  • dry_run – Do not actually build, just simulate

  • build_system – Filter the apps by build system. Can be “cmake”, “make” or a custom App class path

  • marker_expr – Pytest marker expression

  • filter_expr – Filter expression

Returns:

Tuple of (built apps, build return code)

idf_ci.get_all_apps(*, paths: List[str] | None = None, target: str = 'all', modified_files: List[str] | None = None, modified_components: List[str] | None = None, filter_expr: str | None = None, default_build_targets: List[str] | None = None, marker_expr: UndefinedType | str | None = __UNDEF__, compare_manifest_sha_filepath: str | None = None, build_system: UndefinedType | str | None = __UNDEF__) Tuple[List[App], List[App]]

Get test-related and non-test-related applications.

Parameters:
  • paths – List of paths to search for applications

  • target – Target device(s) separated by commas

  • modified_files – List of modified files

  • modified_components – List of modified components

  • filter_expr – Pytest filter expression -k

  • default_build_targets – Default build targets to use

  • marker_expr – Pytest marker expression -m

  • compare_manifest_sha_filepath – Path to the manifest SHA file generated by idf-build-apps dump-manifest-sha

  • build_system – Filter the apps by build system. Can be “cmake”, “make” or a custom App class path

Returns:

Tuple of (test_related_apps, non_test_related_apps)

idf_ci.get_ci_settings() CiSettings

Get the current CiSettings instance from the context.

idf_ci.get_pytest_cases(*, paths: List[str] | None = None, target: str = 'all', sdkconfig_name: str | None = None, marker_expr: UndefinedType | str | None = __UNDEF__, filter_expr: str | None = None, additional_args: List[str] | None = None) List[PytestCase]

Collect pytest test cases from specified paths.

Parameters:
  • paths – List of file system paths to collect test cases from

  • target – Filter by targets

  • sdkconfig_name – Filter tests whose apps are built with this sdkconfig name

  • marker_expr – Filter by pytest marker expression -m

  • filter_expr – Filter by pytest filter expression -k

  • additional_args – Additional arguments to pass to pytest

Returns:

List of collected PytestCase objects

Raises:

RuntimeError – If pytest collection fails