yast-rake 0.2.40 → 0.2.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2642c0e7364635725ef46461b0d6c816fd1ebca543b87a813292cb8b6092a392
4
- data.tar.gz: de07ea039866173b29bf17d3e505ab9d3635ff4a7b50e65c4c9ee4f8da4fdec4
3
+ metadata.gz: b131d89f00dea687fc5d44232d1cf6ce503659ca2ca810d63b17169d69eb5e00
4
+ data.tar.gz: 1e2d455ac8ca10a363b7bf89585f8bf0927dd06c94204d222a1384f421b4270d
5
5
  SHA512:
6
- metadata.gz: cd3a1697577fb14c191261d5b953e123c8cf2052ddb58388d5836f6a0477b233903aab0f58663d723a9eb692d9e3319475e4f1db9878264288b39a9e1758eee5
7
- data.tar.gz: b6153a3bfe3601cef2f3cfad9dfe899e80cbe11eb65563029a84c14a01fe9f8831fc0f8e1f270dd90975badd3abde483db0891f71ca619c5086ee653c9ef5ee1
6
+ metadata.gz: 5a83c6e94d862c23c0f04e84cdf68d48c0aa4b4f51caba4000a6f5106831097c38343b10a553fc83fd3355e37a9b719befab007656b3a1626b2364b76f8db35a
7
+ data.tar.gz: 13828bd3771752722aa0fe5eb0c7f8f305b6f447bf8f0310e71c5df33e4810d5f071fa2cdef39cbcdfc17a2eff2e9e4e12b2f37675aff1c6fbda0d5d4b1b9a24
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.40
1
+ 0.2.44
data/data/targets.yml CHANGED
@@ -85,11 +85,21 @@
85
85
  obs_project: "Devel:YaST:SLE-15-SP3"
86
86
  obs_sr_project: "SUSE:SLE-15-SP3:Update"
87
87
  obs_target: "SUSE_SLE-15-SP3_Update"
88
+ :sle15sp4:
89
+ obs_api: "https://api.suse.de/"
90
+ obs_project: "Devel:YaST:SLE-15-SP4"
91
+ obs_sr_project: "SUSE:SLE-15-SP4:Update"
92
+ obs_target: "SUSE_SLE-15-SP4_Update"
93
+ :sle15sp5:
94
+ obs_api: "https://api.suse.de/"
95
+ obs_project: "Devel:YaST:SLE-15-SP5"
96
+ obs_sr_project: "SUSE:SLE-15-SP5:Update"
97
+ obs_target: "SUSE_SLE-15-SP5_Update"
88
98
  :sle_latest:
89
99
  obs_api: "https://api.suse.de/"
90
100
  obs_project: "Devel:YaST:Head"
91
- obs_sr_project: "SUSE:SLE-15-SP3:GA"
92
- obs_target: "SUSE_SLE-15-SP3_GA"
101
+ obs_sr_project: "SUSE:SLE-15-SP4:GA"
102
+ obs_target: "SUSE_SLE-15-SP4_GA"
93
103
  :factory:
94
104
  obs_project: "YaST:Head"
95
105
  obs_sr_project: "openSUSE:Factory"
@@ -28,8 +28,7 @@ class ContainerRunner
28
28
  # @param client [String,nil] the client name, nil or empty string = find
29
29
  # the client automatically
30
30
  def run(client)
31
- image = find_image
32
- container = GithubActions::Container.new(image)
31
+ container = find_container
33
32
  container.pull
34
33
  container.start
35
34
  container.copy_current_dir
@@ -44,16 +43,16 @@ private
44
43
 
45
44
  # find the Docker image to use in the container
46
45
  # @return [String] the image name
47
- def find_image
46
+ def find_container
48
47
  # explicitly requested image
49
48
  image = ENV["DOCKER_IMAGE"]
50
- return image if image && !image.empty?
49
+ return GithubActions::Container.new(image) if image && !image.empty?
51
50
 
52
51
  # scan the Docker images used in the GitHub Actions
53
- images = workflow_images
54
- return images.first if images.size == 1
52
+ containers = workflow_containers
53
+ return containers.first if containers.size == 1
55
54
 
56
- if images.empty?
55
+ if containers.empty?
57
56
  error("No Docker image was found in the GitHub Actions")
58
57
  puts "Use DOCKER_IMAGE=<name> option for specifying the image name"
