Skip to content

Commit

Permalink
Remove duplicate pipeline definition for nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
zzak authored and rafaelfranca committed Apr 15, 2024
1 parent 398a43c commit 046b28c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 188 deletions.
8 changes: 3 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ require "minitest/test_task"
Minitest::TestTask.create
task default: [:test]

task :diff, [:nightly] => [:buildkite_config, :rails] do |_, args|
args.with_defaults(nightly: false)

diff = Buildkite::Config::Diff.compare(nightly: args[:nightly])
annotate = Buildkite::Config::Annotate.new(diff, nightly: args[:nightly])
task diff: [:buildkite_config, :rails] do
diff = Buildkite::Config::Diff.compare
annotate = Buildkite::Config::Annotate.new(diff)
puts annotate.plan
end

Expand Down
4 changes: 3 additions & 1 deletion buildkite-config-initial-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ steps:
fi
label: ":writing_hand: buildkite-config: annotate nightly diff"
env:
RAILS_CI_NIGHTLY: true
BUNDLE_FROZEN: true
ANNOTATE_COMMAND: >-
docker run --rm
-v "$$PWD":/app:ro -w /app
-v "$$PWD/tmp":/app/tmp:rw
-e RAILS_CI_NIGHTLY
-e BUNDLE_FROZEN
ruby:latest
./pipeline-annotate --nightly
./pipeline-annotate
- group:
label: ":rails: Rails CI"
Expand Down
4 changes: 2 additions & 2 deletions lib/buildkite/config/annotate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Buildkite::Config
class Annotate
def initialize(diff, nightly: false)
def initialize(diff)
@diff = diff
@nightly = nightly
@nightly = ENV.has_key?("RAILS_CI_NIGHTLY")
end

def plan
Expand Down
4 changes: 4 additions & 0 deletions lib/buildkite/config/build_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def build_context
end
end

def nightly?
ENV.has_key?("RAILS_CI_NIGHTLY")
end

def rails_root
Pathname.pwd
end
Expand Down
9 changes: 4 additions & 5 deletions lib/buildkite/config/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

module Buildkite::Config
module Diff
def self.compare(nightly: false)
head = generated_pipeline(Dir.pwd, nightly: nightly)
main = generated_pipeline(File.expand_path("tmp/buildkite-config", Dir.pwd), nightly: nightly)
def self.compare
head = generated_pipeline(Dir.pwd)
main = generated_pipeline(File.expand_path("tmp/buildkite-config", Dir.pwd))
Diffy::Diff.new(main, head, context: 4)
end

def self.generated_pipeline(repo, nightly: false)
def self.generated_pipeline(repo)
File.symlink(repo, "tmp/rails/.buildkite")

command = ["ruby", ".buildkite/pipeline-generate"]

pipeline = "rails-ci"
pipeline += "-nightly" if nightly
command.push(pipeline)

Dir.chdir("tmp/rails") do
Expand Down
4 changes: 1 addition & 3 deletions pipeline-annotate
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

nightly = ARGV.include?("--nightly")

def run(cmd, value = false)
io = IO.popen(cmd)
output = io.read
Expand All @@ -15,6 +13,6 @@ end

run "bundle install"

annotation = run "bundle exec rake diff#{"[true]" if nightly}", true
annotation = run "bundle exec rake diff", true

puts annotation
170 changes: 0 additions & 170 deletions pipelines/rails-ci-nightly/pipeline.rb

This file was deleted.

9 changes: 8 additions & 1 deletion pipelines/rails-ci/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
plugin :docker_compose, "docker-compose#v4.16.0"
plugin :artifacts, "artifacts#v1.9.3"

build_context.setup_rubies %w(2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3)
if build_context.nightly?
build_context.rubies << Buildkite::Config::RubyConfig.master_ruby
build_context.rubies << Buildkite::Config::RubyConfig.yjit_ruby
build_context.rubies << Buildkite::Config::RubyConfig.master_debug_ruby
build_context.default_ruby = Buildkite::Config::RubyConfig.master_ruby
else
build_context.setup_rubies %w(2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3)
end

group do
label "build"
Expand Down
4 changes: 3 additions & 1 deletion rails-nightly-initial-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ steps:
- artifacts#v1.2.0:
upload: [".buildkite/**/*", ".dockerignore"]
env:
RAILS_CI_NIGHTLY: true
BUNDLE_FROZEN: true
PIPELINE_COMMAND: >-
docker run --rm
-v "$$PWD":/app:ro -w /app
-e RAILS_CI_NIGHTLY
-e CI
-e BUILDKITE
-e BUILDKITE_AGENT_META_DATA_QUEUE
Expand All @@ -79,7 +81,7 @@ steps:
-e RUN_QUEUE
-e QUEUE
ruby:latest
.buildkite/pipeline-generate rails-ci-nightly |
.buildkite/pipeline-generate rails-ci |
buildkite-agent pipeline upload
timeout_in_minutes: 5
agents:
Expand Down

0 comments on commit 046b28c

Please sign in to comment.