yast-rake 0.2.41 → 0.2.42

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: 1ea95f9f06d6f3ab9b3a4e5078bf6ac60a87379540571f3c5b99bdea42dfb83c
4
- data.tar.gz: 2e15ce0eb612f90be1ae9f65906283ddfaf0d3f6159fe816954a4ceb5a22c4cc
3
+ metadata.gz: fb204b6229ee0b7fa908d64fd928e5f071e1f29f11ffb991d051c2f247d8bc02
4
+ data.tar.gz: 9c49cd7705d06f94a2eaf8dc2e15add41bab65dccb0cd4fa4bcbd853153f15d5
5
5
  SHA512:
6
- metadata.gz: 9cb29be7fb662e4c53e693efe4c907183210b9b1fb6f7abbb941a791001b64e0c4c7a1aab312d83846ae4aac73755d64957136a36de9e4861ec4cd5fb43184b5
7
- data.tar.gz: ac4dbcc62bcb8a0497205a24f5aac12d6d30137f1832769576e3ac8df5654db9fb3aaa179ab3348b6f6be6ebd427e9264d65a1fb30c99606a1e12eff54efa87b
6
+ metadata.gz: 13f7ba78e61769db2e6eb702631ce6caa25e0e65c355dfd060fb71b10a1e1077a158d4387841a1c7893631e3af9e5784ca0886ef057314047872c21c928dadca
7
+ data.tar.gz: acf04f3a336c6d0f2897dbfee0b064f0c1a5dd74b46213541d778f35767cae04a433f08fb0e5d7ea9278a17d814e48dff790443fc9955fca53f85a5d4281ce73
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.41
1
+ 0.2.42
@@ -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
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.41
4
+ version: 0.2.42
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-06-24 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packaging_rake_tasks