59
58
  abort
@@ -61,20 +60,36 @@ private
61
60
 
62
61
  # multiple images found
63
62
  error("Found multiple Docker images in the GitHub Actions:")
64
- error(images.inspect)
63
+ error(containers.map { |c| [c.image, c.options] })
65
64
  puts "Use DOCKER_IMAGE=<name> option for specifying the image name"
65
+ puts "and DOCKER_OPTIONS=<options> option for specifying the extra Docker"
66
+ puts "command line parameters."
66
67
  abort
67
68
  end
68
69
 
69
70
  # extract the Docker images from the GitHub Actions,
70
71
  # the duplicates are removed
71
- # @return [Array<String>] image names
72
- def workflow_images
73
- GithubActions::Workflow.read.each_with_object([]) do |workflow, images|
72
+ # @return [Array<GithubActions::Container>] image names
73
+ def workflow_containers
74
+ ret = GithubActions::Workflow.read.each_with_object([]) do |workflow, containers|
74
75
  workflow.jobs.each do |job|
75
- container = job.container
76
- images << container if container && !images.include?(container)
76
+ container_data = job.container
77
+
78
+ if container_data.is_a?(String)
79
+ containers << GithubActions::Container.new(container_data)
80
+ elsif container_data.is_a?(Hash)
81
+ # to_s converts missing options (nil) to empty options ("")
82
+ # to treat these as equal in comparison
83
+ containers << GithubActions::Container.new(
84
+ container_data["image"],
85
+ container_data["options"].to_s
86
+ )
87
+ else
88
+ abort "Unsupported container definition: #{container_data.inspect}"
89
+ end
77
90
  end
78
91
  end
92
+
93
+ ret.uniq { |c| [c.image, c.options] }
79
94
  end
80
95
  end
@@ -26,7 +26,7 @@ module GithubActions
26
26
  class Container
27
27
  include Colorizer
28
28
 
29
- attr_reader :image, :container
29
+ attr_reader :image, :options, :container
30
30
 
31
31
  # the default timeout in seconds, maximum time for the running container,
32
32
  # after the time runs out the container is automatically stopped and removed
@@ -43,8 +43,10 @@ module GithubActions
43
43
 
44
44
  # constructor
45
45
  # @param image [String] name of the Docker image to use
46
- def initialize(image)
46
+ # @param options [String, nil] extra docker options
47
+ def initialize(image, options = nil)
47
48
  @image = image
49
+ @options = options
48
50
  end
49
51
 
50
52
  # pull the Docker image, ensure that the latest version is used
@@ -73,7 +75,7 @@ module GithubActions
73
75
  end
74
76
 
75
77
  cmd = "docker create #{env_options(ENV_VARIABLES)} --rm --entrypoint " \
76
- "#{run} #{image.shellescape} #{args}"
78
+ "#{run} #{options} #{ENV["DOCKER_OPTIONS"]} #{image.shellescape} #{args}"
77
79
 
78
80
  # contains the container ID
79
81
  @container = `#{cmd}`.chomp
@@ -58,12 +58,29 @@ module GithubActions
58
58
 
59
59
  # pull the Docker image and start the container
60
60
  def start_container
61
- # prefer the custom image if requested
62
- @container = Container.new(image || job.container)
61
+ @container = find_container
63
62
  container.pull
64
63
  container.start
65
64
  end
66
65
 
66
+ # Get the container configuration
67
+ # @return [Container] container which should run the job
68
+ def find_container
69
+ # prefer the custom image if requested
70
+ image_name = if image
71
+ image
72
+ elsif job.container.is_a?(String)
73
+ job.container
74
+ elsif job.container.is_a?(Hash)
75
+ options = job.container["options"]
76
+ job.container["image"]
77
+ else
78
+ abort "Unsupported container definition: #{job.container.inspect}"
79
+ end
80
+
81
+ Container.new(image_name, options.to_s)
82
+ end
83
+
67
84
  # run a job step
68
85
  # @param step [GithubActions::Step] the step to run
69
86
  # @return [Boolean] `true` if the step succeeded, `false` otherwise
@@ -15,12 +15,24 @@
15
15
  #
16
16
  #++
17
17
 
