Sha256: a3e6ab290ccf8bccaabff7e9d64db943ed4c207717159d589cd94de8830f9b66

Contents?: true

Size: 1.72 KB

Versions: 36

Compression:

Stored size: 1.72 KB

Contents

module HybridPlatformsConductor

  module HpcPlugins

    module Test

      # Check that the repository is having a Git linear strategy on master.
      class LinearStrategy < HybridPlatformsConductor::Test

        # Number of seconds of the period after which we tolerate non-linear history in git
        LOOKING_PERIOD = 6 * 31 * 24 * 60 * 60 # 6 months

        # Check my_test_plugin.rb.sample documentation for signature details.
        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

      end

    end

  end

end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.0.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.18.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.17.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.17.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.16.4 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.16.3 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.16.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.16.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.16.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.15.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.14.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.13.4 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.13.3 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.13.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.13.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.13.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.12.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.11.2 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.11.1 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb
hybrid_platforms_conductor-32.11.0 lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb