yast-rake 0.2.43 → 0.2.46

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 183bdc451acadf652d5ef8d5749b166770f3664b2f73139cadab86f59b35f9e7
4
- data.tar.gz: 86a255dfe87bb4b38128568e04752e4a111c2840bbd880499a12f6f0447e3e71
3
+ metadata.gz: ac63a47eacc8d5837b6ec2ca69605c214fed661530fbae576d154706d8a1317f
4
+ data.tar.gz: ef9b8e4ebd0846d0d9f2d72c3b17e1176d4afd674156dbfeb5f39339b13a0488
5
5
  SHA512:
6
- metadata.gz: 778c1d1c7e5258ce439e0e6d16ec01b0eb20cbb1ac4a7260f497a1256b189865d5d594ba4f1dbf18b9dc6accbaf2430ccb4f3510b19c7a65ae0b56ff5a06c8c0
7
- data.tar.gz: 848c641d6d94d8b40a610d575b4fc0f63df0942b5fe0987663511d11761278ddb560e8e86d1a20a19b3b5529be2b012c9cc4f7d593934613e6832366e1eaaa42
6
+ metadata.gz: cafea33f6f6a17c45b1eae38368536d5f283f939118ab5fd6d0af7dd1bc8c2cf59b75aa8b27dca6ba1100c04417ae7ea548a2a16075d3484a6dcd73aeb07c05e
7
+ data.tar.gz: a7c9caac9a4c08d87aa8371459cec1d4c06c26bf7ee2c2135337e48c74a3a9d3914a043978ad7f23666fa917c7fe33f517bc9c6ea0439510b286cc6e0c63eeac
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.43
1
+ 0.2.46
data/data/targets.yml CHANGED
@@ -98,8 +98,8 @@
98
98
  :sle_latest:
99
99
  obs_api: "https://api.suse.de/"
100
100
  obs_project: "Devel:YaST:Head"
101
- obs_sr_project: "SUSE:SLE-15-SP4:GA"
102
- obs_target: "SUSE_SLE-15-SP4_GA"
101
+ obs_sr_project: "SUSE:SLE-15-SP5:GA"
102
+ obs_target: "SUSE_SLE-15-SP5_GA"
103
103
  :factory:
104
104
  obs_project: "YaST:Head"
105
105
  obs_sr_project: "openSUSE:Factory"
@@ -22,7 +22,7 @@ module GithubActions
22
22
  # Github Actions job
23
23
  # @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
24
24
  class Job
25
- attr_reader :name, :steps, :runs_on, :container, :workflow
25
+ attr_reader :name, :steps, :runs_on, :container, :workflow, :matrix
26
26
 
27
27
  # @param name [String] name of the job
28
28
  # @param data [Hash] data from the workflow YAML file
@@ -32,6 +32,7 @@ module GithubActions
32
32
  @runs_on = data["runs-on"]
33
33
  @container = data["container"]
34
34
  @workflow = workflow
35
+ @matrix = data.fetch("strategy", {})["matrix"]
35
36
 
36
37
  @steps = data["steps"].map do |step|
37
38
  Step.new(self, step)
@@ -78,7 +78,23 @@ module GithubActions
78
78
  abort "Unsupported container definition: #{job.container.inspect}"
79
79
  end
80
80
 
81
- Container.new(image_name, options.to_s)
81
+ Container.new(expand_name(image_name), options.to_s)
82
+ end
83
+
84
+ # replace the ${{ matrix.<value> }} placeholders in the image name
85
+ #
86
+ # @param image_name [String] name of the Docker image
87
+ # @return [String] name with replaced values
88
+ def expand_name(image_name)
89
+ image_name.gsub(/\$\{\{\s*matrix\.[^}]*\}\}/) do |subst|
90
+ name = /\$\{\{\s*matrix\.([^}]*)\}\}/.match(subst)[1].strip
91
+ value = job.matrix ? job.matrix[name] : subst
92
+
93
+ # if the value is an Array use the first value by default
94
+ replacement = value.is_a?(Array) ? value.first : value.to_s
95
+ puts "Using ${{matrix.#{name}}} value: #{replacement.inspect}"
96
+ replacement
97
+ end
82
98
  end
83
99
 
84
100
  # run a job step
@@ -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
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.43
4
+ version: 0.2.46
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-11-29 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packaging_rake_tasks