diff --git a/.github/workflows/consumer_test.yml b/.github/workflows/consumer_test.yml index f3f41c995..15b154785 100644 --- a/.github/workflows/consumer_test.yml +++ b/.github/workflows/consumer_test.yml @@ -14,8 +14,8 @@ name: Consumer Tests on: workflow_call: - pull_request_target: - types: [opened, reopened, synchronize] # Allows forks to trigger the docs build + pull_request: + types: [opened, reopened, synchronize] merge_group: types: [checks_requested] diff --git a/src/tests/test_consumer.py b/src/tests/test_consumer.py index a8f8071fb..14adad1b1 100644 --- a/src/tests/test_consumer.py +++ b/src/tests/test_consumer.py @@ -12,6 +12,7 @@ # ******************************************************************************* import os import re +import shutil import subprocess from collections import defaultdict from dataclasses import dataclass, field @@ -132,6 +133,17 @@ def sphinx_base_dir(tmp_path_factory: TempPathFactory, pytestconfig: Config) -> return CACHE_DIR +def cleanup(): + """ + Cleanup before tests are run + """ + for p in Path(".").glob("*/ubproject.toml"): + p.unlink() + shutil.rmtree("_build", ignore_errors=True) + cmd = "bazel clean --async" + subprocess.run(cmd.split(), text=True) + + def get_current_git_commit(curr_path: Path): """ Get the current git commit hash (HEAD). @@ -449,6 +461,8 @@ def run_cmd( ) -> tuple[list[Result], bool]: verbosity: int = pytestconfig.get_verbosity() + cleanup() + if verbosity >= 3: # Level 3 (-vvv): Stream output in real-time BR = stream_subprocess_output(cmd, repo_name) @@ -584,6 +598,7 @@ def prepare_repo_overrides( # Updated version of your test loop def test_and_clone_repos_updated(sphinx_base_dir: Path, pytestconfig: Config): # Get command line options from pytest config + repo_tests: str | None = cast(str | None, pytestconfig.getoption("--repo")) disable_cache: bool = bool(pytestconfig.getoption("--disable-cache"))