From a5a2668af599c7c055f1a771e349d2949ae1cc33 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Thu, 22 Sep 2022 18:06:46 +0200 Subject: [PATCH] integration_tests: default KBS branch name from CI env vars if kbs_branch comes back empty --- integration_tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/integration_tests.py b/integration_tests.py index 79f83ff..3d5b956 100644 --- a/integration_tests.py +++ b/integration_tests.py @@ -28,9 +28,15 @@ def ctx() -> click.Context: def test_packages_update(ctx: click.Context): - kbs_branch = git_get_branch(config.runtime.script_source_dir) pkgbuilds_path = config.get_path('pkgbuilds') - for branch, may_fail in {'main': False, 'dev': False, kbs_branch: True}.items(): + kbs_branch = git_get_branch(config.runtime.script_source_dir) + # Gitlab CI integration: the CI checks out a detached commit, branch comes back empty. + if not kbs_branch and os.environ.get('CI', 'false') == 'true': + kbs_branch = os.environ.get('CI_COMMIT_BRANCH', '') + branches: dict[str, bool] = {'main': False, 'dev': False} + if kbs_branch: + branches[kbs_branch] = True + for branch, may_fail in branches.items(): config.file.pkgbuilds.git_branch = branch try: ctx.invoke(cmd_update, non_interactive=True, switch_branch=True)