18
+ # the default old version used
19
+ OLD_RUBOCOP_VERSION = "0.41.2"
20
+
21
+ def rubocop_version
22
+ return @rubocop_version if @rubocop_version
23
+
24
+ @rubocop_version = if File.read(".rubocop.yml").match(/rubocop-(\d+\.\d+\.\d+)/)
25
+ Regexp.last_match[1]
26
+ else
27
+ OLD_RUBOCOP_VERSION
28
+ end
29
+ end
30
+
18
31
  def rubocop_bin
19
32
  return @rubocop_bin if @rubocop_bin
20
33
  return @rubocop_bin = ENV["RUBOCOP_BIN"] if ENV["RUBOCOP_BIN"]
21
34
 
22
- version = File.read(".rubocop.yml").include?("rubocop-0.71.0") ? "0.71.0" : "0.41.2"
23
- binary = `/usr/sbin/update-alternatives --list rubocop | grep '#{version}'`.strip
35
+ binary = `/usr/sbin/update-alternatives --list rubocop | grep '#{rubocop_version}'`.strip
24
36
  if !system("which #{binary}")
25
37
  raise "cannot find proper version of rubocop binary in " \
26
38
  "'/usr/sbin/update-alternatives --list rubocop'." \
@@ -32,18 +44,26 @@ end
32
44
  # run Rubocop in parallel
33
45
  # @param params [String] optional Rubocop parameters
34
46
  def run_rubocop(params = "")
35
- # how it works:
36
- # 1) get the list of inspected files by Rubocop
37
- # 2) shuffle it randomly (better would be evenly distribute them according to
38
- # the analysis complexity but that is hard to evaluate and even simply
39
- # distributing by file size turned out to be ineffective and slower than
40
- # a simple random shuffling)
41
- # 3) pass that as input for xargs
42
- # a) use -P with number of processors to run the commands in parallel
43
- # b) use -n to set the maximum number of files per process, this number
44
- # is computed to equally distribute the files across the workers
45
- sh "#{rubocop_bin} -L | sort -R | xargs -P`nproc` -n$(expr `#{rubocop_bin} -L | wc -l` / " \
46
- "`nproc` + 1) #{rubocop_bin} #{params}"
47
+ # newer Rubocop versions support the "-P" ("--parallel") option,
48
+ # but that is not compatible with the "-a" ("--auto-correct") option
49
+ if rubocop_version != OLD_RUBOCOP_VERSION && !params.to_s.match(/-a|--auto-correct/)
50
+ sh "#{rubocop_bin} -P #{params}"
51
+ else
52
+ # for older Rubocop or auto-correct mode manually start multiple instances in parallel
53
+ #
54
+ # how it works:
55
+ # 1) get the list of inspected files by Rubocop
56
+ # 2) shuffle it randomly (better would be evenly distribute them according to
57
+ # the analysis complexity but that is hard to evaluate and even simply
58
+ # distributing by file size turned out to be ineffective and slower than
59
+ # a simple random shuffling)
60
+ # 3) pass that as input for xargs
61
+ # a) use -P with number of processors to run the commands in parallel
62
+ # b) use -n to set the maximum number of files per process, this number
63
+ # is computed to equally distribute the files across the workers
64
+ sh "#{rubocop_bin} -L | sort -R | xargs -P`nproc` -n$(expr `#{rubocop_bin} -L | wc -l` / " \
65
+ "`nproc` + 1) #{rubocop_bin} #{params}"
66
+ end
47
67
  end
48
68
 
49
69
  namespace :check do
@@ -18,12 +18,16 @@
18
18
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
19
  #++
20
20
 
21
- require_relative "../yast/tarball_server"
22
-
23
21
  # Rake task for running a source code web server,
24
22
  # designed for the `yupdate` script.
25
23
  desc "Start an HTTP server providing dynamically generated source code tarball"
26
24
  task :server, [:port] do |_task, args|
25
+ begin
26
+ require_relative "../yast/tarball_server"
27
+ rescue LoadError
28
+ abort "Webrick server is not installed, please install the webrick Ruby gem"
29
+ end
30
+
27
31
  server = Yast::TarballServer.new(args[:port])
28
32
 
29
33
  puts "Starting tarball webserver:"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yast-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.40
4
+ version: 0.2.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Reidinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packaging_rake_tasks
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.7.6.2
104
+ rubygems_version: 2.7.6.3
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Rake tasks providing basic work-flow for Yast development