4 Star 18 Fork 184

Fengguang/lkp-tests

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build-single 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
Fengguang 提交于 2024-05-18 17:27 +08:00 . Merge files from eulermaker
#! /usr/bin/env ruby
# frozen_string_literal: true
LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.dirname(File.realpath($PROGRAM_NAME))))
require 'json'
require 'optparse'
require "#{LKP_SRC}/sbin/cli/ccb_common"
require "#{LKP_SRC}/sbin/cli/ccb_api_client"
json_path = nil
yaml_path = nil
options = OptionParser.new do |opts|
opts.banner = 'Usage: ccb build-single key1=val1 -j JSON|-y YAML'
opts.separator ' eg.1: ccb build-single os_project=openEuler:Mainline packages=gcc -j JSON|-y YAML'
opts.separator ''
opts.on('-j', '--json <path>', 'json file') do |j|
json_path = j
end
opts.on('-y', '--yaml <path>', 'yaml file') do |y|
yaml_path = y
end
opts.on('-h', '--help', 'show this message') do
puts options
exit
end
end
options.parse!(ARGV)
if ARGV.empty?
puts(options)
exit
end
def build_single_response(os_project, jwt, hash, my_config)
ccb_api_client = CcbApiClient.new(my_config['GATEWAY_IP'], my_config['GATEWAY_PORT'])
response = ccb_api_client.build_single(jwt, os_project, hash.to_json)
response = JSON.parse(response)
end
def build_single_result(os_project, hash, my_config)
jwt = load_jwt?
response = build_single_response(os_project, jwt, hash, my_config)
if response.has_key?('status_code') && (response['status_code'] == 401)
# jwt may timeout and retry once
jwt = load_jwt?(force_update = true)
response = build_single_response(os_project, jwt, hash, my_config)
end
check_return_code(response)
puts JSON.pretty_generate response
end
hash = get_no_option_paras!(ARGV, json_path, yaml_path)[0]
my_config = load_my_config
os_project = hash['os_project'] || ''
build_id = hash['build_id'] || ''
packages = hash['packages'] || ''
if os_project.empty? || packages.empty?
puts "Both os_project and packages can't be empty"
exit
end
required_keys = %w[GATEWAY_IP GATEWAY_PORT]
required_keys.each do |var|
unless my_config.has_key?(var) && !my_config[var].nil?
puts "config #{var} not found"
exit
end
end
build_single_result(os_project, hash, my_config)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wu_fengguang/lkp-tests.git
git@gitee.com:wu_fengguang/lkp-tests.git
wu_fengguang
lkp-tests
lkp-tests
master

搜索帮助