From 56c809691f1d328682616cde02458b1390daa1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Tue, 27 Jun 2023 15:53:10 +0200 Subject: [PATCH] fixup! Add new command /tests to run bci-tests on a test build --- .github/workflows/tests-command.yml | 4 ++- src/staging/bot.py | 40 ++++++++++++++++------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests-command.yml b/.github/workflows/tests-command.yml index 1debd2821..552b27d70 100644 --- a/.github/workflows/tests-command.yml +++ b/.github/workflows/tests-command.yml @@ -54,7 +54,9 @@ jobs: run: exit 1 - name: run BCI-tests - run: echo "${{ steps.find_comment.outputs.comment-body }}" | poetry run scratch-build-bot -vvvv --from-stdin run_bci_tests + run: | + echo "${{ steps.find_comment.outputs.comment-body }}" | poetry run scratch-build-bot -vvvv --from-stdin run_bci_tests + ./run_bci_tests.sh shell: fish {0} env: OSC_PASSWORD: ${{ secrets.OSC_PASSWORD }} diff --git a/src/staging/bot.py b/src/staging/bot.py index 12577f9f2..6c7dbb549 100644 --- a/src/staging/bot.py +++ b/src/staging/bot.py @@ -31,7 +31,6 @@ from obs_package_update.util import CommandError from obs_package_update.util import CommandResult from obs_package_update.util import retry_async_run_cmd -from obs_package_update.util import run_cmd from obs_package_update.util import RunCommand from staging.build_result import Arch from staging.build_result import PackageBuildResult @@ -1504,6 +1503,7 @@ def main() -> None: import logging import os.path import sys + import stat from typing import Any from bci_build.package import ALL_OS_VERSIONS @@ -1863,24 +1863,28 @@ async def _pkgs_as_str() -> str: async def _run_tests() -> str: tox_env = os.getenv("TOX_ENV") bci_tests_branch = os.getenv("BCI_TESTS_BRANCH") - await run_cmd( - f"git clone https://github.com/SUSE/BCI-tests", logger=LOGGER - ) - runner = RunCommand( - cwd=os.path.join(os.getcwd(), "BCI-tests"), logger=LOGGER - ) + + script = fr"""#!/bin/bash +set -euxo pipefail + +git clone https://github.com/SUSE/BCI-tests +pushd BCI-tests +export OS_VERSION="15.{bot.os_version}" +export TARGET="custom" +export BASEURL="{bot.staging_project_registry_base_url}" +export TOX_SKIP_ENV='py(\d+)-unit' +""" if bci_tests_branch: - await runner(f"git checkout {bci_tests_branch}") - - test_res = await runner( - f"tox {'-e ' + tox_env if tox_env else ''} -- -n auto", - env={ - "OS_VERSION": f"15.{bot.os_version}", - "TARGET": "custom", - "BASEURL": bot.staging_project_registry_base_url, - }, - ) - return test_res.stdout + script += f"""git checkout {bci_tests_branch} +""" + + script += f"tox{' -e ' + tox_env if tox_env else ''} -- -n auto" + + with open("run_bci_tests.sh", "w") as bci_tests_sh: + bci_tests_sh.write(script) + + os.chmod("run_bci_tests.sh", 0o755) + return "" coro = _run_tests()