foreman_openbolt 0.1.1 → 1.1.0
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 +4 -4
- data/README.md +297 -17
- data/Rakefile +17 -93
- data/app/controllers/foreman_openbolt/task_controller.rb +61 -49
- data/app/lib/actions/foreman_openbolt/cleanup_proxy_artifacts.rb +11 -10
- data/app/lib/actions/foreman_openbolt/poll_task_status.rb +70 -60
- data/app/models/foreman_openbolt/task_job.rb +16 -17
- data/config/routes.rb +0 -1
- data/lib/foreman_openbolt/engine.rb +11 -11
- data/lib/foreman_openbolt/version.rb +1 -1
- data/lib/proxy_api/openbolt.rb +25 -9
- data/lib/tasks/foreman_openbolt_tasks.rake +1 -22
- data/locale/gemspec.rb +1 -1
- data/package.json +11 -15
- data/webpack/__mocks__/foremanReact/common/I18n.js +15 -0
- data/webpack/__mocks__/foremanReact/components/ToastsList/index.js +6 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +11 -0
- data/webpack/src/Components/LaunchTask/FieldTable.js +8 -5
- data/webpack/src/Components/LaunchTask/HostSelector/SearchSelect.js +74 -62
- data/webpack/src/Components/LaunchTask/HostSelector/SelectedChips.js +11 -13
- data/webpack/src/Components/LaunchTask/HostSelector/index.js +28 -33
- data/webpack/src/Components/LaunchTask/OpenBoltOptionsSection.js +3 -2
- data/webpack/src/Components/LaunchTask/ParameterField.js +2 -0
- data/webpack/src/Components/LaunchTask/SmartProxySelect.js +2 -1
- data/webpack/src/Components/LaunchTask/TaskSelect.js +3 -3
- data/webpack/src/Components/LaunchTask/__tests__/EmptyContent.test.js +10 -0
- data/webpack/src/Components/LaunchTask/__tests__/LaunchTask.test.js +83 -0
- data/webpack/src/Components/LaunchTask/__tests__/ParameterField.test.js +86 -0
- data/webpack/src/Components/LaunchTask/__tests__/ParametersSection.test.js +50 -0
- data/webpack/src/Components/LaunchTask/__tests__/SmartProxySelect.test.js +63 -0
- data/webpack/src/Components/LaunchTask/__tests__/TaskSelect.test.js +39 -0
- data/webpack/src/Components/LaunchTask/hooks/__tests__/useOpenBoltOptions.test.js +90 -0
- data/webpack/src/Components/LaunchTask/hooks/__tests__/useSmartProxies.test.js +69 -0
- data/webpack/src/Components/LaunchTask/hooks/__tests__/useTasksData.test.js +103 -0
- data/webpack/src/Components/LaunchTask/hooks/useOpenBoltOptions.js +9 -11
- data/webpack/src/Components/LaunchTask/hooks/useSmartProxies.js +12 -13
- data/webpack/src/Components/LaunchTask/hooks/useTasksData.js +6 -13
- data/webpack/src/Components/LaunchTask/index.js +9 -27
- data/webpack/src/Components/TaskExecution/ExecutionDetails.js +29 -29
- data/webpack/src/Components/TaskExecution/ExecutionDisplay.js +9 -10
- data/webpack/src/Components/TaskExecution/LoadingIndicator.js +7 -2
- data/webpack/src/Components/TaskExecution/ResultDisplay.js +13 -17
- data/webpack/src/Components/TaskExecution/TaskDetails.js +58 -67
- data/webpack/src/Components/TaskExecution/__tests__/ExecutionDetails.test.js +47 -0
- data/webpack/src/Components/TaskExecution/__tests__/ExecutionDisplay.test.js +29 -0
- data/webpack/src/Components/TaskExecution/__tests__/LoadingIndicator.test.js +25 -0
- data/webpack/src/Components/TaskExecution/__tests__/ResultDisplay.test.js +28 -0
- data/webpack/src/Components/TaskExecution/__tests__/TaskDetails.test.js +38 -0
- data/webpack/src/Components/TaskExecution/__tests__/TaskExecution.test.js +80 -0
- data/webpack/src/Components/TaskExecution/hooks/__tests__/useJobPolling.test.js +177 -0
- data/webpack/src/Components/TaskExecution/hooks/useJobPolling.js +34 -33
- data/webpack/src/Components/TaskExecution/index.js +10 -12
- data/webpack/src/Components/TaskHistory/TaskPopover.js +9 -12
- data/webpack/src/Components/TaskHistory/__tests__/TaskHistory.test.js +109 -0
- data/webpack/src/Components/TaskHistory/__tests__/TaskPopover.test.js +26 -0
- data/webpack/src/Components/TaskHistory/index.js +21 -29
- data/webpack/src/Components/common/HostsPopover.js +12 -3
- data/webpack/src/Components/common/__tests__/HostsPopover.test.js +20 -0
- data/webpack/src/Components/common/__tests__/helpers.test.js +135 -0
- data/webpack/src/Components/common/helpers.js +34 -5
- data/webpack/test_setup.js +34 -11
- metadata +37 -91
- data/test/factories/foreman_openbolt_factories.rb +0 -7
- data/test/test_plugin_helper.rb +0 -8
- data/test/unit/foreman_openbolt_test.rb +0 -13
- data/webpack/global_test_setup.js +0 -11
- data/webpack/webpack.config.js +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19c30e74d249eacf814179dac70292c3e42182b39477cab06adf304885298587
|
|
4
|
+
data.tar.gz: bbc28cd01be2a7f100d1ec015c92aff471584e7445468184e7ef1bd97c485b27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b40018885e22e7d3690b13c524787dadbf8ad2fe8fa5af2e82e5eb4fd99d65a56a7015cbd02717573c5cd12395d1a157130c16257fa94a5b3f28ef78470fd55
|
|
7
|
+
data.tar.gz: 753476abd475f3de15ad928874048c9772d4a55534129f35b9d4c032beb5c0f787e8ba6aed271763bb59d66383986360cbf8d0438618aefdb9f2175790b959c7
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# foreman-openbolt
|
|
2
2
|
|
|
3
3
|
[](https://github.com/overlookinfra/foreman_openbolt/blob/master/LICENSE)
|
|
4
4
|
[](https://github.com/overlookinfra/foreman_openbolt/actions/workflows/test.yml)
|
|
@@ -6,28 +6,234 @@
|
|
|
6
6
|
[](https://rubygems.org/gems/foreman_openbolt)
|
|
7
7
|
[](https://rubygems.org/gems/foreman_openbolt)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Bringing OpenBolt Task & Plans into Foreman!
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
[OpenBolt](https://github.com/OpenVoxProject/openbolt) is the open source successor of [Bolt](https://github.com/puppetlabs/bolt) by [Perforce](https://www.perforce.com/).
|
|
14
|
+
OpenBolt supports running Tasks or Plans against various targets via different transport protocols.
|
|
15
|
+
OpenBolt and Bolt are CLI-only tools.
|
|
16
|
+
They connect to the targets from a central location (usually a jumpnode or workstation).
|
|
17
|
+
|
|
18
|
+
## Tasks
|
|
19
|
+
|
|
20
|
+
Tasks are little executeable things, like binaries or scripts.
|
|
21
|
+
They are enhanced with a metadata file, which describes input and output parameters.
|
|
22
|
+
A task is copied to N targets and executed there.
|
|
23
|
+
|
|
24
|
+
## Plans
|
|
25
|
+
|
|
26
|
+
Plans provide complex logic options, written in Puppet DSL.
|
|
27
|
+
Besides the usual Puppet DSL functions, it's also possible to execute tasks and evaluate their responses.
|
|
28
|
+
|
|
29
|
+
## OpenBolt in Foreman!
|
|
30
|
+
|
|
31
|
+
OpenBolt is the Ansible counterpart and OpenBolt is Puppet "native".
|
|
32
|
+
OpenBolt and Puppet integrate very well together and OpenBolt can reuse your existing Puppet code.
|
|
33
|
+
Since OpenBolt is a CLI only application, and most Puppet users run Foreman anyways, it made sense to integrate OpenBolt into Foreman, instead of writing another web UI.
|
|
10
34
|
|
|
11
35
|
## Installation
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
The installation is split into four parts:
|
|
38
|
+
|
|
39
|
+
* Foreman Plugin
|
|
40
|
+
* Foreman Smartproxy Plugin
|
|
41
|
+
* OpenBolt
|
|
42
|
+
* Code Deployment
|
|
43
|
+
|
|
44
|
+
See [How_to_Install_a_Plugin](https://theforeman.org/plugins/#2.Installation) for how to install Foreman plugins.
|
|
45
|
+
The [theforeman/foreman](https://github.com/theforeman/puppet-foreman/blob/master/manifests/plugin/openbolt.pp) puppet module also supports the **Foreman plugin** installation.
|
|
46
|
+
The [theforeman/foreman_proxy](https://github.com/theforeman/puppet-foreman_proxy/blob/master/manifests/plugin/openbolt.pp) puppet module also supports the **Foreman Smartproxy plugin** installation.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
The Foreman plugin provides UI elements to start Tasks on various nodes.
|
|
50
|
+
Foreman then talks to a Smartproxy to run OpenBolt.
|
|
51
|
+
The Smartproxy also establishes the connections to the various targets.
|
|
52
|
+
This is usually a ssh or WinRM connection (and soon choria, see [the TODO section](#todo)).
|
|
53
|
+
|
|
54
|
+
You need to have `bolt` in your `$PATH` on the Smartproxy.
|
|
55
|
+
OpenBolt packages are available at [yum.voxpupuli.org](https://yum.voxpupuli.org/) & [apt.voxpupuli.org](https://apt.voxpupuli.org/) in the openvox8 repo.
|
|
56
|
+
You can also use the legacy Bolt packages from Perforce from the `puppet-tools` repo on [apt.puppet.com](https://apt.puppet.com/) or [yum.puppet.com](https://yum.puppet.com/).
|
|
57
|
+
|
|
58
|
+
The integration is supported on Foreman 3.17 and all following versions, including development/nightly builds.
|
|
59
|
+
|
|
60
|
+
OpenBolt relies on Tasks & Plans. They are distributed as puppet modules.
|
|
61
|
+
The plugin assumes that you deployed your code.
|
|
62
|
+
We recommend to use [r10k](https://github.com/puppetlabs/r10k?tab=readme-ov-file#r10k) or [g10k](https://github.com/xorpaul/g10k?tab=readme-ov-file#g10k) to deploy code, as you do it on your compilers.
|
|
63
|
+
|
|
64
|
+
A handful of core/default Tasks & Plans are also included in the [OpenBolt rpm/deb packages](https://github.com/OpenVoxProject/openbolt/blob/main/Puppetfile).
|
|
15
65
|
|
|
16
66
|
## Usage
|
|
17
67
|
|
|
18
|
-
|
|
68
|
+
(all screenshots were taken on Foreman 3.17)
|
|
69
|
+
|
|
70
|
+
After installation, you will see a new UI element
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
The "Launch Task" option allows you to select any smartproxy with the `openbolt` feature (which is available when the OpenBolt Smartproxy plugin is installed).
|
|
75
|
+
Afterwards you can select N targets to run the task and select an available task from the selected Smartproxy.
|
|
76
|
+
On the right side you can configure OpenBolt connection settings.
|
|
77
|
+
|
|
78
|
+

|
|
79
|
+
|
|
80
|
+
After selecting a task, the task metadata is fetched and shown.
|
|
81
|
+
Additional input elements will appear, if the task support it.
|
|
82
|
+
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
The metadata can contains a description and datatypes for tasks.
|
|
86
|
+
Those information can be shown as well.
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
While the task is running, the UI polls the status from the smart proxy.
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
After the task finished, it will display a success for failure page.
|
|
95
|
+
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
You can also see the used parameters for a task.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
We also display the used OpenBolt command line, in case you want to manually run it or debug it.
|
|
103
|
+
|
|
104
|
+

|
|
105
|
+
|
|
106
|
+
OpenBolt returns JSON for executed tasks.
|
|
107
|
+
That's visible in the UI.
|
|
108
|
+
For failed tasks but also for passed tasks.
|
|
109
|
+
|
|
110
|
+

|
|
111
|
+
|
|
112
|
+

|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
### Linting
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
bundle exec rake lint # Run all linters (rubocop, erb_lint, eslint)
|
|
120
|
+
bundle exec rake lint:fix # Auto-fix where possible
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Ruby and ERB linters run directly. The JavaScript linter requires npm dependencies, so either install them locally (`npm install --legacy-peer-deps`) or run lint:js inside a container:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
CONTAINER=1 bundle exec rake lint:js
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Unit Tests
|
|
130
|
+
|
|
131
|
+
Unit tests run inside Docker containers with a full Foreman installation. Requires Docker with compose support.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bundle exec rake test:unit:up # Build image, start containers, install deps
|
|
135
|
+
bundle exec rake test:unit:ruby # Run Ruby tests
|
|
136
|
+
bundle exec rake test:unit:js # Run JavaScript tests
|
|
137
|
+
bundle exec rake test:unit:all # Run all unit tests
|
|
138
|
+
bundle exec rake test:unit:down # Stop and remove containers
|
|
139
|
+
bundle exec rake test # Shortcut: up, test, down in one step
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Set `FOREMAN_VERSION` to test against a specific Foreman version (default: `3.18`):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
FOREMAN_VERSION=3.17 bundle exec rake test:unit:up
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Acceptance Tests
|
|
149
|
+
|
|
150
|
+
Acceptance tests exercise the plugin through the browser using Capybara and Selenium. They build RPMs, start a multi-container environment (Foreman + OpenVox + SSH targets + Chromium), and run tests against the real UI.
|
|
151
|
+
|
|
152
|
+
**Prerequisites:**
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
bundle install --with acceptance
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The [smart_proxy_openbolt](https://github.com/overlookinfra/smart_proxy_openbolt) and [foreman-packaging](https://github.com/theforeman/foreman-packaging) repos are cloned automatically when needed.
|
|
159
|
+
|
|
160
|
+
**Running:**
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
bundle exec rake acceptance # Full cycle: up, run tests, down
|
|
164
|
+
bundle exec rake acceptance:up # Build RPMs, start Foreman, configure everything
|
|
165
|
+
bundle exec rake acceptance:run # Run tests (requires up first)
|
|
166
|
+
bundle exec rake acceptance:down # Stop containers
|
|
167
|
+
bundle exec rake acceptance:clean # Full reset: stop containers, remove images and artifacts
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The `acceptance:up` task is idempotent and can be re-run to pick up new RPM changes. It caches the Foreman Docker image per version so subsequent runs are faster.
|
|
171
|
+
|
|
172
|
+
**Watching tests in the browser:**
|
|
173
|
+
|
|
174
|
+
Set `HEADFUL=1` to disable headless mode, then open `http://localhost:7900` (password: `secret`) to watch the tests via noVNC:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
HEADFUL=1 bundle exec rake acceptance:run
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Running a subset of tests:**
|
|
181
|
+
|
|
182
|
+
`acceptance:run` accepts `TEST=<path>` to limit which test files are loaded, and `TESTOPTS=<opts>` to forward options (e.g. `--name=/pattern/`) to the Test::Unit autorunner. Both can be combined.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Run every test in one file
|
|
186
|
+
bundle exec rake acceptance:run TEST=test/acceptance/tests/settings_test.rb
|
|
187
|
+
|
|
188
|
+
# Run a single test by exact method name (any file)
|
|
189
|
+
bundle exec rake acceptance:run TESTOPTS='--name=test_echo_task_succeeds_on_all_targets'
|
|
190
|
+
|
|
191
|
+
# Run tests whose name matches a regex within one file
|
|
192
|
+
bundle exec rake acceptance:run \
|
|
193
|
+
TEST=test/acceptance/tests/settings_test.rb \
|
|
194
|
+
TESTOPTS='--name=/host_key/'
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Environment variables:**
|
|
198
|
+
|
|
199
|
+
| Variable | Default | Description |
|
|
200
|
+
|----------|---------|-------------|
|
|
201
|
+
| `CHROMEDRIVER_URL` | `http://localhost:4444` | Selenium WebDriver endpoint |
|
|
202
|
+
| `FOREMAN_BRANCH` | `<version>-stable` | Foreman git branch for unit test image (derived from `FOREMAN_VERSION`) |
|
|
203
|
+
| `FOREMAN_PACKAGING_REPO` | `https://github.com/theforeman/foreman-packaging.git` | Git URL for foreman-packaging (cloned automatically for RPM builds) |
|
|
204
|
+
| `FOREMAN_PASS` | `changeme` | Foreman login password |
|
|
205
|
+
| `FOREMAN_URL` | `https://foreman` | Foreman URL as seen by Chrome. Override to run tests against a live instance |
|
|
206
|
+
| `FOREMAN_USER` | `admin` | Foreman login username |
|
|
207
|
+
| `FOREMAN_VERSION` | `3.18` | Foreman version to test against |
|
|
208
|
+
| `HEADFUL` | unset | Set to `1` to show the browser in noVNC |
|
|
209
|
+
| `SELENIUM_IMAGE` | auto-detected (ARM/x86) | Selenium container image (auto-selects `seleniarm/standalone-chromium` or `selenium/standalone-chrome`) |
|
|
210
|
+
| `SMART_PROXY_OPENBOLT_REF` | `main` | Branch or tag to clone |
|
|
211
|
+
| `SMART_PROXY_OPENBOLT_REPO` | `https://github.com/overlookinfra/smart_proxy_openbolt.git` | Git URL for smart_proxy_openbolt (cloned automatically for RPM builds) |
|
|
212
|
+
|
|
213
|
+
### Building Packages
|
|
214
|
+
|
|
215
|
+
Build RPM or DEB packages locally using containers. The [foreman-packaging](https://github.com/theforeman/foreman-packaging) repo is cloned automatically:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
bundle exec rake build:rpm # Build RPM
|
|
219
|
+
bundle exec rake build:deb # Build DEB
|
|
220
|
+
```
|
|
19
221
|
|
|
20
222
|
## TODO
|
|
21
223
|
|
|
22
|
-
*
|
|
224
|
+
* Integrate plans into the web UI
|
|
225
|
+
* Provide a choria transport plugin
|
|
23
226
|
|
|
24
|
-
## Contributing
|
|
227
|
+
## Contributing & support
|
|
25
228
|
|
|
26
229
|
Fork and send a Pull Request. Thanks!
|
|
230
|
+
If you have questions or need professional support, please join the `#sig-orchestrator` channel on the [Vox Pupuli slack](https://voxpupuli.org/connect/).
|
|
27
231
|
|
|
28
232
|
## Copyright
|
|
29
233
|
|
|
30
|
-
Copyright (c) *
|
|
234
|
+
Copyright (c) *2025* *Overlook InfraTech*
|
|
235
|
+
|
|
236
|
+
Copyright (c) *2025* *betadots GmbH*
|
|
31
237
|
|
|
32
238
|
This program is free software: you can redistribute it and/or modify
|
|
33
239
|
it under the terms of the GNU General Public License as published by
|
|
@@ -42,14 +248,88 @@ GNU General Public License for more details.
|
|
|
42
248
|
You should have received a copy of the GNU General Public License
|
|
43
249
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
44
250
|
|
|
45
|
-
##
|
|
251
|
+
## How to Release
|
|
252
|
+
|
|
253
|
+
### Version locations
|
|
254
|
+
|
|
255
|
+
Update the version in these files:
|
|
256
|
+
|
|
257
|
+
1. `lib/foreman_openbolt/version.rb` -- the gem version (authoritative source)
|
|
258
|
+
2. `package.json` -- the npm package version (must match)
|
|
259
|
+
|
|
260
|
+
If the minimum Foreman version changes, also update:
|
|
261
|
+
|
|
262
|
+
3. `lib/foreman_openbolt/engine.rb` -- `requires_foreman '>= X.Y.Z'`
|
|
263
|
+
4. `foreman_openbolt.spec.erb` -- `%global foreman_min_version X.Y.Z`
|
|
264
|
+
5. `.github/workflows/build.yml` -- default `foreman_version` and `foreman_packaging_ref` inputs
|
|
265
|
+
|
|
266
|
+
### Release steps
|
|
267
|
+
|
|
268
|
+
1. Bump the version in the two files listed above
|
|
269
|
+
2. Generate the changelog:
|
|
270
|
+
```bash
|
|
271
|
+
CHANGELOG_GITHUB_TOKEN=github_pat_... bundle exec rake changelog
|
|
272
|
+
```
|
|
273
|
+
3. Create a PR with the version bump and changelog, get it reviewed and merged
|
|
274
|
+
4. Create and push a tag matching the version:
|
|
275
|
+
```bash
|
|
276
|
+
git tag 1.1.0
|
|
277
|
+
git push origin 1.1.0
|
|
278
|
+
```
|
|
279
|
+
5. The [release workflow](.github/workflows/release.yml) runs automatically on tag push and:
|
|
280
|
+
- Builds the gem
|
|
281
|
+
- Creates a GitHub Release with auto-generated notes and the gem attached
|
|
282
|
+
- Publishes the gem to GitHub Packages
|
|
283
|
+
- Publishes the gem to RubyGems.org (requires the `release` environment)
|
|
284
|
+
- Verifies the gem is available on RubyGems.org
|
|
285
|
+
|
|
286
|
+
### RPM/DEB packaging
|
|
287
|
+
|
|
288
|
+
After the gem is published to RubyGems, both RPM and DEB packages need to be updated in [theforeman/foreman-packaging](https://github.com/theforeman/foreman-packaging).
|
|
289
|
+
|
|
290
|
+
A bot automatically creates PRs against the `rpm/develop` and `deb/develop` branches to pick up the new gem version. These PRs build packages for Foreman nightly.
|
|
291
|
+
|
|
292
|
+
For stable Foreman releases (currently 3.17 and 3.18), cherry-pick the packaging commits from the develop branches into the corresponding stable branches. For each stable version you want to support:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
cd foreman-packaging
|
|
296
|
+
|
|
297
|
+
# RPM: cherry-pick from rpm/develop into a branch off the stable target
|
|
298
|
+
git checkout rpm/3.18
|
|
299
|
+
git checkout -b cherry-pick/rubygem-foreman_openbolt-rpm-3.18
|
|
300
|
+
git cherry-pick <commit-from-rpm/develop>
|
|
301
|
+
# Push to your fork and open a PR targeting rpm/3.18
|
|
302
|
+
|
|
303
|
+
# DEB: same approach for the deb side
|
|
304
|
+
git checkout deb/3.18
|
|
305
|
+
git checkout -b cherry-pick/rubygem-foreman-openbolt-deb-3.18
|
|
306
|
+
git cherry-pick <commit-from-deb/develop>
|
|
307
|
+
# Push to your fork and open a PR targeting deb/3.18
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
PRs against stable branches should be labeled "Stable branch".
|
|
311
|
+
|
|
312
|
+
**Alternative: manual version bump**
|
|
313
|
+
|
|
314
|
+
If the cherry-pick doesn't apply cleanly, you can bump the version manually on the stable branch instead.
|
|
315
|
+
|
|
316
|
+
*RPM:* Checkout the target branch and run `bump_rpm.sh`:
|
|
317
|
+
```bash
|
|
318
|
+
cd foreman-packaging
|
|
319
|
+
git checkout rpm/3.18
|
|
320
|
+
git checkout -b bump_rpm/rubygem-foreman_openbolt
|
|
321
|
+
./bump_rpm.sh packages/plugins/rubygem-foreman_openbolt
|
|
322
|
+
# Review changes, push to your fork, and open a PR targeting rpm/3.18
|
|
323
|
+
```
|
|
46
324
|
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* github actions will publish the tag
|
|
325
|
+
*DEB:* Checkout the target branch and update these files:
|
|
326
|
+
- `debian/gem.list` -- new gem filename
|
|
327
|
+
- `foreman_openbolt.rb` -- new version
|
|
328
|
+
- `debian/control` -- dependency versions (if changed)
|
|
329
|
+
- `debian/changelog` -- add a new entry
|
|
53
330
|
|
|
54
|
-
|
|
55
|
-
|
|
331
|
+
```bash
|
|
332
|
+
git checkout deb/3.18
|
|
333
|
+
git checkout -b bump_deb/ruby-foreman-openbolt
|
|
334
|
+
# Make the changes above, push to your fork, and open a PR targeting deb/3.18
|
|
335
|
+
```
|
data/Rakefile
CHANGED
|
@@ -1,99 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
rdoc.title = 'ForemanOpenbolt'
|
|
16
|
-
rdoc.options << '--line-numbers'
|
|
17
|
-
rdoc.rdoc_files.include('README.rdoc')
|
|
18
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
require 'rake/testtask'
|
|
22
|
-
|
|
23
|
-
Rake::TestTask.new(:test) do |t|
|
|
24
|
-
t.libs << 'lib'
|
|
25
|
-
t.libs << 'test'
|
|
26
|
-
t.pattern = 'test/**/*_test.rb'
|
|
27
|
-
t.verbose = false
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
begin
|
|
31
|
-
require 'rubocop/rake_task'
|
|
32
|
-
RuboCop::RakeTask.new
|
|
33
|
-
rescue LoadError
|
|
34
|
-
puts 'Rubocop not loaded.'
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# This is all kinda screwy. Fix it up later.
|
|
38
|
-
LINTERS = {
|
|
39
|
-
ruby: { cmd: 'rubocop', fix: '--auto-correct' },
|
|
40
|
-
erb: { cmd: 'erb_lint', fix: '--autocorrect', glob: '**/*.erb' },
|
|
41
|
-
js: { image: 'registry.access.redhat.com/ubi9/nodejs-20:latest', cmd: 'npm run lint --', fix: '--fix' },
|
|
42
|
-
}.freeze
|
|
43
|
-
|
|
44
|
-
namespace :lint do
|
|
45
|
-
def fix?
|
|
46
|
-
!ENV['FIX'].nil?
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def local?
|
|
50
|
-
!ENV['LOCAL'].nil?
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def bin
|
|
54
|
-
ENV['CONTAINER_BIN'] || 'docker'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
LINTERS.each do |name, cfg|
|
|
58
|
-
desc "Run #{name} linter#{' (fix)' if fix?}"
|
|
59
|
-
task name do
|
|
60
|
-
cmd = [cfg[:cmd]]
|
|
61
|
-
cmd << cfg[:fix] if fix?
|
|
62
|
-
cmd << cfg[:glob] unless cfg[:glob].nil? || cfg[:glob].empty? # rubocop:disable Rails/Blank
|
|
63
|
-
cmd = cmd.join(' ')
|
|
64
|
-
if cfg[:image] && !local?
|
|
65
|
-
cmd = "#{bin} run --rm -v #{Dir.pwd}:/code #{cfg[:image]} /bin/bash -c " +
|
|
66
|
-
"'cd /code && npm install --loglevel=error && #{cmd}'"
|
|
67
|
-
end
|
|
68
|
-
sh cmd
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
desc 'Run all linters'
|
|
73
|
-
task all: LINTERS.keys
|
|
74
|
-
|
|
75
|
-
desc 'Run all linters and apply fixes'
|
|
76
|
-
task :fix do
|
|
77
|
-
ENV['FIX'] = 'true'
|
|
78
|
-
Rake::Task['lint:all'].invoke
|
|
3
|
+
require_relative 'rakelib/utils/shell'
|
|
4
|
+
|
|
5
|
+
def latest_foreman_version
|
|
6
|
+
result = Shell.capture(
|
|
7
|
+
['git', 'ls-remote', '--tags', 'https://github.com/theforeman/foreman.git'],
|
|
8
|
+
print_command: false, allowed_exit_codes: [0, 1]
|
|
9
|
+
)
|
|
10
|
+
tags = result.output.scan(%r{refs/tags/([^\s]+)$}).flatten
|
|
11
|
+
versions = tags.filter_map do |tag|
|
|
12
|
+
Gem::Version.new(tag)
|
|
13
|
+
rescue ArgumentError
|
|
14
|
+
nil
|
|
79
15
|
end
|
|
16
|
+
latest = versions.reject(&:prerelease?).max
|
|
17
|
+
latest ? "#{latest.segments[0]}.#{latest.segments[1]}" : '3.18'
|
|
80
18
|
end
|
|
81
19
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
begin
|
|
85
|
-
require 'rubygems'
|
|
86
|
-
require 'github_changelog_generator/task'
|
|
20
|
+
DEFAULT_FOREMAN_VERSION = latest_foreman_version
|
|
21
|
+
FOREMAN_VERSION = ENV.fetch('FOREMAN_VERSION', DEFAULT_FOREMAN_VERSION)
|
|
87
22
|
|
|
88
|
-
|
|
89
|
-
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
|
|
90
|
-
config.user = 'overlookinfra'
|
|
91
|
-
config.project = 'foreman_openbolt'
|
|
92
|
-
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
|
93
|
-
config.future_release = gem_version
|
|
94
|
-
end
|
|
95
|
-
rescue LoadError
|
|
96
|
-
task :changelog do
|
|
97
|
-
abort("Run `bundle install --with release` to install the `github_changelog_generator` gem.")
|
|
98
|
-
end
|
|
99
|
-
end
|
|
23
|
+
task default: :lint
|