Class: HybridPlatformsConductor::HpcPlugins::Test::LinearStrategy
- Defined in:
- lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
Overview
Check that the repository is having a Git linear strategy on master.
Constant Summary collapse
- LOOKING_PERIOD =
Number of seconds of the period after which we tolerate non-linear history in git
6 * 31 * 24 * 60 * 60
Constants included from LoggerHelpers
LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR
Instance Attribute Summary
Attributes inherited from Test
#errors, #expected_failure, #name, #node, #platform
Instance Method Summary collapse
-
#test_on_platform ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
Methods inherited from Test
#assert_equal, #assert_match, #error, #executed, #executed?, #initialize, only_on_nodes, only_on_platforms, #to_s
Methods inherited from Plugin
extend_config_dsl_with, #initialize, valid?
Methods included from LoggerHelpers
#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar
Constructor Details
This class inherits a constructor from HybridPlatformsConductor::Test
Instance Method Details
#test_on_platform ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb', line 14 def test_on_platform _exit_status, stdout, _stderr = @cmd_runner.run_cmd( "cd #{@platform.repository_path} && git --no-pager log --merges --pretty=format:\"%H\"", log_to_stdout: log_debug? ) stdout.split("\n").each do |merge_commit_id| _exit_status, stdout, _stderr = @cmd_runner.run_cmd(<<~EOS, log_to_stdout: log_debug?, no_exception: true, expected_code: [0, 1]) cd #{@platform.repository_path} && \ git --no-pager log \ $(git merge-base \ --octopus \ $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:\"%P\") \ )..#{merge_commit_id} \ --pretty=format:\"%H\" \ --graph \ | grep '|' EOS if !stdout.empty? _exit_status, stdout, _stderr = @cmd_runner.run_cmd( "cd #{@platform.repository_path} && git --no-pager log #{merge_commit_id} --pretty=format:%aI", log_to_stdout: log_debug? ) error "Git history is not linear because of Merge commit #{merge_commit_id}" if Time.now - Time.parse(stdout.strip) < LOOKING_PERIOD end end end |