diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..b2d4b591 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,317 @@ +require: + - rubocop-minitest + - rubocop-packaging + - rubocop-rails + +AllCops: + TargetRubyVersion: 2.7 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + SuggestExtensions: false + Exclude: + - '**/tmp/**/*' + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + - 'actionmailbox/test/dummy/**/*' + - 'activestorage/test/dummy/**/*' + - 'actiontext/test/dummy/**/*' + - 'tools/rail_inspector/test/fixtures/*' + - guides/source/debugging_rails_applications.md + - guides/source/active_support_instrumentation.md + - '**/node_modules/**/*' + - '**/CHANGELOG.md' + - '**/2_*_release_notes.md' + - '**/3_*_release_notes.md' + - '**/4_*_release_notes.md' + - '**/5_*_release_notes.md' + - '**/6_*_release_notes.md' + + +# Prefer assert_not over assert ! +Rails/AssertNot: + Include: + - '**/test/**/*' + +# Prefer assert_not_x over refute_x +Rails/RefuteMethods: + Include: + - '**/test/**/*' + +Rails/IndexBy: + Enabled: true + +Rails/IndexWith: + Enabled: true + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +Layout/ClosingHeredocIndentation: + Enabled: true + +Layout/ClosingParenthesisIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +Layout/EndOfLine: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +Layout/EmptyLinesAroundAccessModifier: + Enabled: true + EnforcedStyle: only_before + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: true + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + Exclude: + - '**/*.md' + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/ExplicitBlockArgument: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always + Exclude: + - 'actionview/test/**/*.builder' + - 'actionview/test/**/*.ruby' + - 'actionpack/test/**/*.builder' + - 'actionpack/test/**/*.ruby' + - 'activestorage/db/migrate/**/*.rb' + - 'activestorage/db/update_migrate/**/*.rb' + - 'actionmailbox/db/migrate/**/*.rb' + - 'actiontext/db/migrate/**/*.rb' + - '**/*.md' + +Style/MapToHash: + Enabled: true + +Style/RedundantFreeze: + Enabled: true + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + EnforcedStyleForEmptyBraces: space + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +# Detect hard tabs, no hard tabs. +Layout/IndentationStyle: + Enabled: true + +# Empty lines should not have any spaces. +Layout/TrailingEmptyLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: true + +# Use quotes for string literals when they are enough. +Style/RedundantPercentQ: + Enabled: true + +Lint/AmbiguousOperator: + Enabled: true + +Lint/AmbiguousRegexpLiteral: + Enabled: true + +Lint/DuplicateRequire: + Enabled: true + +Lint/DuplicateMagicComment: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/ErbNewArguments: + Enabled: true + +Lint/EnsureReturn: + Enabled: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Lint/RedundantStringCoercion: + Enabled: true + +Lint/RedundantSafeNavigation: + Enabled: true + +Lint/UriEscapeUnescape: + Enabled: true + +Lint/UselessAssignment: + Enabled: true + +Lint/DeprecatedClassMethods: + Enabled: true + +Lint/InterpolationCheck: + Enabled: true + Exclude: + - '**/test/**/*' + +Style/EvalWithLocation: + Enabled: true + Exclude: + - '**/test/**/*' + +Style/ParenthesesAroundCondition: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + +Style/RedundantBegin: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/RedundantRegexpEscape: + Enabled: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true + +# Prefer Foo.method over Foo::method +Style/ColonMethodCall: + Enabled: true + +Style/TrivialAccessors: + Enabled: true + +# Prefer a = b || c over a = b ? b : c +Style/RedundantCondition: + Enabled: true + +Style/RedundantDoubleSplatHashBraces: + Enabled: true + +Minitest/AssertPredicate: + Enabled: true + +Minitest/AssertRaisesWithRegexpArgument: + Enabled: true + +Minitest/AssertWithExpectedArgument: + Enabled: true + +Minitest/LiteralAsActualArgument: + Enabled: true + +Minitest/SkipEnsure: + Enabled: true + +Minitest/UnreachableAssertion: + Enabled: true diff --git a/Gemfile b/Gemfile index 6e6c8038..9c3ffc5a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gem "buildkit" @@ -5,4 +7,8 @@ gem "buildkite-builder" gem "diffy" gem "rake" gem "debug" -gem "activesupport" \ No newline at end of file +gem "activesupport" +gem "rubocop" +gem "rubocop-minitest" +gem "rubocop-packaging" +gem "rubocop-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 80b9a75a..9b894a53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,6 +13,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) base64 (0.1.1) bigdecimal (3.1.4) buildkit (1.5.0) @@ -37,17 +38,49 @@ GEM irb (1.8.3) rdoc reline (>= 0.3.8) + json (2.6.3) + language_server-protocol (3.17.0.3) minitest (5.19.0) mutex_m (0.1.2) + parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc psych (5.1.1.1) stringio public_suffix (5.0.1) + racc (1.7.3) + rack (3.0.8) rainbow (3.1.1) rake (13.0.6) rdoc (6.5.0) psych (>= 4.0.0) + regexp_parser (2.8.2) reline (0.3.9) io-console (~> 0.5) + rexml (3.2.6) + rubocop (1.57.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.4) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) + rubocop-minitest (0.31.0) + rubocop (>= 1.39, < 2.0) + rubocop-packaging (0.5.2) + rubocop (>= 1.33, < 2.0) + rubocop-rails (2.22.1) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sawyer (0.9.2) addressable (>= 2.3.5) @@ -55,6 +88,7 @@ GEM stringio (3.0.8) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) PLATFORMS aarch64-linux @@ -68,6 +102,10 @@ DEPENDENCIES debug diffy rake + rubocop + rubocop-minitest + rubocop-packaging + rubocop-rails BUNDLED WITH 2.4.10 diff --git a/lib/buildkite_config.rb b/lib/buildkite_config.rb index 2ce12599..9bd16302 100644 --- a/lib/buildkite_config.rb +++ b/lib/buildkite_config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Buildkite module Config autoload :Annotate, File.expand_path("buildkite_config/annotate", __dir__) diff --git a/lib/buildkite_config/annotate.rb b/lib/buildkite_config/annotate.rb index 4cf87901..1bc55f24 100644 --- a/lib/buildkite_config/annotate.rb +++ b/lib/buildkite_config/annotate.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Buildkite::Config class Annotate def initialize(diff) @@ -21,4 +23,4 @@ def plan PLAN end end -end \ No newline at end of file +end diff --git a/lib/buildkite_config/build_context.rb b/lib/buildkite_config/build_context.rb index 97d67bb9..70393ce8 100644 --- a/lib/buildkite_config/build_context.rb +++ b/lib/buildkite_config/build_context.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "buildkite-builder" module Buildkite::Config diff --git a/lib/buildkite_config/diff.rb b/lib/buildkite_config/diff.rb index 6243777f..081615ec 100644 --- a/lib/buildkite_config/diff.rb +++ b/lib/buildkite_config/diff.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "diffy" module Buildkite::Config @@ -20,4 +22,3 @@ def self.generated_pipeline(repo) end end end - diff --git a/lib/buildkite_config/docker_build.rb b/lib/buildkite_config/docker_build.rb index 3a468147..aa14eb70 100644 --- a/lib/buildkite_config/docker_build.rb +++ b/lib/buildkite_config/docker_build.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "buildkite-builder" module Buildkite::Config @@ -14,7 +16,7 @@ def builder(ruby:, &block) download: %w[.dockerignore .buildkite/* .buildkite/**/*] } - plugin build_context.docker_compose_plugin,{ + plugin build_context.docker_compose_plugin, { build: "base", config: ".buildkite/docker-compose.yml", env: %w[PRE_STEPS RACK], diff --git a/lib/buildkite_config/rake_command.rb b/lib/buildkite_config/rake_command.rb index 71a22a49..485add2c 100644 --- a/lib/buildkite_config/rake_command.rb +++ b/lib/buildkite_config/rake_command.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "buildkite-builder" module Buildkite::Config @@ -11,7 +13,7 @@ def to_label(ruby, dir, task) str << " (#{ruby.short_ruby})" end - def rake(dir = "", task = "test", service: "default", pre_steps:[], &block) + def rake(dir = "", task = "test", service: "default", pre_steps: [], &block) build_context = context.extensions.find(BuildContext) ## Setup ENV @@ -38,7 +40,7 @@ def rake(dir = "", task = "test", service: "default", pre_steps:[], &block) download: %w[.buildkite/* .buildkite/**/*] } - plugin build_context.docker_compose_plugin,{ + plugin build_context.docker_compose_plugin, { "env" => [ "PRE_STEPS", "RACK" diff --git a/lib/buildkite_config/ruby_config.rb b/lib/buildkite_config/ruby_config.rb index 77d66c26..9746bde2 100644 --- a/lib/buildkite_config/ruby_config.rb +++ b/lib/buildkite_config/ruby_config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Buildkite::Config class RubyConfig class << self @@ -17,7 +19,7 @@ def yjit_ruby attr_reader :image_base, :version, :yjit, :prefix, :soft_fail attr_writer :image_base - def initialize(version:, soft_fail:nil, prefix: nil, image_base:nil, build:true) + def initialize(version:, soft_fail: nil, prefix: nil, image_base: nil, build: true) @image_base = image_base @prefix = prefix @version = version diff --git a/lib/buildkite_config/ruby_group.rb b/lib/buildkite_config/ruby_group.rb index fb2995d2..6021a4bb 100644 --- a/lib/buildkite_config/ruby_group.rb +++ b/lib/buildkite_config/ruby_group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "buildkite-builder" module Buildkite::Config diff --git a/pipeline-annotate b/pipeline-annotate index 6b7d2414..5a3ae752 100755 --- a/pipeline-annotate +++ b/pipeline-annotate @@ -1,18 +1,18 @@ #!/usr/bin/env ruby # frozen_string_literal: true -def run(cmd, value=false) +def run(cmd, value = false) io = IO.popen(cmd) output = io.read io.close raise output unless $?.success? - return output if value + output if value end run "bundle install" annotation = run "bundle exec rake diff", true -puts annotation \ No newline at end of file +puts annotation diff --git a/pipeline-generate b/pipeline-generate index fe93203d..dd98a027 100755 --- a/pipeline-generate +++ b/pipeline-generate @@ -1,14 +1,14 @@ #!/usr/bin/env ruby # frozen_string_literal: true -def run(cmd, env={}, value=false) +def run(cmd, env = {}, value = false) io = IO.popen(env, cmd) output = io.read io.close raise output unless $?.success? - return output if value + output if value end env = {} diff --git a/pipelines/rails-ci/pipeline.rb b/pipelines/rails-ci/pipeline.rb index a2c9a2ad..5a6d854e 100644 --- a/pipelines/rails-ci/pipeline.rb +++ b/pipelines/rails-ci/pipeline.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "pathname" require "yaml" @@ -8,7 +9,7 @@ Pathname.new(File.expand_path("../../.buildkite", __dir__)) end -#Buildkite::Builder.root(start_path: BUILDKITE_ROOT_DIR) +# Buildkite::Builder.root(start_path: BUILDKITE_ROOT_DIR) Buildkite::Builder.pipeline do require_relative "../../lib/buildkite_config" diff --git a/test/buildkite_config/test_docker_build.rb b/test/buildkite_config/test_docker_build.rb index 58a9a6a4..50ce689c 100644 --- a/test/buildkite_config/test_docker_build.rb +++ b/test/buildkite_config/test_docker_build.rb @@ -12,28 +12,28 @@ def test_builder builder ruby: Buildkite::Config::RubyConfig.new(prefix: "builder:", version: "3.2") end - expected = {"steps"=> - [{"label"=>":docker: builder:3.2", - "key"=>"docker-image-builder-3-2", - "agents"=>{"queue"=>"builder"}, - "env"=> - {"BUNDLER"=>nil, - "RUBYGEMS"=>nil, - "RUBY_IMAGE"=>"builder:3.2", - "encrypted_0fb9444d0374_key"=>nil, - "encrypted_0fb9444d0374_iv"=>nil}, - "timeout_in_minutes"=>15, - "plugins"=> - [{"artifacts#v1.2.0"=> - {"download"=>[".dockerignore", ".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"build"=>"base", - "config"=>".buildkite/docker-compose.yml", - "env"=>["PRE_STEPS", "RACK"], - "image-name"=>"builder-3-2-local", - "cache-from"=>["base:buildkite-config-base:builder-3-2-br-main"], - "push"=>["base:buildkite-config-base:builder-3-2-br-"], - "image-repository"=>"buildkite-config-base"}}]}]} + expected = { "steps" => + [{ "label" => ":docker: builder:3.2", + "key" => "docker-image-builder-3-2", + "agents" => { "queue" => "builder" }, + "env" => + { "BUNDLER" => nil, + "RUBYGEMS" => nil, + "RUBY_IMAGE" => "builder:3.2", + "encrypted_0fb9444d0374_key" => nil, + "encrypted_0fb9444d0374_iv" => nil }, + "timeout_in_minutes" => 15, + "plugins" => + [{ "artifacts#v1.2.0" => + { "download" => [".dockerignore", ".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "build" => "base", + "config" => ".buildkite/docker-compose.yml", + "env" => ["PRE_STEPS", "RACK"], + "image-name" => "builder-3-2-local", + "cache-from" => ["base:buildkite-config-base:builder-3-2-br-main"], + "push" => ["base:buildkite-config-base:builder-3-2-br-"], + "image-repository" => "buildkite-config-base" } }] }] } assert_equal expected, pipeline.to_h end @@ -45,28 +45,28 @@ def test_builder_gem_version builder ruby: Buildkite::Config::RubyConfig.new(prefix: "ruby:", version: Gem::Version.new("1.9.3")) end - expected = {"steps"=> - [{"label"=>":docker: ruby:1.9.3", - "key"=>"docker-image-ruby-1-9-3", - "agents"=>{"queue"=>"builder"}, - "env"=> - {"BUNDLER"=>nil, - "RUBYGEMS"=>nil, - "RUBY_IMAGE"=>"ruby:1.9.3", - "encrypted_0fb9444d0374_key"=>nil, - "encrypted_0fb9444d0374_iv"=>nil}, - "timeout_in_minutes"=>15, - "plugins"=> - [{"artifacts#v1.2.0"=> - {"download"=>[".dockerignore", ".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"build"=>"base", - "config"=>".buildkite/docker-compose.yml", - "env"=>["PRE_STEPS", "RACK"], - "image-name"=>"ruby-1-9-3-local", - "cache-from"=>["base:buildkite-config-base:ruby-1-9-3-br-main"], - "push"=>["base:buildkite-config-base:ruby-1-9-3-br-"], - "image-repository"=>"buildkite-config-base"}}]}]} + expected = { "steps" => + [{ "label" => ":docker: ruby:1.9.3", + "key" => "docker-image-ruby-1-9-3", + "agents" => { "queue" => "builder" }, + "env" => + { "BUNDLER" => nil, + "RUBYGEMS" => nil, + "RUBY_IMAGE" => "ruby:1.9.3", + "encrypted_0fb9444d0374_key" => nil, + "encrypted_0fb9444d0374_iv" => nil }, + "timeout_in_minutes" => 15, + "plugins" => + [{ "artifacts#v1.2.0" => + { "download" => [".dockerignore", ".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "build" => "base", + "config" => ".buildkite/docker-compose.yml", + "env" => ["PRE_STEPS", "RACK"], + "image-name" => "ruby-1-9-3-local", + "cache-from" => ["base:buildkite-config-base:ruby-1-9-3-br-main"], + "push" => ["base:buildkite-config-base:ruby-1-9-3-br-"], + "image-repository" => "buildkite-config-base" } }] }] } assert_equal expected, pipeline.to_h end @@ -79,28 +79,28 @@ def test_builder_sets_image_base builder ruby: build_context.ruby end - expected = {"steps"=> - [{"label"=>":docker: 2.0", - "key"=>"docker-image-2-0", - "agents"=>{"queue"=>"builder"}, - "env"=> - {"BUNDLER"=>nil, - "RUBYGEMS"=>nil, - "RUBY_IMAGE"=>"2.0", - "encrypted_0fb9444d0374_key"=>nil, - "encrypted_0fb9444d0374_iv"=>nil}, - "timeout_in_minutes"=>15, - "plugins"=> - [{"artifacts#v1.2.0"=> - {"download"=>[".dockerignore", ".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"build"=>"base", - "config"=>".buildkite/docker-compose.yml", - "env"=>["PRE_STEPS", "RACK"], - "image-name"=>"2-0-local", - "cache-from"=>["base:test_builder_sets_image_base:2-0-br-main"], - "push"=>["base:test_builder_sets_image_base:2-0-br-"], - "image-repository"=>"test_builder_sets_image_base"}}]}]} + expected = { "steps" => + [{ "label" => ":docker: 2.0", + "key" => "docker-image-2-0", + "agents" => { "queue" => "builder" }, + "env" => + { "BUNDLER" => nil, + "RUBYGEMS" => nil, + "RUBY_IMAGE" => "2.0", + "encrypted_0fb9444d0374_key" => nil, + "encrypted_0fb9444d0374_iv" => nil }, + "timeout_in_minutes" => 15, + "plugins" => + [{ "artifacts#v1.2.0" => + { "download" => [".dockerignore", ".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "build" => "base", + "config" => ".buildkite/docker-compose.yml", + "env" => ["PRE_STEPS", "RACK"], + "image-name" => "2-0-local", + "cache-from" => ["base:test_builder_sets_image_base:2-0-br-main"], + "push" => ["base:test_builder_sets_image_base:2-0-br-"], + "image-repository" => "test_builder_sets_image_base" } }] }] } assert_equal expected, pipeline.to_h end end diff --git a/test/buildkite_config/test_rake_command.rb b/test/buildkite_config/test_rake_command.rb index 4e2f0345..825fccce 100644 --- a/test/buildkite_config/test_rake_command.rb +++ b/test/buildkite_config/test_rake_command.rb @@ -14,7 +14,7 @@ def test_to_label end end - expected = {"steps" => [{ "label" => "test all (3.2)", "group" => nil, "steps" => [] }] } + expected = { "steps" => [{ "label" => "test all (3.2)", "group" => nil, "steps" => [] }] } assert_equal expected, pipeline.to_h end @@ -28,7 +28,7 @@ def test_ruby_image_name end end - expected = {"steps" => [{ "depends_on" => ["ruby:3.2"], "group" => nil, "steps" => [] }] } + expected = { "steps" => [{ "depends_on" => ["ruby:3.2"], "group" => nil, "steps" => [] }] } assert_equal expected, pipeline.to_h end @@ -42,7 +42,7 @@ def test_depends_on_yjit end end - expected = {"steps" => [{ "depends_on" => ["rubylang/ruby:master-nightly-jammy"], "group" => nil, "steps" => [] }] } + expected = { "steps" => [{ "depends_on" => ["rubylang/ruby:master-nightly-jammy"], "group" => nil, "steps" => [] }] } assert_equal expected, pipeline.to_h end @@ -54,23 +54,23 @@ def test_command rake "test", "test:all" end - expected = {"steps"=> - [{"label"=>"test all (3.2)", - "command"=>["rake test:all"], - "depends_on"=>["docker-image-ruby-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":ruby-3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "test"]}}]}]} + expected = { "steps" => + [{ "label" => "test all (3.2)", + "command" => ["rake test:all"], + "depends_on" => ["docker-image-ruby-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":ruby-3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "test"] } }] }] } assert_equal expected, pipeline.to_h end @@ -82,23 +82,23 @@ def test_default_task rake "activerecord" end - expected = {"steps"=> - [{"label"=>"activerecord (3.2)", - "command"=>["rake test"], - "depends_on"=>["docker-image-ruby-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":ruby-3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "activerecord"]}}]}]} + expected = { "steps" => + [{ "label" => "activerecord (3.2)", + "command" => ["rake test"], + "depends_on" => ["docker-image-ruby-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":ruby-3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "activerecord"] } }] }] } assert_equal expected, pipeline.to_h end @@ -111,39 +111,39 @@ def test_multiple rake "second", "test:all" end - expected = {"steps"=> - [{"label"=>"first all (3.2)", - "command"=>["rake test:all"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "first"]}}]}, - {"label"=>"second all (3.2)", - "command"=>["rake test:all"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "second"]}}]}]} + expected = { "steps" => + [{ "label" => "first all (3.2)", + "command" => ["rake test:all"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "first"] } }] }, + { "label" => "second all (3.2)", + "command" => ["rake test:all"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "second"] } }] }] } assert_equal expected, pipeline.to_h end @@ -155,23 +155,23 @@ def test_docker_compose_plugin rake "subdirectory", "test:isolated", service: "myservice" end - expected = {"steps"=> - [{"label"=>"subdirectory isolated (3.2)", - "command"=>["rake test:isolated"], - "depends_on"=>["docker-image-3-2"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "artifact_paths"=>["test-reports/*/*.xml"], - "env"=>{"IMAGE_NAME"=>"buildkite-config-base:3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"myservice", - "pull"=>"myservice", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "subdirectory"]}}]}]} + expected = { "steps" => + [{ "label" => "subdirectory isolated (3.2)", + "command" => ["rake test:isolated"], + "depends_on" => ["docker-image-3-2"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "artifact_paths" => ["test-reports/*/*.xml"], + "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "myservice", + "pull" => "myservice", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "subdirectory"] } }] }] } assert_equal expected, pipeline.to_h end @@ -184,23 +184,23 @@ def test_env_yjit rake end - expected = {"steps"=> - [{"label"=>" (yjit)", - "command"=>["rake test"], - "depends_on"=>["docker-image-yjit-rubylang-ruby-master-nightly-jammy"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>"buildkite-config-base:rubylang-ruby-master-nightly-jammy-local", "RUBY_YJIT_ENABLE"=>"1"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => " (yjit)", + "command" => ["rake test"], + "depends_on" => ["docker-image-yjit-rubylang-ruby-master-nightly-jammy"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => "buildkite-config-base:rubylang-ruby-master-nightly-jammy-local", "RUBY_YJIT_ENABLE" => "1" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -214,23 +214,23 @@ def test_env_pre_steps end end - expected = {"steps"=> - [{"label"=>"test_env_pre_steps", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>"buildkite-config-base:3-2-local", "PRE_STEPS"=>"rm Gemfile.lock && bundle install"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "test_env_pre_steps", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local", "PRE_STEPS" => "rm Gemfile.lock && bundle install" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -245,23 +245,23 @@ def test_agents end end - expected = {"steps"=> - [{"label"=>"test_agents", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"test_agents"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "test_agents", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "test_agents" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -276,23 +276,23 @@ def test_artifact_paths end end - expected = {"steps"=> - [{"label"=>"test_artifact_paths", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test_artifact_paths"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "test_artifact_paths", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test_artifact_paths"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -310,23 +310,23 @@ def test_automatic_retry_on end end - expected = {"steps"=> - [{"label"=>"test_automatic_retry_on", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>1, "exit_status"=>127}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "test_automatic_retry_on", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 1, "exit_status" => 127 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -341,23 +341,23 @@ def test_timeout_in_minutes end end - expected = {"steps"=> - [{"label"=>"test_timeout_in_minutes", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>10, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "test_timeout_in_minutes", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 10, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -372,24 +372,24 @@ def test_soft_fail end end - expected = {"steps"=> - [{"label"=>"soft_fail", - "command"=>["rake test"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local"}, - "timeout_in_minutes"=>30, - "soft_fail"=>true, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", ""]}}]}]} + expected = { "steps" => + [{ "label" => "soft_fail", + "command" => ["rake test"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local" }, + "timeout_in_minutes" => 30, + "soft_fail" => true, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", ""] } }] }] } assert_equal expected, pipeline.to_h end @@ -404,23 +404,23 @@ def test_rake_with_block end end - expected = {"steps"=> - [{"label"=>"test all (3.2) with_block", - "command"=>["rake all"], - "depends_on"=>["docker-image-3-2"], - "artifact_paths"=>["test-reports/*/*.xml"], - "agents"=>{"queue"=>"default"}, - "retry"=>{"automatic"=>[{"limit"=>2, "exit_status"=>-1}]}, - "env"=>{"IMAGE_NAME"=>":3-2-local", "MYSQL_IMAGE"=>"mariadb:latest"}, - "timeout_in_minutes"=>30, - "plugins"=> - [{"artifacts#v1.2.0"=>{"download"=>[".buildkite/*", ".buildkite/**/*"]}}, - {"docker-compose#v3.7.0"=> - {"env"=>["PRE_STEPS", "RACK"], - "run"=>"default", - "pull"=>"default", - "config"=>".buildkite/docker-compose.yml", - "shell"=>["runner", "test"]}}]}]} + expected = { "steps" => + [{ "label" => "test all (3.2) with_block", + "command" => ["rake all"], + "depends_on" => ["docker-image-3-2"], + "artifact_paths" => ["test-reports/*/*.xml"], + "agents" => { "queue" => "default" }, + "retry" => { "automatic" => [{ "limit" => 2, "exit_status" => -1 }] }, + "env" => { "IMAGE_NAME" => ":3-2-local", "MYSQL_IMAGE" => "mariadb:latest" }, + "timeout_in_minutes" => 30, + "plugins" => + [{ "artifacts#v1.2.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + { "docker-compose#v3.7.0" => + { "env" => ["PRE_STEPS", "RACK"], + "run" => "default", + "pull" => "default", + "config" => ".buildkite/docker-compose.yml", + "shell" => ["runner", "test"] } }] }] } assert_equal expected, pipeline.to_h end end diff --git a/test/buildkite_config/test_ruby_config.rb b/test/buildkite_config/test_ruby_config.rb index dc5e930d..3196f601 100644 --- a/test/buildkite_config/test_ruby_config.rb +++ b/test/buildkite_config/test_ruby_config.rb @@ -97,32 +97,32 @@ def test_short_ruby_sub def test_soft_fail sub = Buildkite::Config::RubyConfig.new(version: Gem::Version.new("3.2"), soft_fail: true) - assert sub.soft_fail? + assert_predicate sub, :soft_fail? end def test_soft_fail_default sub = Buildkite::Config::RubyConfig.new(version: Gem::Version.new("3.2")) - refute sub.soft_fail? + assert_not sub.soft_fail? end def test_yjit_enabled sub = Buildkite::Config::RubyConfig.new(version: Buildkite::Config::RubyConfig.yjit_ruby) - assert sub.yjit_enabled? + assert_predicate sub, :yjit_enabled? end def test_yjit_enabled_default sub = Buildkite::Config::RubyConfig.new(version: Gem::Version.new("3.2")) - refute sub.yjit_enabled? + assert_not sub.yjit_enabled? end def test_build sub = Buildkite::Config::RubyConfig.new(version: Gem::Version.new("3.3"), build: false) - refute sub.build? + assert_not sub.build? end def test_build_default sub = Buildkite::Config::RubyConfig.new(version: Gem::Version.new("3.3")) - assert sub.build? + assert_predicate sub, :build? end def test_mangle_name diff --git a/test/buildkite_config/test_ruby_group.rb b/test/buildkite_config/test_ruby_group.rb index 67a6e066..1eeef89f 100644 --- a/test/buildkite_config/test_ruby_group.rb +++ b/test/buildkite_config/test_ruby_group.rb @@ -18,10 +18,10 @@ def test_ruby_group_default end end - expected = {"steps"=> - [{"label"=>"3.2", - "group"=>nil, - "steps"=>[{"label"=>"test [3.2]]}]", "command"=>["rake test"]}]}]} + expected = { "steps" => + [{ "label" => "3.2", + "group" => nil, + "steps" => [{ "label" => "test [3.2]]}]", "command" => ["rake test"] }] }] } assert_equal expected, pipeline.to_h end @@ -39,10 +39,10 @@ def test_soft_fail end end - expected = {"steps"=> - [{"label"=>"3.3", - "group"=>nil, - "steps"=>[{"label"=>"test [soft_fail]]}]", "command"=>["rake test"]}]}]} + expected = { "steps" => + [{ "label" => "3.3", + "group" => nil, + "steps" => [{ "label" => "test [soft_fail]]}]", "command" => ["rake test"] }] }] } assert_equal expected, pipeline.to_h end @@ -58,10 +58,10 @@ def test_ruby_group_config_version end end - expected = {"steps"=> - [{"label"=>"1.8.7", - "group"=>nil, - "steps"=>[{"label"=>"test", "command"=>["rake test"]}]}]} + expected = { "steps" => + [{ "label" => "1.8.7", + "group" => nil, + "steps" => [{ "label" => "test", "command" => ["rake test"] }] }] } assert_equal expected, pipeline.to_h end @@ -81,12 +81,12 @@ def test_ruby_group_sets_image_base end end - expected = {"steps"=> - [{"label"=>"2.0", - "group"=>nil, - "steps"=> - [{"label"=>"test [test_ruby_group_sets_image_base]", - "command"=>["rake test"]}]}]} + expected = { "steps" => + [{ "label" => "2.0", + "group" => nil, + "steps" => + [{ "label" => "test [test_ruby_group_sets_image_base]", + "command" => ["rake test"] }] }] } assert_equal expected, pipeline.to_h end end diff --git a/test/test_helper.rb b/test/test_helper.rb index fce8d8db..e47b2ebf 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -37,4 +37,4 @@ def build_pipeline(data) ] } end -end \ No newline at end of file +end diff --git a/update-initial-pipelines b/update-initial-pipelines index f2ac81ee..19438987 100755 --- a/update-initial-pipelines +++ b/update-initial-pipelines @@ -15,7 +15,7 @@ def update_pipeline(pipeline, configuration) resp = client.update_pipeline("rails", pipeline, { configuration: configuration }) - puts resp.steps.to_s + puts resp.steps end # Update rails/rails