From 85e3b5554e18ee8957a384ae2ecc43a1cc7d9219 Mon Sep 17 00:00:00 2001 From: SamTheisens <1911436+SamTheisens@users.noreply.github.com> Date: Mon, 15 May 2023 09:58:35 +0800 Subject: [PATCH] [TECH-272] Introduce separate command for client mode branch: feature/TECH-272-upgrade-monorepo --- mpyl_config.example.yml | 1 + src/mpyl/schema/mpyl_config.schema.yml | 3 +++ src/mpyl/utilities/sbt/__init__.py | 6 +++--- tests/steps/build_step/test/test_sbt_test.py | 9 +++++---- tests/test_resources/mpyl_config.yml | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mpyl_config.example.yml b/mpyl_config.example.yml index 0c2ce90e4..f84091697 100644 --- a/mpyl_config.example.yml +++ b/mpyl_config.example.yml @@ -39,6 +39,7 @@ jenkins: defaultPipeline: 'mpyl-test' sbt: command: 'sbt' + clientCommand: 'sbtn' testWithCoverage: !ENV ${SBT_RUN_WITH_COVERAGE:false} verbose: false javaOpts: '-Xmx4G -Xms4G -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -Xss2M' diff --git a/src/mpyl/schema/mpyl_config.schema.yml b/src/mpyl/schema/mpyl_config.schema.yml index 9cba440a5..02b49a604 100644 --- a/src/mpyl/schema/mpyl_config.schema.yml +++ b/src/mpyl/schema/mpyl_config.schema.yml @@ -196,6 +196,8 @@ definitions: properties: command: type: string + clientCommand: + type: string verbose: default: false type: boolean @@ -217,6 +219,7 @@ definitions: default: true required: - command + - clientCommand - javaOpts - sbtOpts title: Sbt diff --git a/src/mpyl/utilities/sbt/__init__.py b/src/mpyl/utilities/sbt/__init__.py index 75a31c33e..81791d566 100644 --- a/src/mpyl/utilities/sbt/__init__.py +++ b/src/mpyl/utilities/sbt/__init__.py @@ -9,6 +9,7 @@ class SbtConfig: java_opts: str sbt_opts: str sbt_command: str + sbt_client_command: str test_with_coverage: bool verbose: bool build_with_client: bool @@ -21,6 +22,7 @@ def from_config(config: Dict): raise KeyError(f"'sbt' could not be loaded from {config}") return SbtConfig( sbt_command=sbt_config['command'], + sbt_client_command=sbt_config['clientCommand'], java_opts=sbt_config['javaOpts'], sbt_opts=sbt_config['sbtOpts'], test_with_coverage=(str(sbt_config['testWithCoverage']).lower() == 'true'), @@ -30,11 +32,9 @@ def from_config(config: Dict): ) def to_command(self, client_mode: bool, sbt_commands: list[str]): - cmd = [self.sbt_command] + cmd = [self.sbt_client_command if client_mode else self.sbt_command] if self.verbose: cmd.append('-v') - if client_mode: - cmd.append('--client') cmd.extend([f'-J{opt}' for opt in self.java_opts.split(' ')]) cmd.extend([f'-D{opt}' for opt in self.sbt_opts.split(' ')]) diff --git a/tests/steps/build_step/test/test_sbt_test.py b/tests/steps/build_step/test/test_sbt_test.py index 25e7f6439..928ab3549 100644 --- a/tests/steps/build_step/test/test_sbt_test.py +++ b/tests/steps/build_step/test/test_sbt_test.py @@ -23,13 +23,14 @@ def test_sbt_test_test_command_should_be_properly_constructed(self): '-J-Xss2M -Duser.timezone=GMT -Djline.terminal=jline.UnixTerminal project ' 'dockertest; test; coverageOff') - def test_sbt_test_without_coverage_command_should_be_properly_constructed(self): + def test_sbt_test_without_coverage_but_with_client_command_should_be_properly_constructed(self): sbt_config = self.sbt_config sbt_config_with_coverage = SbtConfig(sbt_config.java_opts, sbt_config.sbt_opts, - sbt_command=sbt_config.sbt_command, test_with_coverage=False, - verbose=False, build_with_client=True, test_with_client=False) + sbt_command=sbt_config.sbt_command, + sbt_client_command=sbt_config.sbt_client_command, test_with_coverage=False, + verbose=False, build_with_client=True, test_with_client=True) command = TestSbt._construct_sbt_command(self.step_input, sbt_config_with_coverage, TestSbt._construct_sbt_command_test_without_coverage) - assert ' '.join(command) == ('sbt -J-Xmx4G -J-Xms4G -J-XX:+UseG1GC -J-XX:+CMSClassUnloadingEnabled ' + assert ' '.join(command) == ('sbtn -J-Xmx4G -J-Xms4G -J-XX:+UseG1GC -J-XX:+CMSClassUnloadingEnabled ' '-J-Xss2M -Duser.timezone=GMT -Djline.terminal=jline.UnixTerminal ' 'dockertest/test') diff --git a/tests/test_resources/mpyl_config.yml b/tests/test_resources/mpyl_config.yml index 336d80c33..76be74efd 100644 --- a/tests/test_resources/mpyl_config.yml +++ b/tests/test_resources/mpyl_config.yml @@ -29,6 +29,7 @@ docker: dockerFileName: 'Dockerfile-mpl' sbt: command: 'sbt' + clientCommand: 'sbtn' testWithCoverage: !ENV ${SBT_RUN_WITH_COVERAGE:true} verbose: true javaOpts: '-Xmx4G -Xms4G -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -Xss2M'