Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions tasks/update_component_info.rake
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
require 'json'
require 'open3'

FIRST_TAG = '202501080'.freeze # First tag to include when regenerating
IGNORED_PLATFORMS = %w[aix solaris redhatfips windowsfips el-6 osx sles-11 windows-2012r2 ppc64le armhf i386].freeze
INCLUDED_PROJECTS = %w[agent-runtime openbolt-runtime].freeze

def run(cmd, action)
output, status = Open3.capture2e(cmd)
abort "Failed to #{action}: #{output}" unless status.success?

output
end

def platforms
# First item will be a `- Platforms` header. Also exclude
# any platforms we don't actually build for or have problems parsing.
`bundle exec vanagon list -l`.split("\n")[1..]
.reject { |p| p =~ /(#{IGNORED_PLATFORMS.join('|')})/ }
output = run('bundle exec vanagon list -l', 'list platforms')
output.split("\n")[1..]
.reject { |p| p =~ /(#{IGNORED_PLATFORMS.join('|')})/ }
end

def projects
# First item will be a `- Projects` header. Also exclude
# any projects prefixed with '_' as these are not real projects and
# are shared between projects. Also ignore any projects we don't care
# about.
`bundle exec vanagon list -r`.split("\n")[1..]
.reject { |p| p.start_with?('_') || p !~ /^(#{INCLUDED_PROJECTS.join('|')})/ }
output = run('bundle exec vanagon list -r', 'list projects')
output.split("\n")[1..]
.reject { |p| p.start_with?('_') || p !~ /^(#{INCLUDED_PROJECTS.join('|')})/ }
end

# Sometimes the version is a git ref so extract
Expand All @@ -37,7 +47,8 @@ def component_info

platforms.each do |platform|
puts " #{platform}"
platform_data = JSON.parse(`bundle exec vanagon inspect #{project} #{platform}`)
output = run("bundle exec vanagon inspect #{project} #{platform}", "inspect #{project} on #{platform}")
platform_data = JSON.parse(output)
project_data[project][platform] = platform_data.map { |h| [h['name'], h['version'] || h.dig('options', 'ref')] }.to_h
end
end
Expand Down Expand Up @@ -76,18 +87,16 @@ namespace :vox do
desc 'Regenerate component_info.json with all tags'
task :regenerate_component_info do
# Clone a copy of the repo to avoid messing up the current working dir
`git clone https://github.com/openvoxproject/puppet-runtime puppet-runtime-tmp`
run('git clone https://github.com/openvoxproject/puppet-runtime puppet-runtime-tmp', 'clone puppet-runtime repo')
begin
all_data = {}
Dir.chdir('puppet-runtime-tmp') do
`git fetch origin --tags --prune --prune-tags`
`git tag --sort=creatordate | awk '$0=="#{FIRST_TAG}"{seen=1; next} seen'`.split("\n").each do |tag|
run('git fetch origin --tags --prune --prune-tags', 'fetch tags')
output = run("git tag --sort=creatordate | awk '$0==\"#{FIRST_TAG}\"{seen=1; next} seen'", 'list tags')
output.split("\n").each do |tag|
puts "Checking out tag #{tag}..."
`git checkout #{tag}`
Bundler.with_unbundled_env do
`BUNDLER_GEMFILE=./Gemfile bundle install --path .bundle`
all_data[tag] = component_info
end
run("git checkout #{tag}", "checkout #{tag}")
all_data[tag] = component_info
end
end
# Reverse order to latest is on top
Expand Down
Loading