yast-rake 0.2.36 → 0.2.41

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: 604fa7a174e99d46c9d37b8ea3fff3d2d94ce7b6344a1d1c80bdec247203a56c
4
- data.tar.gz: a8aa455360687b68e4879732c8e28bc6e430e68dd7a3e9cec14931c10d3c0c05
3
+ metadata.gz: 1ea95f9f06d6f3ab9b3a4e5078bf6ac60a87379540571f3c5b99bdea42dfb83c
4
+ data.tar.gz: 2e15ce0eb612f90be1ae9f65906283ddfaf0d3f6159fe816954a4ceb5a22c4cc
5
5
  SHA512:
6
- metadata.gz: 176ca7514b8829e75d7f73d63d5279b1ac7eada517595db0a44689a84c21d71a4089136ac5cc062b0b828bade746292acb8f555248e8e24770c1d393690ce9b7
7
- data.tar.gz: 623c0548088ad30f2c7c090444df16ce266ebfa09428b59ae52e4bfd3f4925e78430b3a4a908298dea1b331e08733fa023b0f068b19801754c1a761acaf1287b
6
+ metadata.gz: 9cb29be7fb662e4c53e693efe4c907183210b9b1fb6f7abbb941a791001b64e0c4c7a1aab312d83846ae4aac73755d64957136a36de9e4861ec4cd5fb43184b5
7
+ data.tar.gz: ac4dbcc62bcb8a0497205a24f5aac12d6d30137f1832769576e3ac8df5654db9fb3aaa179ab3348b6f6be6ebd427e9264d65a1fb30c99606a1e12eff54efa87b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.36
1
+ 0.2.41
data/data/index.html ADDED
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <!-- This is a simple main page for the "rake server" task. -->
3
+ <html>
4
+ <head>
5
+ <title>Source Code Tarball Server</title>
6
+ </head>
7
+ <body>
8
+
9
+ <h1>Source Code Tarball Server</h1>
10
+ <p>This server provides dynamically generated source code tarballs.</p>
11
+
12
+ <h2>Supported URL Paths</h2>
13
+ <p>
14
+ <ul>
15
+ <li>
16
+ <b><a href = "/archive/current.tar.gz">/archive/current.tar.gz</a></b>
17
+ - dynamically generated tarball with the current source files
18
+ </li>
19
+ <li>
20
+ <b><a href = "/servers/index.json">/servers/index.json</a></b>
21
+ - index of other running servers on the machine
22
+ </li>
23
+ </ul>
24
+ </p>
25
+
26
+ </body>
27
+ </html>
data/data/targets.yml CHANGED
@@ -80,11 +80,26 @@
80
80
  obs_project: "Devel:YaST:SLE-15-SP2"
81
81
  obs_sr_project: "SUSE:SLE-15-SP2:Update"
82
82
  obs_target: "SUSE_SLE-15-SP2_Update"
83
+ :sle15sp3:
84
+ obs_api: "https://api.suse.de/"
85
+ obs_project: "Devel:YaST:SLE-15-SP3"
86
+ obs_sr_project: "SUSE:SLE-15-SP3:Update"
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"
83
98
  :sle_latest:
84
99
  obs_api: "https://api.suse.de/"
85
100
  obs_project: "Devel:YaST:Head"
86
- obs_sr_project: "SUSE:SLE-15-SP2:GA"
87
- obs_target: "SUSE_SLE-15-SP2_GA"
101
+ obs_sr_project: "SUSE:SLE-15-SP4:GA"
102
+ obs_target: "SUSE_SLE-15-SP4_GA"
88
103
  :factory:
89
104
  obs_project: "YaST:Head"
