File tree Expand file tree Collapse file tree 7 files changed +52
-16
lines changed Expand file tree Collapse file tree 7 files changed +52
-16
lines changed Original file line number Diff line number Diff line change 4848 sudo apt install -y asciidoctor
4949 sudo gem install asciidoctor asciidoctor-diagram rouge
5050
51- - name : Install cmake-format
52- run : |
53- pipx install cmakelang
54- pipx inject cmakelang pyyaml
55-
56- - name : Install python quality tools
57- run : |
58- pipx install pytest
59- pipx inject pytest pytest-forked
60- pipx inject pytest hypothesis
61- pipx install mypy
62- pipx install black
63- echo "/opt/pipx_bin" >> $GITHUB_PATH
64-
6551 - name : Checkout target branch
6652 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6753 with :
7460 - name : Checkout PR branch
7561 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7662
63+ - name : Install python test requirements
64+ run : |
65+ python3 -m venv ${{github.workspace}}/test_venv
66+ source ${{github.workspace}}/test_venv/bin/activate
67+ pip install -r ${{github.workspace}}/requirements.txt
68+ echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
69+
70+ - name : Install cmake-format
71+ run : |
72+ pip install cmakelang pyyaml
73+
74+ - name : Install python quality tools
75+ run : |
76+ pip install mypy black
77+
7778 - name : Restore CPM cache
7879 env :
7980 cache-name : cpm-cache-0
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ option(INFRA_PROVIDE_CLANG_TIDY "Provide .clang-tidy file" ON)
2626option (INFRA_PROVIDE_CMAKE_FORMAT "Provide .cmake-format.yaml file" ON )
2727option (INFRA_PROVIDE_PRESETS "Provide cmake presets and toolchains" ON )
2828option (INFRA_PROVIDE_MULL "Provide mull.yml file" ON )
29+ option (INFRA_PROVIDE_PYTEST_REQS
30+ "Provide pip requirements.txt for python tests" ON )
2931option (INFRA_PROVIDE_GITIGNORE "Add provided things to .gitignore" ON )
3032option (INFRA_USE_SYMLINKS "Use symlinks to provide common files" ON )
3133
Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ function(make_gitignore)
4141 list (APPEND GITIGNORE_CONTENTS "mull.yml" )
4242 endif ()
4343 endif ()
44+ if (INFRA_PROVIDE_PYTEST_REQS)
45+ if (NOT EXISTS "${CMAKE_SOURCE_DIR} /requirements.txt" )
46+ list (APPEND GITIGNORE_CONTENTS "requirements.txt" )
47+ endif ()
48+ endif ()
4449 endif ()
4550
4651 string (REPLACE ";" "\n " GITIGNORE_CONTENTS "${GITIGNORE_CONTENTS} " )
@@ -112,6 +117,9 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
112117 if (INFRA_PROVIDE_MULL)
113118 put_in_project_dir("mull.yml" )
114119 endif ()
120+ if (INFRA_PROVIDE_PYTEST_REQS)
121+ put_in_project_dir("requirements.txt" )
122+ endif ()
115123
116124 if (INFRA_PROVIDE_GITHUB_WORKFLOWS)
117125 execute_process (COMMAND ${CMAKE_COMMAND} -E make_directory
Original file line number Diff line number Diff line change @@ -245,8 +245,8 @@ function(add_python_test_target name)
245245 set (include_dirs_arg --include_dirs ${include_dirs} )
246246 endif ()
247247 set (target_test_command
248- env "PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR} /__pycache__" pytest
249- --forked -o "cache_dir=${CMAKE_BINARY_DIR} /.pytest_cache"
248+ env "PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR} /__pycache__" pytest -n
249+ auto -o "cache_dir=${CMAKE_BINARY_DIR} /.pytest_cache"
250250 --rootdir=${CMAKE_SOURCE_DIR} -s ${UNIT_FILES} ${include_files_arg}
251251 ${include_dirs_arg} ${UNIT_EXTRA_ARGS} )
252252
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ level, and a `toolchains` directory.
3030
3131When `ON`, this repository provides a `mull.yml` file at the root level.
3232
33+ *`INFRA_PROVIDE_PYTEST_REQS`*
34+
35+ When `ON`, this repository provides a `requirements.txt` file at the root level.
36+ When used with `pip install -r requirements.txt` this provides the packages
37+ sufficient to run python tests.
38+
3339*`INFRA_PROVIDE_GITIGNORE`*
3440
3541When `ON`, this repository provides a `.gitignore` file at the root level. It
Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ dependencies that are not part of the CMake dependency tree. A `conftest.py`
6868file in the same directory as any of the `FILE`s is automatically discovered as
6969such a dependency.
7070
71+ NOTE: Python tests use several testing packages; these can be installed using
72+ `requirements.txt` which is provided through the `INFRA_PROVIDE_PYTEST_REQS`
73+ option.
74+
7175=== Fuzz tests
7276
7377[source,cmake]
Original file line number Diff line number Diff line change 1+ # The contents of this file can be generated at latest versions available by running:
2+ #
3+ # $ python3 -m venv ./test_venv
4+ # $ source ./test_venv/bin/activate
5+ # $ pip install pytest pytest-xdist hypothesis | tail -n1 | cut -d' ' -f 3- | tr ' ' '\n' | sed 's/\(.*\)-\(.*\)/\1==\2/'
6+ #
7+ attrs == 24.2.0
8+ execnet == 2.1.1
9+ hypothesis == 6.115.3
10+ iniconfig == 2.0.0
11+ packaging == 24.1
12+ pluggy == 1.5.0
13+ pytest == 8.3.3
14+ pytest-xdist == 3.6.1
15+ sortedcontainers == 2.4.0
You can’t perform that action at this time.
0 commit comments