Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto test #2

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
fb60f30
Fixes #32568 - Make cmd object be available in command extensions
ofedoren May 8, 2021
a49c7f6
Fixes #32570 - Unescape ENUM validator description
ofedoren May 8, 2021
2988cc6
Fixes #29093 - change from superficial copy to deep copy of fields
adiabramovitch May 24, 2021
684bcb1
Merge pull request #345 from adiabramovitch/29093
yifatmakias May 26, 2021
fab0e74
Merge pull request #344 from ofedoren/bug-32570-unescape-html-for-enums
yifatmakias May 26, 2021
0c2bd91
Merge pull request #343 from ofedoren/feat-32568-cmd-obj-cmd-ext
yifatmakias May 26, 2021
b4ec35a
Revert "Fixes #29093 - change from superficial copy to deep copy of f…
ofedoren Jun 2, 2021
558b080
Merge pull request #346 from theforeman/revert-345-29093
yifatmakias Jun 2, 2021
1e7b39e
Bump version to 3.0-develop
tbrisker Jul 22, 2021
2ed3b50
Update rel-eng notebook (#347)
ofedoren Jul 23, 2021
26a8d83
Bump to 3.0.0
ofedoren Aug 4, 2021
b70ed1e
i18n - extracting new, pulling from tx
ofedoren Aug 4, 2021
819023c
Bump to 3.1.0-develop
ofedoren Aug 4, 2021
27d4686
Fixes #32783 - Extract descs to option details section
ofedoren Aug 6, 2021
7f0e533
Fixes #33225 - Show depr warning only on option usage
ofedoren Aug 6, 2021
d0bedb1
Merge pull request #350 from ofedoren/bug-32783-add-new-section
yifatmakias Aug 10, 2021
73a3c55
Merge pull request #351 from ofedoren/ref-33225-opt-depr-way
yifatmakias Aug 10, 2021
247f57f
Fixes #33226 - Make API docs params to be the main options
ofedoren Aug 6, 2021
581378e
Merge pull request #352 from ofedoren/ref-33226-api-docs-opts
yifatmakias Aug 11, 2021
c8430df
Fixes #29093 - change from superficial copy to deep copy of fields (#…
adiabramovitch Aug 12, 2021
2085565
Fixes #33259 - Don't store @context in field params
ofedoren Aug 16, 2021
c9753b3
Fixes #33129 - Wrap option descriptions to 80 chars
ofedoren Aug 17, 2021
df4639c
Fix rake version
ofedoren Aug 23, 2021
e29260d
Revert Fix rake version
ofedoren Aug 23, 2021
53ef0ae
Merge pull request #354 from ofedoren/bug-33129-align-long-descs
yifatmakias Aug 26, 2021
c2105d8
Fixes #33810 - Remove a space in hammer's shebang
ekohl Nov 2, 2021
2557e44
Bump to 3.1.0
ofedoren Nov 10, 2021
07e7a65
i18n - extracting new, pulling from tx
ofedoren Nov 10, 2021
a7815b3
Bump to 3.2.0-develop
ofedoren Nov 10, 2021
9375f2d
Fixes #34079 - Allow explicit strings in key=value options (#356)
ofedoren Dec 12, 2021
be29954
Add missing_args_error_result test helper (#357)
ofedoren Jan 12, 2022
2af612a
Fixes #34204 - Fix FR translation (#358)
ofedoren Jan 25, 2022
5670f92
Bump to 3.2.0
ofedoren Feb 10, 2022
5d88c19
i18n - extracting new, pulling from tx
ofedoren Feb 10, 2022
27087bf
Bump to 3.3.0-develop
ofedoren Feb 10, 2022
e6268bb
Fixes #34724 - Fix hammer shell with pipe as stdin (#360)
adamruzicka Apr 8, 2022
e6c4c52
Bump to 3.3.0
ofedoren May 10, 2022
8244a3c
i18n - extracting new, pulling from tx
ofedoren May 10, 2022
2d7ffb6
Bump to 3.4.0-develop
ofedoren May 10, 2022
de7095a
Bump to 3.4.0
ofedoren Aug 9, 2022
1209410
i18n - extracting new, pulling from tx
ofedoren Aug 9, 2022
581c44e
Bump to 3.5.0-develop
ofedoren Aug 9, 2022
3234dc2
Bump to 3.5.0
ofedoren Oct 31, 2022
cfe33c7
i18n - extracting new, pulling from tx
ofedoren Oct 31, 2022
147df01
Bump to 3.6.0-develop
ofedoren Oct 31, 2022
6f8ec97
Correct mocha inclusion in tests
ekohl Nov 24, 2022
c6cb296
Include Makefile.def in the gem
ekohl Nov 23, 2022
8805e4a
Update apipie-bindings to 0.6.0
ofedoren Feb 21, 2023
560feae
Bump to 3.6.0
ofedoren Feb 23, 2023
dd629ac
i18n - extracting new, pulling from tx
ofedoren Feb 23, 2023
c32a4c9
Bump to 3.7.0-develop
ofedoren Feb 23, 2023
97589ef
Fixes #34853 - Load SSL key using OpenSSL::PKey.read (#364)
ofedoren Mar 22, 2023
6c34baf
Fix config template typos (#365)
wbclark Apr 17, 2023
951d3df
Fixes #36337 - Update rake and clamp deps
ofedoren May 2, 2023
6df1acb
Refs #36337 - Fix ambiguous operator warnings
ofedoren May 2, 2023
af674ad
Refs #36337 - Remove unused code
ofedoren May 2, 2023
5c0846b
Fixes #36418 - Honor TZ in datetime normalizer (#369)
adamruzicka May 19, 2023
c168830
Bump to 3.7.0
ofedoren May 23, 2023
c96d2b4
Bump to 3.8.0-develop
ofedoren May 23, 2023
25b47c4
Add packit config (#370)
ofedoren Jun 2, 2023
9c327d1
Fixes #36283 - Update transifex automation
ofedoren Apr 18, 2023
141a464
Refs #36283 - Move Makefile targets to Rakefile
ofedoren Apr 25, 2023
51e273f
Refs #36283 - Improve Rakefile tx commands
ofedoren May 22, 2023
c24b5b2
i18n - extracting new, pulling from tx
ofedoren Jun 8, 2023
e4e042e
Fixes #36592 - Update minitest version
ofedoren May 10, 2023
0d64bed
Refs #36592 - Try to upgrade ci_reporter
ofedoren May 10, 2023
688e362
Refs #36592 - Wrap commands with Class.new to clone
ofedoren Jul 14, 2023
f8b6768
Add GA to run tests on Ruby 3+
ofedoren Jul 14, 2023
761d84a
Fix minitest (#375)
ofedoren Jul 27, 2023
b5e8b52
Fixes #36258 - Improve regex for KeyValueList normalizer
ofedoren Jul 27, 2023
327f191
Drop unicode gem (#376)
ehelms Aug 1, 2023
464f594
Fixes #36588 - Consider false values in String#format
ofedoren Jul 13, 2023
f3797c2
Bump to 3.8.0
ofedoren Aug 25, 2023
7ac6ae6
i18n - extracting new, pulling from tx
ofedoren Aug 25, 2023
9c3093a
Bump to 3.9.0-develop
ofedoren Aug 25, 2023
3e67cb6
Update rel-eng
ofedoren Aug 25, 2023
213a20a
i18n - extracting new, pulling from tx
ofedoren Nov 2, 2023
f9641c6
Update packit
ofedoren Nov 23, 2023
d1ce64a
Use strings for Ruby versions in GHA (#380)
ofedoren Nov 29, 2023
0cd6d81
Bump to 3.9.0
ofedoren Nov 29, 2023
e21a7ef
i18n - extracting new, pulling from tx
ofedoren Nov 29, 2023
b57568d
Bump to 3.10.0-develop
ofedoren Nov 29, 2023
519f26a
Test gh pr utility
ofedoren Jan 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run tests GA

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hammer-cli
strategy:
fail-fast: false
matrix:
ruby:
- '2.7'
- '3.0'
- '3.1'

steps:
- name: Get hammer-cli
uses: actions/checkout@v2
with:
path: hammer-cli
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
working-directory: hammer-cli
- name: Run tests
run: |
bundle exec rake test
44 changes: 44 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See the documentation for more information:
# https://packit.dev/docs/configuration/

specfile_path: rubygem-hammer_cli.spec

# add or remove files that should be synced
files_to_sync:
- rubygem-hammer_cli.spec
- .packit.yaml

# name in upstream package repository or registry (e.g. in PyPI)
upstream_package_name: hammer_cli
# downstream (Fedora) RPM package name
downstream_package_name: rubygem-hammer_cli

actions:
post-upstream-clone:
- "wget https://raw.githubusercontent.com/theforeman/foreman-packaging/rpm/develop/packages/foreman/rubygem-hammer_cli/rubygem-hammer_cli.spec -O rubygem-hammer_cli.spec"
- "a2x -d manpage -f manpage -D man/ man/hammer.1.asciidoc"
- "gzip -f9 man/hammer.1"
- "sed -i '/^%global prereleasesource pre.develop$/d' rubygem-hammer_cli.spec"
- "sed -i '/^%global prerelease %{?prereleasesource:.}%{?prereleasesource}$/d' rubygem-hammer_cli.spec"
get-current-version:
- ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version'
create-archive:
- gem build hammer_cli.gemspec
- bash -c "ls -1t ./hammer_cli-*.gem | head -n 1"

jobs:
- job: copr_build
trigger: pull_request
targets:
centos-stream-8:
additional_modules: "foreman-devel:el8"
additional_repos:
- https://yum.theforeman.org/releases/nightly/el8/x86_64/
- https://yum.theforeman.org/plugins/nightly/el8/x86_64/
module_hotfixes: true

srpm_build_deps:
- wget
- asciidoc
- gzip
- rubygems
5 changes: 3 additions & 2 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[main]
host = https://www.transifex.com
host = https://app.transifex.com

[foreman.hammer-cli]
[o:foreman:p:foreman:r:hammer-cli]
file_filter = locale/<lang>/hammer-cli.edit.po
source_file = locale/hammer-cli.pot
source_lang = en
type = PO
resource_name = hammer-cli
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ gemspec
gem 'gettext', '>= 3.1.3', '< 4.0.0'

group :test do
gem 'rake', '~> 10.1.0'
gem 'rake'
gem 'thor'
gem 'minitest', '4.7.4'
gem 'minitest', '~> 5.18'
gem 'minitest-spec-context'
gem 'simplecov'
gem 'mocha'
gem 'ci_reporter', '>= 1.6.3', "< 2.0.0", :require => false
gem 'ci_reporter_minitest', '~> 1.0', :require => false
end

# load local gemfile
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Rake::TestTask.new do |t|
t.libs.push "lib"
t.test_files = Dir.glob('test/**/*_test.rb')
t.verbose = true
t.warning = ENV.key?('RUBY_WARNINGS')
end

file "man/hammer.1.gz" => "man/hammer.1.asciidoc" do |t|
Expand Down
9 changes: 2 additions & 7 deletions bin/hammer
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env ruby
#!/usr/bin/env ruby

require 'rubygems'
require 'clamp'
Expand Down Expand Up @@ -56,12 +56,7 @@ end
# load user's settings
require 'hammer_cli/settings'

CFG_PATH = ['~/.hammer/', '/etc/hammer/', "#{::RbConfig::CONFIG['sysconfdir']}/hammer/"].uniq
HammerCLI::Settings.load_from_paths CFG_PATH

CFG_PATH_LOCAL = ['./config/']

HammerCLI::Settings.load_from_paths CFG_PATH_LOCAL
HammerCLI::Settings.load_from_defaults

if preparser.config
if File.file? preparser.config
Expand Down
6 changes: 3 additions & 3 deletions config/cli_config.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Location of shell history file
:history_file: '~/.hammer/history'
# Mark translated strings with X characters (for developers)
#:mark_translated: false
# :mark_translated: false
# Hide headers from output of list actions
# :no_headers: true
# Choose capitalization for JSON/YAML output.
Expand All @@ -17,7 +17,7 @@
# Enable/disable color output of logger in Clamp commands
:watch_plain: false

# Forece relaod of Apipie cache with every Hammer invocation
# Force reload of Apipie cache with every Hammer invocation
:reload_cache: false

# Directory where the logs are stored. The default is /var/log/hammer/ and the log file is named hammer.log
Expand Down Expand Up @@ -75,5 +75,5 @@
# Certs from the local storage are used only when neither :ssl_ca_file: nor :ssl_ca_path: is cofigured.
#:local_ca_store_path: '~/.hammer/certs'

# Allows setting the SSL version to use when making API calls
# Allows setting the SSL version to use when making API calls
#:ssl_version: 'TLSv1_2'
14 changes: 8 additions & 6 deletions doc/commands_extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ Each command can be easily extended with one ore more `HammerCLI::CommandExtensi
child option_params
end
# Extend hash with data returned from server before it is printed
before_print do |data|
before_print do |data, command_object, command_class|
# data modifications
end
# Extend command's output definition
output do |definition|
output do |definition, command_object, command_class|
# output definition modifications
end
# Extend command's help definition
help do |h|
# help modifications
end
# Extend hash with headers before request is sent
request_headers do |headers|
request_headers do |headers, command_object, command_class|
# headers modifications
end
# Extend hash with options before request is sent
request_options do |options|
request_options do |options, command_object, command_class|
# options modifications
end
# Extend hash with params before request is sent
request_params do |params|
request_params do |params, command_object, command_class|
# params modifications
end
# Extend option sources
option_sources do |sources, command|
option_sources do |sources, command_object, command_class|
# no need to call super method
# simply add your sources to sources variable
end
Expand All @@ -63,6 +63,8 @@ __NOTE:__
- `request_*` extensions are applied before sending a request to the server
- `option`, `output`, `help` extensions are applied right away after the command is extended with `extend_with`
- `before_print` extensions are applied right away after the server returns the data
- `request_*`, `output`, `before_print` extensions have access to the command object
after the command with the extension was initialized

#### Example
```ruby
Expand Down
17 changes: 17 additions & 0 deletions doc/creating_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ To define an option family, use the following DSL:
end
```

You can also add additional options for automatically built ones:
```ruby
# ...
build_options
# If --resource-id option comes from the API params and you want to add options
# with searchables such as --resource-name, --resource-label
option_family(associate: 'resource') do
child '--resource-name', 'RESOURCE', _('Resource desc'), attribute_name: :option_resource_name
child '--resource-label', 'RESOURCE', _('Resource desc'), attribute_name: :option_resource_label
end
# $ hammer command --help:
# ...
# Options:
# --resource[-id|-name|-label] Resource desc
# ...
```

##### Example

```ruby
Expand Down
75 changes: 75 additions & 0 deletions doc/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
Release notes
=============
### 3.9.0 (2023-11-29)
* Use strings for ruby versions in gha ([PR #380](https://github.com/theforeman/hammer-cli/pull/380))
* Update packit
* Update rel-eng
* Bump to 3.9.0-develop

### 3.8.0 (2023-08-25)
* Consider false values in string#format, [#36588](http://projects.theforeman.org/issues/36588)
* Drop unicode gem ([PR #376](https://github.com/theforeman/hammer-cli/pull/376))
* Improve regex for keyvaluelist normalizer, [#36258](http://projects.theforeman.org/issues/36258)
* Fix minitest ([PR #375](https://github.com/theforeman/hammer-cli/pull/375))
* Add ga to run tests on ruby 3+
* Wrap commands with class.new to clone, [#36592](http://projects.theforeman.org/issues/36592)
* Try to upgrade ci_reporter, [#36592](http://projects.theforeman.org/issues/36592)
* Update minitest version, [#36592](http://projects.theforeman.org/issues/36592)
* Improve rakefile tx commands, [#36283](http://projects.theforeman.org/issues/36283)
* Move makefile targets to rakefile, [#36283](http://projects.theforeman.org/issues/36283)
* Update transifex automation, [#36283](http://projects.theforeman.org/issues/36283)
* Add packit config ([PR #370](https://github.com/theforeman/hammer-cli/pull/370))
* Bump to 3.8.0-develop

### 3.7.0 (2023-05-23)
* Honor tz in datetime normalizer ([PR #369](https://github.com/theforeman/hammer-cli/pull/369)), [#36418](http://projects.theforeman.org/issues/36418)
* Remove unused code, [#36337](http://projects.theforeman.org/issues/36337)
* Fix ambiguous operator warnings, [#36337](http://projects.theforeman.org/issues/36337)
* Update rake and clamp deps, [#36337](http://projects.theforeman.org/issues/36337)
* Fix config template typos ([PR #365](https://github.com/theforeman/hammer-cli/pull/365))
* Load ssl key using openssl::pkey.read ([PR #364](https://github.com/theforeman/hammer-cli/pull/364)), [#34853](http://projects.theforeman.org/issues/34853)
* Bump to 3.7.0-develop

### 3.6.0 (2023-02-23)
* Update apipie-bindings to 0.6.0
* Include makefile.def in the gem
* Correct mocha inclusion in tests
* Bump to 3.6.0-develop

### 3.5.0 (2022-10-31)
* Bump to 3.5.0-develop

### 3.4.0 (2022-08-09)
* Bump to 3.4.0-develop

### 3.3.0 (2022-05-10)
* Fix hammer shell with pipe as stdin ([PR #360](https://github.com/theforeman/hammer-cli/pull/360)), [#34724](http://projects.theforeman.org/issues/34724)
* Bump to 3.3.0-develop

### 3.2.0 (2022-02-10)
* Fix fr translation ([PR #358](https://github.com/theforeman/hammer-cli/pull/358)), [#34204](http://projects.theforeman.org/issues/34204)
* Add missing_args_error_result test helper ([PR #357](https://github.com/theforeman/hammer-cli/pull/357))
* Allow explicit strings in key=value options ([PR #356](https://github.com/theforeman/hammer-cli/pull/356)), [#34079](http://projects.theforeman.org/issues/34079)
* Bump to 3.2.0-develop

### 3.1.0 (2021-11-10)
* Remove a space in hammer's shebang, [#33810](http://projects.theforeman.org/issues/33810)
* Revert fix rake version
* Fix rake version
* Wrap option descriptions to 80 chars, [#33129](http://projects.theforeman.org/issues/33129)
* Don't store @context in field params, [#33259](http://projects.theforeman.org/issues/33259)
* Change from superficial copy to deep copy of fields ([PR #348](https://github.com/theforeman/hammer-cli/pull/348)), [#29093](http://projects.theforeman.org/issues/29093)
* Make api docs params to be the main options, [#33226](http://projects.theforeman.org/issues/33226)
* Show depr warning only on option usage, [#33225](http://projects.theforeman.org/issues/33225)
* Extract descs to option details section, [#32783](http://projects.theforeman.org/issues/32783)
* Bump to 3.1.0-develop

### 3.0.0 (2021-08-04)
* Update rel-eng notebook ([PR #347](https://github.com/theforeman/hammer-cli/pull/347))
* Bump version to 3.0-develop
* Revert "change from superficial copy to deep copy of fields", [#29093](http://projects.theforeman.org/issues/29093)
* Change from superficial copy to deep copy of fields, [#29093](http://projects.theforeman.org/issues/29093)
* Add full comparison for fields option, [#31984](http://projects.theforeman.org/issues/31984)
* Force capitalized field names in help, [#32444](http://projects.theforeman.org/issues/32444)
* Unescape enum validator description, [#32570](http://projects.theforeman.org/issues/32570)
* Make cmd object be available in command extensions, [#32568](http://projects.theforeman.org/issues/32568)
* Bump to 2.6.0-develop

### 2.5.0 (2021-05-04)
* Better family assignment for options, [#30996](http://projects.theforeman.org/issues/30996)
* Bump to 2.5.0-develop
Expand Down
9 changes: 5 additions & 4 deletions hammer_cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ EOF
locales = Dir['locale/*'].select { |f| File.directory?(f) }
s.files = Dir['{lib,test,bin,doc,config}/**/*', 'LICENSE', 'README*'] +
locales.map { |loc| "#{loc}/LC_MESSAGES/hammer-cli.mo" } +
['man/hammer.1.gz']
['locale/Makefile.def', 'man/hammer.1.gz']

s.test_files = Dir['test/**/*']
s.extra_rdoc_files = Dir['{doc,config}/**/*', 'README*']
s.require_paths = ["lib"]
s.executables = ['hammer', 'hammer-complete']

s.add_dependency 'clamp', '>= 1.1', '< 1.2.0'
s.required_ruby_version = '>= 3.0'

s.add_dependency 'clamp', '>= 1.3.1', '< 2.0.0'
s.add_dependency 'logging'
s.add_dependency 'unicode-display_width'
s.add_dependency 'unicode'
s.add_dependency 'amazing_print'
s.add_dependency 'highline'
s.add_dependency 'fast_gettext'
s.add_dependency 'locale', '>= 2.0.6'
s.add_dependency 'apipie-bindings', '>= 0.2.0'
s.add_dependency 'apipie-bindings', '>= 0.6.0'

end
Loading
Loading