90
105
  obs_sr_project: "openSUSE:Factory"
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2021 SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require_relative "github_actions/tasks"
22
+
23
+ # tasks related to GitHub Actions (https://docs.github.com/en/actions)
24
+ namespace :actions do
25
+ desc "List the GitHub Action jobs"
26
+ task :list do
27
+ GithubActions::Tasks::List.new.run
28
+ end
29
+
30
+ desc "Display GitHub Action job details"
31
+ task :details do
32
+ GithubActions::Tasks::Details.new.run
33
+ end
34
+
35
+ desc "Run locally the specified GitHub Action job (all jobs if \"job\" is empty)"
36
+ task :run, [:job] do |_task, args|
37
+ name = args[:job]
38
+ if name.nil? || name.empty?
39
+ GithubActions::Tasks::RunAll.new.run
40
+ else
41
+ GithubActions::Tasks::Run.new(name).run
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2021 SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require_relative "github_actions/github_actions"
22
+
23
+ # Run a client in Docker container
24
+ class ContainerRunner
25
+ include GithubActions::Colorizer
26
+
27
+ # start a container, copy the sources there and run "rake run"
28
+ # @param client [String,nil] the client name, nil or empty string = find
29
+ # the client automatically
30
+ def run(client)
31
+ image = find_image
32
+ container = GithubActions::Container.new(image)
33
+ container.pull
34
+ container.start
35
+ container.copy_current_dir
36
+
37
+ cmd = client ? "rake run[#{client}]" : "rake run"
38
+ container.run(cmd)
39
+
40
+ container.stop
41
+ end
42
+
43
+ private
44
+
45
+ # find the Docker image to use in the container
46
+ # @return [String] the image name
47
+ def find_image
48
+ # explicitly requested image
49
+ image = ENV["DOCKER_IMAGE"]
50
+ return image if image && !image.empty?
51
+
52
+ # scan the Docker images used in the GitHub Actions
53
+ images = workflow_images
54
+ return images.first if images.size == 1
55
+
56
+ if images.empty?
57
+ error("No Docker image was found in the GitHub Actions")
58
+ puts "Use DOCKER_IMAGE=<name> option for specifying the image name"
59
+ abort
60
+ end
61
+
62
+ # multiple images found
63
+ error("Found multiple Docker images in the GitHub Actions:")
64
+ error(images.inspect)
65
+ puts "Use DOCKER_IMAGE=<name> option for specifying the image name"
66
+ abort
67
+ end
68
+
69
+ # extract the Docker images from the GitHub Actions,
70
+ # the duplicates are removed
71
+ # @return [Array<String>] image names
72
+ def workflow_images
73
+ GithubActions::Workflow.read.each_with_object([]) do |workflow, images|
74
+ workflow.jobs.each do |job|
75
+ container = job.container
76
+ images << container if container && !images.include?(container)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2021 SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require_relative "github_actions/colorizer"
22
+ require_relative "github_actions/container"
23
+ require_relative "github_actions/job"
24
+ require_relative "github_actions/job_runner"
25
+ require_relative "github_actions/step"
26
+ require_relative "github_actions/workflow"
27
+
28
+ # classes for running the Github Actions locally
29
+ module GithubActions
30
+ # regexps for some special actions which need to be handled differently
31
+ CHECKOUT_ACTION = /\Aactions\/checkout(|@.*)\z/.freeze
32
+ COVERALLS_ACTION = /\Acoverallsapp\/github-action(|@.*)\z/.freeze
33
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2021 SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ module GithubActions
22
+ # helper methods for colorizing output, if the "rainbow" colorizing gem
23
+ # is not installed then it prints the original messages without any colorizing
24
+ module Colorizer
25
+ # print an error
26
+ # @param msg [Object] the text to print
27
+ def error(msg)
28
+ print_colored(msg, :red)
29
+ end
30
+
31
+ # print a success message
32
+ # @param msg [Object] the text to print
33
+ def success(msg)
34
+ print_colored(msg, :green)
35
+ end
36
+
37
+ # print a warning
38
+ # @param msg [Object] the text to print
39
+ def warning(msg)
40
+ print_colored(msg, :magenta)
41
+ end
42
+
43
+ # print a message
44
+ # @param msg [Object] the text to print
45
+ def info(msg)
46
+ print_colored(msg, :cyan)
47
+ end
48
+
49
+ # print the progress status
50
+ # @param msg [Object] the text to print
51
+ def stage(msg)
52
+ print_colored(msg, :yellow)
53
+ end
54
+
55
+ private
56
+
57
+ # helper for printing the text
58
+ # @param msg [Object] the text to print
59
+ # @param color [Symbol] the text color
60
+ def print_colored(msg, color)
61
+ puts rainbow? ? Rainbow(msg).color(color) : msg
62
+ end
63
+
64
+ # load the Rainbow colorizing library if present
65
+ # see https://github.com/sickill/rainbow
66
+ # @return Boolean `true` if Rainbow was successfully loaded, `false` otherwise
67
+ def rainbow?
68
+ return @rainbow_present unless @rainbow_present.nil?
69
+
70
+ begin
71
+ require "rainbow"
72
+ @rainbow_present = true
73
+ rescue LoadError
74
+ @rainbow_present = false
75
+ end
76
+
77
+ @rainbow_present
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2021 SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require "English"
22
+ require "shellwords"
23
+
24
+ module GithubActions
25
+ # Manage a Docker container
26
+ class Container
27
+ include Colorizer
28
+
29
+ attr_reader :image, :container
30
+
31
+ # the default timeout in seconds, maximum time for the running container,
32
+ # after the time runs out the container is automatically stopped and removed
33
+ # unless `KEEP_CONTAINER` option is set
34
+ TIMEOUT = 3600
35
+
36
+ # the default environment variables in the container
37
+ ENV_VARIABLES = {
38
+ # this is a CI environment
39
+ "CI" => "true",
40
+ # skip the modified check in the "rake osc:build" task
41
+ "CHECK_MODIFIED" => "0"
42
+ }.freeze
43
+
44
+ # constructor
45
+ # @param image [String] name of the Docker image to use
46
+ def initialize(image)
47
+ @image = image
48
+ end
49
+
50
+ # pull the Docker image, ensure that the latest version is used
51
+ def pull
52
+ stage("Pulling the #{image} image...")
53
+ # if the latest image is already present it does nothing
54
+ system("docker pull #{image.shellescape}")
55
+ end
56
+
57
+ # start the container, runs "docker create" and "docker start"
58
+ def start
59
+ stage("Starting the container...")
60
+
61
+ # define the initial command for the container to start
62
+ if keep_container?
63
+ # running "tail -f /dev/null" does nothing and gets stuck forever,
64
+ # this ensures the container keeps running and we can execute
65
+ # the other commands there via "docker exec"
66
+ run = "tail"
67
+ args = "-f /dev/null"
68
+ else
69
+ # the "sleep" command ensures the container shuts down automatically after
70
+ # the timeout (to abort frozen jobs or avoid hanging containers after a crash)
71
+ run = "sleep"
72
+ args = TIMEOUT
73
+ end
74
+
75
+ cmd = "docker create #{env_options(ENV_VARIABLES)} --rm --entrypoint " \
76
+ "#{run} #{image.shellescape} #{args}"
77
+
78
+ # contains the container ID
79
+ @container = `#{cmd}`.chomp
80
+ system("docker start #{container.shellescape} > /dev/null")
81
+ end
82
+
83
+ # stop and remove the container from the system, runs "docker rm"
84
+ def stop
85
+ if keep_container?
86
+ print_container_usage
87
+ else
88
+ stage("Stopping the container...")
89
+ system("docker rm --force #{container.shellescape} > /dev/null")
90
+ end
91
+ end
92
+
93
+ # run a command in the container, runs "docker exec"
94
+ # the command is executed in a shell, so shell metacharacters like "&&"
95
+ # can be used to join several commands
96
+ # @param cmd [String] the command to run, it is passed to a shell to it might
97
+ # contain multiple commands or shell meta characters
98
+ # @param env [Hash] optional environment variables (with mapping "name" => "value")
99
+ # @return [Boolean] `true` if the command succeeded (exit status 0),
100
+ # `false` otherwise
101
+ def run(cmd, env = {})
102
+ stage("Running command: #{cmd}")
103
+ system("docker exec -it #{env_options(env)} #{container.shellescape} " \
104
+ "sh -c #{cmd.shellescape}")
105
+ $CHILD_STATUS.success?
106
+ end
107
+
108
+ # get the current working directory in the container
109
+ # @return [String] the path
110
+ def cwd
111
+ `docker exec #{container.shellescape} pwd`.chomp
112
+ end
113
+
114
+ # copy the files from host into the container
115
+ # @param from [String] the source path, if it is a directory all content
116
+ # is copied (including subdirectories)
117
+ # @param to [String] the target location in the container
118
+ def copy_files(from, to)
119
+ stage("Copying #{from} to #{to} in the container...")
120
+
121
+ if File.directory?(from)
122
+ # Dir.children is similar to Dir.entries but it omits the "." and ".." values
123
+ Dir.children(from).each do |f|
124
+ system("docker cp #{f.shellescape} #{container.shellescape}:#{to.shellescape}")
125
+ end
126
+ else
127
+ system("docker cp #{from.shellescape} #{container.shellescape}:#{to.shellescape}")
128
+ end
129
+ end
130
+
131
+ # copy the current directory to the current directory in the container
132
+ def copy_current_dir
133
+ copy_files(Dir.pwd, cwd)
134
+ end
135
+
136
+ private
137
+
138
+ # should we keep the container at the end or remove it?
139
+ def keep_container?
140
+ ENV["KEEP_CONTAINER"] == "1" || ENV["KEEP_CONTAINER"] == "true"
141
+ end
142
+
143
+ # when we keep the container running print some hints how to use it
144
+ def print_container_usage
145
+ warning("The Docker container is still running!")
146
+ puts "Use this command to connect to it:"
147
+ # docker accepts shortened IDs, make the commands shorter
148
+ info(" docker exec -it #{container[0..16]} bash")
149
+ puts "To stop and remove the container run:"
150
+ info(" docker rm -f #{container[0..16]}")
151
+ end
152
+
153
+ # build the docker environment command line options
154
+ # @param mapping [Hash] environment variables
155
+ # @return [String] the built Docker options
156
+ def env_options(mapping)
157
+ mapping.map do |name, value|
158
+ "-e #{name.shellescape}=#{value.shellescape}"
159
+ end.join(" ")
160
+ end
161
+ end
162
+ end