Skip to content

Commit 2fd619b

Browse files
committed
[Automation] Updates download_artifacts in bumpmatrix task
This way when the task is called, the value is updated from `main` to the corresponding branch. E.g.: $ rake automation:bumpmatrix[9.6.0-SNAPSHOT] - run: rake es:download_artifacts[main] && cd elasticsearch-api && bundle exec rake test:all + run: rake es:download_artifacts[9.6] && cd elasticsearch-api && bundle exec rake test:all
1 parent 90da0bb commit 2fd619b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

rake_tasks/automation.rake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,28 @@ namespace :automation do
110110
files = gh_actions + ['.buildkite/pipeline.yml']
111111
regexp = Regexp.new(/[stack-version|STACK_VERSION]:\ ([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}?+(-SNAPSHOT)?)/)
112112
files.each do |file|
113+
next if file.match?('docs')
114+
115+
current_branch = `git rev-parse --abbrev-ref HEAD | tr -d '\n'`
116+
version_branch = version.to_s.match(/([0-9]+\.[0-9]+)\.[0-9]+.*/)[1]
113117
content = File.read(file)
114118
if file == '.buildkite/pipeline.yml'
115119
require 'yaml'
116120
yaml = YAML.safe_load(content)
117121
yaml_tests_branch = yaml['steps'][0]['env']['ES_YAML_TESTS_BRANCH'].to_s
118-
current_branch = `git rev-parse --abbrev-ref HEAD | tr -d '\n'`
119-
120122
if current_branch == 'main'
121123
old = content.match(/STACK_VERSION: (.*)/)[0]
122124
new = "STACK_VERSION: #{version}"
123125
content.gsub!(new, old)
124126
else
125-
branch = version.to_s.match(/([0-9]+\.[0-9]+)\.[0-9]+.*/)[1]
126-
content.gsub!(/(ES_YAML_TESTS_BRANCH: )#{yaml_tests_branch}/, "\\1#{branch}")
127-
puts "[#{yaml_tests_branch}] -> [#{branch}] in #{file.gsub('./', '')}"
127+
content.gsub!(/(ES_YAML_TESTS_BRANCH: )#{yaml_tests_branch}/, "\\1#{version_branch}")
128+
puts "[#{yaml_tests_branch}] -> [#{version_branch}] in #{file.gsub('./', '')}"
128129
end
129130
File.open(file, 'w') { |f| f.puts content }
130131
end
132+
if content.match?('download_artifacts') && current_branch != 'main'
133+
content.gsub!('download_artifacts[main]', "download_artifacts[#{version_branch}]")
134+
end
131135
match = content.match(regexp)
132136
next if match.nil?
133137

0 commit comments

Comments
 (0)