Skip to content

Commit

Permalink
[TECH-272] Introduce separate command for client mode
Browse files Browse the repository at this point in the history
branch: feature/TECH-272-upgrade-monorepo
  • Loading branch information
SamTheisens committed May 15, 2023
1 parent 3202b49 commit 85e3b55
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions mpyl_config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions src/mpyl/schema/mpyl_config.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ definitions:
properties:
command:
type: string
clientCommand:
type: string
verbose:
default: false
type: boolean
Expand All @@ -217,6 +219,7 @@ definitions:
default: true
required:
- command
- clientCommand
- javaOpts
- sbtOpts
title: Sbt
Expand Down
6 changes: 3 additions & 3 deletions src/mpyl/utilities/sbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'),
Expand All @@ -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(' ')])

Expand Down
9 changes: 5 additions & 4 deletions tests/steps/build_step/test/test_sbt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
1 change: 1 addition & 0 deletions tests/test_resources/mpyl_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 85e3b55

Please sign in to comment.