moose-inventory 1.0.8 → 2.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 +5 -5
- data/.github/workflows/ci.yml +49 -0
- data/.github/workflows/release.yml +58 -0
- data/.gitignore +1 -1
- data/.gitleaks.toml +9 -0
- data/.rubocop.yml +19 -784
- data/BACKLOG.md +290 -0
- data/Gemfile.lock +95 -0
- data/README.md +38 -9
- data/Rakefile +1 -1
- data/bin/moose-inventory +1 -1
- data/docs/release/publishing.md +109 -0
- data/docs/release/release-readiness.md +55 -0
- data/docs/security-audit-2026-05-21.md +71 -0
- data/docs/security-audit-2026-05-26-rerun.md +75 -0
- data/docs/security-audit-2026-05-26.md +63 -0
- data/lib/moose_inventory/cli/formatter.rb +16 -17
- data/lib/moose_inventory/cli/group.rb +4 -1
- data/lib/moose_inventory/cli/group_add.rb +89 -75
- data/lib/moose_inventory/cli/group_addchild.rb +84 -71
- data/lib/moose_inventory/cli/group_addhost.rb +78 -69
- data/lib/moose_inventory/cli/group_addvar.rb +37 -37
- data/lib/moose_inventory/cli/group_get.rb +23 -26
- data/lib/moose_inventory/cli/group_list.rb +12 -15
- data/lib/moose_inventory/cli/group_listvars.rb +12 -14
- data/lib/moose_inventory/cli/group_rm.rb +104 -76
- data/lib/moose_inventory/cli/group_rmchild.rb +99 -54
- data/lib/moose_inventory/cli/group_rmhost.rb +64 -60
- data/lib/moose_inventory/cli/group_rmvar.rb +5 -5
- data/lib/moose_inventory/cli/helpers.rb +76 -0
- data/lib/moose_inventory/cli/host.rb +4 -1
- data/lib/moose_inventory/cli/host_add.rb +51 -66
- data/lib/moose_inventory/cli/host_addgroup.rb +77 -68
- data/lib/moose_inventory/cli/host_addvar.rb +6 -6
- data/lib/moose_inventory/cli/host_get.rb +15 -18
- data/lib/moose_inventory/cli/host_list.rb +3 -3
- data/lib/moose_inventory/cli/host_listvars.rb +21 -23
- data/lib/moose_inventory/cli/host_rm.rb +9 -9
- data/lib/moose_inventory/cli/host_rmgroup.rb +63 -60
- data/lib/moose_inventory/cli/host_rmvar.rb +3 -3
- data/lib/moose_inventory/config/config.rb +43 -40
- data/lib/moose_inventory/db/db.rb +92 -52
- data/lib/moose_inventory/db/models.rb +11 -12
- data/lib/moose_inventory/inventory_context.rb +50 -0
- data/lib/moose_inventory/operations/add_associations.rb +127 -0
- data/lib/moose_inventory/operations/add_groups.rb +115 -0
- data/lib/moose_inventory/operations/add_hosts.rb +110 -0
- data/lib/moose_inventory/operations/group_child_relations.rb +118 -0
- data/lib/moose_inventory/operations/group_cleanup.rb +55 -0
- data/lib/moose_inventory/operations/remove_associations.rb +101 -0
- data/lib/moose_inventory/operations/remove_groups.rb +79 -0
- data/lib/moose_inventory/version.rb +1 -1
- data/moose-inventory.gemspec +38 -20
- data/scripts/check.sh +10 -0
- data/scripts/ci/check_permissions.sh +35 -0
- data/scripts/ci/check_rubocop.sh +28 -0
- data/scripts/ci/check_secrets.sh +26 -0
- data/scripts/ci/check_security.sh +68 -0
- data/scripts/ci/install_security_tools.sh +47 -0
- data/scripts/ci/package_sanity.sh +46 -0
- data/scripts/files.rb +1 -4
- data/scripts/install_dependencies.sh +19 -0
- data/scripts/reports.sh +2 -2
- data/spec/lib/moose_inventory/cli/cli_spec.rb +13 -14
- data/spec/lib/moose_inventory/cli/group_add_spec.rb +118 -119
- data/spec/lib/moose_inventory/cli/group_addchild_spec.rb +49 -51
- data/spec/lib/moose_inventory/cli/group_addhost_spec.rb +80 -83
- data/spec/lib/moose_inventory/cli/group_addvar_spec.rb +91 -91
- data/spec/lib/moose_inventory/cli/group_get_spec.rb +22 -23
- data/spec/lib/moose_inventory/cli/group_list_spec.rb +19 -20
- data/spec/lib/moose_inventory/cli/group_listvar_spec.rb +35 -36
- data/spec/lib/moose_inventory/cli/group_rm_spec.rb +115 -78
- data/spec/lib/moose_inventory/cli/group_rmchild_spec.rb +86 -45
- data/spec/lib/moose_inventory/cli/group_rmhost_spec.rb +43 -46
- data/spec/lib/moose_inventory/cli/group_rmvar_spec.rb +131 -131
- data/spec/lib/moose_inventory/cli/group_spec.rb +9 -9
- data/spec/lib/moose_inventory/cli/host_add_spec.rb +103 -43
- data/spec/lib/moose_inventory/cli/host_addgroup_spec.rb +78 -80
- data/spec/lib/moose_inventory/cli/host_addvar_spec.rb +122 -122
- data/spec/lib/moose_inventory/cli/host_get_spec.rb +16 -16
- data/spec/lib/moose_inventory/cli/host_list_spec.rb +8 -8
- data/spec/lib/moose_inventory/cli/host_listvar_spec.rb +50 -52
- data/spec/lib/moose_inventory/cli/host_rm_spec.rb +12 -12
- data/spec/lib/moose_inventory/cli/host_rmgroup_spec.rb +48 -51
- data/spec/lib/moose_inventory/cli/host_rmvar_spec.rb +136 -136
- data/spec/lib/moose_inventory/config/config_spec.rb +16 -3
- data/spec/lib/moose_inventory/db/db_spec.rb +386 -2
- data/spec/lib/moose_inventory/db/models_spec.rb +10 -11
- data/spec/lib/moose_inventory/operations/add_associations_spec.rb +77 -0
- data/spec/lib/moose_inventory/operations/add_groups_spec.rb +65 -0
- data/spec/lib/moose_inventory/operations/add_hosts_spec.rb +69 -0
- data/spec/lib/moose_inventory/operations/group_child_relations_spec.rb +76 -0
- data/spec/lib/moose_inventory/operations/remove_associations_spec.rb +78 -0
- data/spec/lib/moose_inventory/operations/remove_groups_spec.rb +57 -0
- data/spec/shared/shared_config_setup.rb +2 -2
- data/spec/spec_helper.rb +7 -8
- metadata +157 -105
- data/.coveralls.yml +0 -0
- data/Guardfile +0 -38
- data/config/dotfiles/coveralls.yml +0 -0
- data/config/dotfiles/gitignore +0 -20
- data/config/dotfiles/rubocop.yml +0 -793
- data/scripts/guard_quality.sh +0 -3
- data/scripts/guard_test.sh +0 -2
data/BACKLOG.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Moose Inventory Release Readiness Backlog
|
|
2
|
+
|
|
3
|
+
Release readiness status counts: 12 done / 1 open.
|
|
4
|
+
|
|
5
|
+
## Open
|
|
6
|
+
|
|
7
|
+
1. Verify RubyGems trusted publishing with the next real release tag.
|
|
8
|
+
- RubyGems trusted publisher is configured for repository `RusDavies/moose-inventory`, workflow `release.yml`, and environment `release`.
|
|
9
|
+
- Verify the full trusted-publishing path when publishing the next real version tag.
|
|
10
|
+
- Do not retag already-published `v1.0.9`.
|
|
11
|
+
|
|
12
|
+
## Done
|
|
13
|
+
|
|
14
|
+
1. Align release workflow with required CI security tooling.
|
|
15
|
+
- Security audit rerun found that `.github/workflows/release.yml` ran `./scripts/check.sh` without installing or requiring the dedicated security tools, meaning tag-based releases could skip `gitleaks`/`osv-scanner` enforcement if those tools were absent.
|
|
16
|
+
- Added Go setup with cache disabled, installed pinned security tools through `scripts/ci/install_security_tools.sh`, required `MOOSE_INVENTORY_REQUIRE_SECURITY_TOOLS=1` during the release check gate, and added the same native-dependency timeout used by CI.
|
|
17
|
+
- Documented the rerun in `docs/security-audit-2026-05-26-rerun.md`; final trusted-publishing proof remains gated on the next real release tag.
|
|
18
|
+
|
|
19
|
+
1. Add manual GitHub Actions CI trigger and harden CI runner setup.
|
|
20
|
+
- Added `workflow_dispatch` to `.github/workflows/ci.yml` so CI can be manually triggered when push events fail to enqueue during a GitHub Actions incident.
|
|
21
|
+
- Verified both push-triggered CI and manual `workflow_dispatch` CI runs succeeded on `master`.
|
|
22
|
+
- Disabled unused `actions/setup-go` caching for the Go-based security tools so the workflow no longer emits a missing-`go.mod` cache warning.
|
|
23
|
+
- Added a timeout to the native dependency installation step so runner package-manager stalls fail fast instead of hanging the matrix indefinitely.
|
|
24
|
+
|
|
25
|
+
1. Diagnose missing GitHub Actions runs after security-tooling merge.
|
|
26
|
+
- Confirmed the affected commits were pushed and visible on GitHub, with GitHub PushEvents recorded but no check runs created.
|
|
27
|
+
- Confirmed the workflow was active and visible, and GitHub Actions was degraded during the missing-run window due to platform-side authentication/startup issues.
|
|
28
|
+
- Conclusion: the missing runs were caused by a GitHub Actions incident, not by the repository workflow configuration.
|
|
29
|
+
|
|
30
|
+
1. Install optional local/CI security audit tools.
|
|
31
|
+
- Added `bundler-audit` as a development dependency and wired it into `scripts/ci/check_security.sh`.
|
|
32
|
+
- Added `scripts/ci/install_security_tools.sh` to install pinned `gitleaks` and `osv-scanner` CLI tools into `tmp/security-tools/bin` when they are not already on `PATH`.
|
|
33
|
+
- Added `scripts/ci/check_secrets.sh` and `.gitleaks.toml` so generated audit, coverage, and package-sanity artifacts stay out of dedicated secret scans.
|
|
34
|
+
- Updated GitHub Actions CI to install the Go-based audit tools and require them during `./scripts/check.sh`; local runs skip missing optional tools unless `MOOSE_INVENTORY_REQUIRE_SECURITY_TOOLS=1` is set.
|
|
35
|
+
|
|
36
|
+
1. Configure RubyGems trusted publisher for the existing gem.
|
|
37
|
+
- Repository-side trusted publishing workflow is present in `.github/workflows/release.yml`.
|
|
38
|
+
- RubyGems trusted publisher is configured for the `moose-inventory` gem with repository `RusDavies/moose-inventory`, workflow `release.yml`, and environment `release`.
|
|
39
|
+
- Evidence: RubyGems trusted publisher page shows GitHub Actions for `RusDavies/moose-inventory`, workflow `release.yml`, environment `release`.
|
|
40
|
+
|
|
41
|
+
1. Add GitHub Actions RubyGems trusted publishing.
|
|
42
|
+
- Added `.github/workflows/release.yml` triggered by `v*` tags.
|
|
43
|
+
- The workflow verifies the tag matches `Moose::Inventory::VERSION`, runs `./scripts/check.sh`, and publishes with `rubygems/release-gem@v1` using OIDC/trusted publishing.
|
|
44
|
+
- Updated `docs/release/publishing.md` and `docs/release/release-readiness.md` with trusted publishing release instructions and RubyGems setup requirements.
|
|
45
|
+
|
|
46
|
+
1. Resolve GitHub Actions Node.js 20 deprecation warning.
|
|
47
|
+
- Updated the CI workflow to use `actions/checkout@v5`, which runs on the Node.js 24 runtime.
|
|
48
|
+
- Verified with full `./scripts/check.sh` and a post-merge GitHub Actions run with no Node.js 20 deprecation annotations.
|
|
49
|
+
|
|
50
|
+
1. Decide and declare the supported Ruby version floor.
|
|
51
|
+
- Set `spec.required_ruby_version` to `>= 3.2` in the gemspec.
|
|
52
|
+
- Updated GitHub Actions CI to test Ruby `3.2`, `3.3`, and `3.4` so the declared floor remains exercised.
|
|
53
|
+
- Updated release-readiness documentation to describe matrix coverage.
|
|
54
|
+
|
|
55
|
+
1. Document manual RubyGems publishing.
|
|
56
|
+
- Added `docs/release/publishing.md` with the current manual release path: verify version, run `./scripts/check.sh`, push and wait for CI, build the gem, `gem push`, verify RubyGems, then tag the release.
|
|
57
|
+
- Noted that the repo currently has CI but no publishing workflow.
|
|
58
|
+
- Added the trusted-publishing follow-up as an open release-readiness item.
|
|
59
|
+
|
|
60
|
+
1. Create a release-readiness backlog.
|
|
61
|
+
- Added this release-readiness section to track post-modernization packaging/CI hardening separately from the completed modernization and fresh-pass backlogs.
|
|
62
|
+
|
|
63
|
+
1. Add CI/security gates to prevent regressions.
|
|
64
|
+
- Added `.github/workflows/ci.yml` for GitHub Actions on `master` pushes and pull requests.
|
|
65
|
+
- Expanded `./scripts/check.sh` to run the RSpec suite, `git diff --check`, executable-permission checks, OSV dependency advisory checks, and package sanity checks.
|
|
66
|
+
- Added `scripts/ci/check_permissions.sh` to keep executable bits limited to intentional entrypoints and scripts.
|
|
67
|
+
- Added `scripts/ci/check_security.sh` to query OSV for locked RubyGems dependency advisories.
|
|
68
|
+
|
|
69
|
+
1. Do a gem/package sanity pass.
|
|
70
|
+
- Added `scripts/ci/package_sanity.sh` to build the gem, inspect the packaged payload, verify required files, check executable metadata, and smoke-test the CLI version command.
|
|
71
|
+
- Documented the release-readiness gate in `docs/release/release-readiness.md`.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
# Moose Inventory GitHub Issues Backlog
|
|
76
|
+
|
|
77
|
+
GitHub issues status counts: 4 done / 0 open.
|
|
78
|
+
|
|
79
|
+
## Open
|
|
80
|
+
|
|
81
|
+
_No open GitHub issue items._
|
|
82
|
+
|
|
83
|
+
## Done
|
|
84
|
+
|
|
85
|
+
1. [#13 Need to refactor](https://github.com/RusDavies/moose-inventory/issues/13)
|
|
86
|
+
- Added shared `Moose::Inventory::Cli::Helpers` for command argument validation, name normalization, CSV option parsing, automatic `ungrouped` validation, association checks, and automatic group membership maintenance.
|
|
87
|
+
- Refactored representative host/group association commands to use the helper layer while preserving existing CLI output and behavior.
|
|
88
|
+
- Verified with focused CLI specs and full `./scripts/check.sh`.
|
|
89
|
+
|
|
90
|
+
1. [#12 Allow `group rm` to recursively delete orphaned child groups](https://github.com/RusDavies/moose-inventory/issues/12)
|
|
91
|
+
- Kept default deletion conservative: `group rm NAME` removes only the named group and preserves child groups as root groups.
|
|
92
|
+
- Added explicit `group rm --recursive NAME` to delete descendant groups only when they become orphaned by the removal.
|
|
93
|
+
- Added explicit `group rmchild --delete-orphans PARENT CHILD...` to remove parent-child associations and delete orphaned child subtrees.
|
|
94
|
+
- Preserved groups that still have another parent outside the removed edge/subtree.
|
|
95
|
+
- Preserved host safety by moving hosts whose last group is deleted to `ungrouped`.
|
|
96
|
+
- Added regression coverage for recursive deletion, shared-parent preservation, and host fallback to `ungrouped`.
|
|
97
|
+
|
|
98
|
+
1. [#4 `--trace` doesn't do what it claims](https://github.com/RusDavies/moose-inventory/issues/4)
|
|
99
|
+
- Reproduced the broken trace path: `--trace` attempted to print `$ERROR_INFO.backtrace` without requiring `English`, causing a secondary `NoMethodError` instead of a clean trace dump.
|
|
100
|
+
- Fixed Moose DB transaction trace handling to emit the actual exception full message/backtrace while preserving concise default errors.
|
|
101
|
+
- Added regression coverage for both trace and non-trace Moose DB transaction errors.
|
|
102
|
+
- Verified with full `./scripts/check.sh`.
|
|
103
|
+
|
|
104
|
+
1. [#14 Passwords in config files](https://github.com/RusDavies/moose-inventory/issues/14)
|
|
105
|
+
- Added `password_env` support for MySQL and PostgreSQL database configuration while preserving the existing `password` key for compatibility.
|
|
106
|
+
- Added regression coverage for missing password configuration, unset password environment variables, and environment-backed MySQL/PostgreSQL connection passwords.
|
|
107
|
+
- Updated README examples to use `password_env` instead of plaintext sample passwords and added credential-handling guidance.
|
|
108
|
+
- Verified with full `./scripts/check.sh`.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
# Moose Inventory Fresh Pass Backlog
|
|
113
|
+
|
|
114
|
+
Fresh pass status counts: 8 done / 0 open.
|
|
115
|
+
|
|
116
|
+
## Open
|
|
117
|
+
|
|
118
|
+
_No open fresh-pass items._
|
|
119
|
+
|
|
120
|
+
## Done
|
|
121
|
+
|
|
122
|
+
1. Refresh user-facing docs and setup scripts after DB support decisions.
|
|
123
|
+
- Fixed README typos/stale DB support notes and documented the tested support matrix: SQLite live file coverage plus MySQL/PostgreSQL adapter/error-path smoke coverage.
|
|
124
|
+
- Updated `scripts/install_dependencies.sh` for current Fedora package names, removing obsolete `mysql-utilities` and using client development headers for SQLite, MariaDB/MySQL, and PostgreSQL.
|
|
125
|
+
- Verified with full `./scripts/check.sh` and shell syntax check for the install script.
|
|
126
|
+
|
|
127
|
+
1. Add adapter/error-path smoke tests to the stable QA gate.
|
|
128
|
+
- Expanded DB specs included by `./scripts/check.sh` to cover documented adapter dispatch for SQLite, MySQL, and PostgreSQL.
|
|
129
|
+
- Added missing-key error-path smoke coverage for SQLite, MySQL, and PostgreSQL, alongside existing unsupported-adapter and nested SQLite path coverage.
|
|
130
|
+
- Verified with full `./scripts/check.sh`.
|
|
131
|
+
|
|
132
|
+
1. Harden YAML config loading.
|
|
133
|
+
- Replaced `YAML.load_file` with `YAML.safe_load_file` using no permitted classes, no permitted symbols, and aliases disabled.
|
|
134
|
+
- Added regression coverage ensuring config loading uses the safe YAML loader while preserving existing config fixture behavior.
|
|
135
|
+
- Verified with full `./scripts/check.sh`.
|
|
136
|
+
|
|
137
|
+
1. Use recursive directory creation for SQLite database paths.
|
|
138
|
+
- Replaced single-level `Dir.mkdir` with `FileUtils.mkdir_p` in `init_sqlite3`.
|
|
139
|
+
- Added regression coverage for nested SQLite database file paths.
|
|
140
|
+
- Verified with full `./scripts/check.sh`.
|
|
141
|
+
|
|
142
|
+
1. Fix existing-host group association logic in `host add --groups`.
|
|
143
|
+
- Fixed the association-existence condition so existing hosts can be associated with new groups and true duplicate associations are skipped with the existing warning.
|
|
144
|
+
- Added regression coverage for adding a new group to an existing host and idempotently skipping an existing association.
|
|
145
|
+
- Verified with full `./scripts/check.sh`.
|
|
146
|
+
|
|
147
|
+
1. Fix or de-scope PostgreSQL support.
|
|
148
|
+
- Implemented `init_postgresql` using the existing `pg` dependency and `Sequel.postgres`.
|
|
149
|
+
- Added regression coverage for PostgreSQL connection option wiring without requiring a live PostgreSQL server.
|
|
150
|
+
- Verified with full `./scripts/check.sh`.
|
|
151
|
+
|
|
152
|
+
1. Fix MySQL adapter support or remove it from advertised support.
|
|
153
|
+
- Fixed `DB.connect` to dispatch documented `adapter: mysql` instead of misspelled `msqsql`.
|
|
154
|
+
- Updated `init_mysql` to require `mysql2` and use `Sequel.mysql2`, matching the project dependency.
|
|
155
|
+
- Added regression coverage for MySQL adapter dispatch and connection option wiring without requiring a live MySQL server.
|
|
156
|
+
- Verified with full `./scripts/check.sh`.
|
|
157
|
+
|
|
158
|
+
1. Initialize/use DB exception classes before connection failures.
|
|
159
|
+
- Added DB exception initialization before connection setup so unsupported adapters raise `Moose::Inventory::DB::MooseDBException` instead of masking the intended error with `NoMethodError` on nil `@exceptions`.
|
|
160
|
+
- Added regression coverage for unsupported adapter initialization.
|
|
161
|
+
- Verified with full `./scripts/check.sh`.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
# Moose Inventory Modernization Backlog
|
|
166
|
+
|
|
167
|
+
Status counts: 10 done / 0 open.
|
|
168
|
+
|
|
169
|
+
## Open
|
|
170
|
+
|
|
171
|
+
_No open modernization items._
|
|
172
|
+
|
|
173
|
+
## Done
|
|
174
|
+
|
|
175
|
+
1. Review old QA tooling (`rubocop ~> 0`, Guard, Coveralls/SimpleCov setup) and decide what still belongs in the project.
|
|
176
|
+
- Removed obsolete RuboCop/Guard/Coveralls tooling after confirming current `rubocop 0.93.1` fails under Ruby 3.4 with missing bundled/default gems and obsolete config entries.
|
|
177
|
+
- Kept SimpleCov as the local coverage gate because the RSpec suite still passes with 95.16% line coverage against a 90% minimum.
|
|
178
|
+
- Added `scripts/check.sh` as the stable local QA entry point for `bundle exec rspec --format progress` and documented it in the README.
|
|
179
|
+
- Updated `scripts/reports.sh` to open the remaining SimpleCov HTML report only.
|
|
180
|
+
- Verified with `bundle lock`, `scripts/check.sh`, and `git diff --check`.
|
|
181
|
+
|
|
182
|
+
1. Modernize remaining stale runtime dependencies with care, especially `mysql2` and `sqlite3`.
|
|
183
|
+
- `pg` has been moved to a Ruby-3.4-compatible constraint.
|
|
184
|
+
- `json`, `sequel`, and `thor` have been moved to Ruby-3.4-compatible constraints.
|
|
185
|
+
- Tightened `mysql2` from `~> 0` to `>= 0.5.7, < 0.6`; Bundler keeps resolving `mysql2 0.5.7`.
|
|
186
|
+
- Relaxed/modernized `sqlite3` from `~> 1` to `>= 1.7, < 3`; Bundler now resolves `sqlite3 2.9.4`.
|
|
187
|
+
- Verified with `bundle update sqlite3 mysql2 --conservative` and `bundle exec rspec --format documentation`: 242 examples, 0 failures; line coverage 95.16%.
|
|
188
|
+
|
|
189
|
+
1. Generate and commit a current `Gemfile.lock` after deciding whether to stop ignoring it.
|
|
190
|
+
- Removed `/Gemfile.lock` from `.gitignore`.
|
|
191
|
+
- Generated `Gemfile.lock` with Bundler 2.6.9 under Ruby 3.4.8.
|
|
192
|
+
- Verified the lockfile baseline with `bundle exec rspec --format documentation`.
|
|
193
|
+
|
|
194
|
+
1. Update Ruby/Bundler dependency constraints so the project can resolve with current Bundler/Ruby.
|
|
195
|
+
- Changed the development dependency from `bundler ~> 1` to `bundler >= 1.17, < 3`.
|
|
196
|
+
- Verified dependency resolution with `bundle lock` under Ruby 3.4.8 / Bundler 2.6.9.
|
|
197
|
+
2. Provide Ruby development headers for native gem compilation.
|
|
198
|
+
- Russ installed `ruby-devel`; verified `/usr/include/ruby.h` exists.
|
|
199
|
+
- Full `bundle install` now gets past the Ruby header blocker.
|
|
200
|
+
3. Remove the stale direct `hitimes ~> 1` development dependency.
|
|
201
|
+
- Removed `spec.add_development_dependency 'hitimes', '~> 1'` from the gemspec.
|
|
202
|
+
- Removed `rubygem-hitimes` from `scripts/install_dependencies.sh`.
|
|
203
|
+
- `hitimes 1.3.1` failed to compile against Ruby 3.4 and was only referenced as legacy development tooling.
|
|
204
|
+
- Verified `bundle lock --print` no longer includes `hitimes`.
|
|
205
|
+
4. Move past missing database client headers.
|
|
206
|
+
- `bundle install` now builds/installs both `mysql2` and `pg` dependencies in this environment.
|
|
207
|
+
5. Update the stale `pg` dependency for Ruby 3.4 compatibility.
|
|
208
|
+
- Changed `pg` from `~> 0` to `>= 1.5, < 2`.
|
|
209
|
+
- Verified Bundler resolves `pg 1.6.3` instead of `pg 0.21.0`.
|
|
210
|
+
- Verified `bundle install` completes successfully under Ruby 3.4.8 / Bundler 2.6.9.
|
|
211
|
+
6. Run the existing RSpec suite and establish a green modern-Ruby baseline.
|
|
212
|
+
- Initial baseline exposed startup/runtime incompatibilities in old `thor`, `json`, and `sequel` constraints.
|
|
213
|
+
- Updated `json` from `~> 1` to `>= 2.7, < 3`.
|
|
214
|
+
- Updated `thor` from `~> 0` to `>= 1.3, < 2`.
|
|
215
|
+
- Updated `sequel` from `~> 4` to `>= 5.80, < 6`.
|
|
216
|
+
- Verified Bundler resolves `json 2.19.5`, `thor 1.5.0`, and `sequel 5.104.0`.
|
|
217
|
+
7. Fix RSpec harness compatibility with the current checkout/test flow.
|
|
218
|
+
- `spec_helper` now creates `tmp/` before deleting test database files, avoiding `Errno::ENOENT` on fresh clones.
|
|
219
|
+
- Config specs now pass an explicit fixture config when testing default option values.
|
|
220
|
+
- Ansible-mode CLI specs now pass the fixture config when invoking the top-level CLI.
|
|
221
|
+
- Updated the `--list` expectation for Ansible mode, which correctly includes empty `hosts` arrays.
|
|
222
|
+
- Verified `bundle exec rspec --format documentation`: 242 examples, 0 failures; line coverage 95.16%.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
# Moose Inventory Code Quality Backlog
|
|
227
|
+
|
|
228
|
+
Code quality status counts: 10 done / 0 open.
|
|
229
|
+
|
|
230
|
+
## Open
|
|
231
|
+
|
|
232
|
+
_No open code quality items._
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
## Done
|
|
236
|
+
|
|
237
|
+
1. Extract `group rm` to reuse the new group-cleanup / relation-operation seam.
|
|
238
|
+
- Added `Moose::Inventory::Operations::RemoveGroups` and reused `GroupCleanup` so top-level group deletion, recursive orphan cleanup, and host `ungrouped` reattachment now run through structured operation events instead of bespoke Thor logic.
|
|
239
|
+
- Converted `group rm` into a thinner adapter over `InventoryContext`, preserving `--recursive` behavior and existing CLI output.
|
|
240
|
+
- Added direct operation specs and expanded the targeted RuboCop gate to cover the new removal operation and adapter.
|
|
241
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
242
|
+
|
|
243
|
+
1. Extract the shared group-parent/child association flow behind `group addchild` and `group rmchild`.
|
|
244
|
+
- Added `Moose::Inventory::Operations::GroupChildRelations` and `GroupCleanup` to own parent/child link creation, dissociation, and recursive orphan-group cleanup with structured events.
|
|
245
|
+
- Converted `group addchild` and `group rmchild` into thinner adapters over `InventoryContext`, including `--delete-orphans` behavior without leaving the recursion logic buried in the CLI layer.
|
|
246
|
+
- Added direct operation specs and expanded the targeted RuboCop gate to cover the new parent/child relation seam.
|
|
247
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
248
|
+
|
|
249
|
+
1. Extract the shared host/group dissociation flow behind `host rmgroup` and `group rmhost`.
|
|
250
|
+
- Added `Moose::Inventory::Operations::RemoveAssociations` to own shared dissociation, missing-association handling, and automatic `ungrouped` reattachment behavior for existing primary entities.
|
|
251
|
+
- Converted `host rmgroup` and `group rmhost` into thinner adapters that retrieve the primary entity, delegate through `InventoryContext`, and render structured operation events.
|
|
252
|
+
- Added direct operation specs and expanded the targeted RuboCop gate to cover the new removal operation plus both adapter commands.
|
|
253
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
254
|
+
|
|
255
|
+
1. Extract the shared host/group association flow behind `host addgroup` and `group addhost`.
|
|
256
|
+
- Added `Moose::Inventory::Operations::AddAssociations` to own the shared association, auto-create, duplicate-check, and `ungrouped` removal behavior for existing primary entities.
|
|
257
|
+
- Converted `host addgroup` and `group addhost` into thinner adapters that retrieve the primary entity, delegate through `InventoryContext`, and render structured operation events.
|
|
258
|
+
- Added direct operation specs and expanded the targeted RuboCop gate to cover the new operation plus both adapter commands.
|
|
259
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
260
|
+
|
|
261
|
+
1. Extract `group add` into the operation/context/event pattern.
|
|
262
|
+
- Added `Moose::Inventory::Operations::AddGroups` with structured result/events and warning counts, mirroring the `host add` refactor pattern.
|
|
263
|
+
- Converted `group add` into a thin Thor adapter that validates input, delegates through `InventoryContext`, and renders operation events without changing CLI behavior.
|
|
264
|
+
- Added direct operation specs and extended the targeted RuboCop scope to cover the new operation/adapter/spec files.
|
|
265
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
266
|
+
|
|
267
|
+
1. Reintroduce a small modern lint/complexity gate.
|
|
268
|
+
- Added RuboCop as a development dependency and a targeted `.rubocop.yml` for the newly refactored seam instead of the whole legacy tree.
|
|
269
|
+
- Added `scripts/ci/check_rubocop.sh` and wired it into `./scripts/check.sh` so lint/complexity checks run in the standard local and CI gate.
|
|
270
|
+
- Kept the initial lint scope focused on the context/operation/helper/adapter files and direct operation spec, with thresholds strict enough to catch drift without forcing a repo-wide cleanup right now.
|
|
271
|
+
|
|
272
|
+
1. Separate first structured operation result from CLI rendering.
|
|
273
|
+
- Changed `Moose::Inventory::Operations::AddHosts` to return structured `Result`/`Event` objects instead of writing directly to stdout/stderr.
|
|
274
|
+
- Moved `host add` progress/warning rendering into the Thor adapter while preserving existing user-visible CLI output.
|
|
275
|
+
- Added direct operation specs proving inventory mutation and event emission without renderer output.
|
|
276
|
+
- Verified with focused specs and full `./scripts/check.sh`.
|
|
277
|
+
|
|
278
|
+
1. Introduce an inventory context facade around DB access.
|
|
279
|
+
- Added `Moose::Inventory::InventoryContext` as a thin wrapper over the existing DB singleton for transaction/model operations.
|
|
280
|
+
- Wired the `AddHosts` operation through the context, reducing direct DB coupling in the first extracted operation while leaving legacy CLI commands stable.
|
|
281
|
+
- Verified with focused `host add` specs and full `./scripts/check.sh`.
|
|
282
|
+
|
|
283
|
+
1. Extract first domain operation behind a Thor command.
|
|
284
|
+
- Added `Moose::Inventory::Operations::AddHosts` as the first operation/service object behind the CLI.
|
|
285
|
+
- Converted `host add` into a thin adapter that validates/normalizes CLI input and delegates inventory mutation to the operation.
|
|
286
|
+
- Preserved existing `host add` output and behavior under focused specs and full `./scripts/check.sh`.
|
|
287
|
+
|
|
288
|
+
1. Extract shared CLI helpers for low-risk issue #13 refactor.
|
|
289
|
+
- Added helper methods for common validation, normalization, association checks, and automatic `ungrouped` membership handling.
|
|
290
|
+
- Refactored selected host/group CLI commands without changing user-visible output.
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
moose-inventory (2.0)
|
|
5
|
+
indentation (~> 0)
|
|
6
|
+
json (>= 2.7, < 3)
|
|
7
|
+
mysql2 (>= 0.5.7, < 0.6)
|
|
8
|
+
pg (>= 1.5, < 2)
|
|
9
|
+
sequel (>= 5.80, < 6)
|
|
10
|
+
sqlite3 (>= 1.7, < 3)
|
|
11
|
+
thor (>= 1.3, < 2)
|
|
12
|
+
|
|
13
|
+
GEM
|
|
14
|
+
remote: https://rubygems.org/
|
|
15
|
+
specs:
|
|
16
|
+
ast (2.4.3)
|
|
17
|
+
bigdecimal (4.1.2)
|
|
18
|
+
bundler-audit (0.9.3)
|
|
19
|
+
bundler (>= 1.2.0)
|
|
20
|
+
thor (~> 1.0)
|
|
21
|
+
diff-lcs (1.6.2)
|
|
22
|
+
docile (1.4.1)
|
|
23
|
+
indentation (0.1.1)
|
|
24
|
+
json (2.19.5)
|
|
25
|
+
language_server-protocol (3.17.0.5)
|
|
26
|
+
lint_roller (1.1.0)
|
|
27
|
+
mysql2 (0.5.7)
|
|
28
|
+
bigdecimal
|
|
29
|
+
parallel (1.28.0)
|
|
30
|
+
parser (3.3.11.1)
|
|
31
|
+
ast (~> 2.4.1)
|
|
32
|
+
racc
|
|
33
|
+
pg (1.6.3-x86_64-linux)
|
|
34
|
+
prism (1.9.0)
|
|
35
|
+
racc (1.8.1)
|
|
36
|
+
rainbow (3.1.1)
|
|
37
|
+
rake (13.4.2)
|
|
38
|
+
regexp_parser (2.12.0)
|
|
39
|
+
rspec (3.13.2)
|
|
40
|
+
rspec-core (~> 3.13.0)
|
|
41
|
+
rspec-expectations (~> 3.13.0)
|
|
42
|
+
rspec-mocks (~> 3.13.0)
|
|
43
|
+
rspec-core (3.13.6)
|
|
44
|
+
rspec-support (~> 3.13.0)
|
|
45
|
+
rspec-expectations (3.13.5)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.13.0)
|
|
48
|
+
rspec-mocks (3.13.8)
|
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
+
rspec-support (~> 3.13.0)
|
|
51
|
+
rspec-support (3.13.7)
|
|
52
|
+
rubocop (1.86.2)
|
|
53
|
+
json (~> 2.3)
|
|
54
|
+
language_server-protocol (~> 3.17.0.2)
|
|
55
|
+
lint_roller (~> 1.1.0)
|
|
56
|
+
parallel (>= 1.10)
|
|
57
|
+
parser (>= 3.3.0.2)
|
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
59
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
60
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
61
|
+
ruby-progressbar (~> 1.7)
|
|
62
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
63
|
+
rubocop-ast (1.49.1)
|
|
64
|
+
parser (>= 3.3.7.2)
|
|
65
|
+
prism (~> 1.7)
|
|
66
|
+
ruby-progressbar (1.13.0)
|
|
67
|
+
sequel (5.104.0)
|
|
68
|
+
bigdecimal
|
|
69
|
+
simplecov (0.22.0)
|
|
70
|
+
docile (~> 1.1)
|
|
71
|
+
simplecov-html (~> 0.11)
|
|
72
|
+
simplecov_json_formatter (~> 0.1)
|
|
73
|
+
simplecov-html (0.13.2)
|
|
74
|
+
simplecov_json_formatter (0.1.4)
|
|
75
|
+
sqlite3 (2.9.4-x86_64-linux-gnu)
|
|
76
|
+
thor (1.5.0)
|
|
77
|
+
unicode-display_width (3.2.0)
|
|
78
|
+
unicode-emoji (~> 4.1)
|
|
79
|
+
unicode-emoji (4.2.0)
|
|
80
|
+
|
|
81
|
+
PLATFORMS
|
|
82
|
+
x86_64-linux
|
|
83
|
+
|
|
84
|
+
DEPENDENCIES
|
|
85
|
+
bundler (>= 2.2.33, < 3)
|
|
86
|
+
bundler-audit (>= 0.9, < 1)
|
|
87
|
+
moose-inventory!
|
|
88
|
+
parallel (>= 1.10, < 2.0)
|
|
89
|
+
rake (>= 13.0, < 14)
|
|
90
|
+
rspec (~> 3)
|
|
91
|
+
rubocop (>= 1.72, < 2)
|
|
92
|
+
simplecov (~> 0)
|
|
93
|
+
|
|
94
|
+
BUNDLED WITH
|
|
95
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -9,14 +9,13 @@ Note 2: This software is intended for use on UNIX/Linux systems. It will likely
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
Note: You may need to install
|
|
12
|
+
Note: You may need to install Ruby development headers and database client development packages on your system so native gems can build. On current Fedora releases, the project helper script installs the expected SQLite, MariaDB/MySQL, and PostgreSQL client headers.
|
|
13
13
|
|
|
14
14
|
The tool is a ruby gem. Assuming that you have ruby on your system, then it can be installed from the command line as follows.
|
|
15
15
|
|
|
16
16
|
$ gem install moose-inventory
|
|
17
17
|
|
|
18
|
-
Note: It may be
|
|
19
|
-
ve builds.
|
|
18
|
+
Note: It may be necessary to first install native build tools and database client development headers before installing the gem or running Bundler.
|
|
20
19
|
|
|
21
20
|
It can also be installed by adding the following line to a Gemfile and then executing `bundle`:
|
|
22
21
|
|
|
@@ -57,7 +56,7 @@ moose_ops:
|
|
|
57
56
|
host: "localhost"
|
|
58
57
|
database: "water"
|
|
59
58
|
user: "duck"
|
|
60
|
-
|
|
59
|
+
password_env: "MOOSE_INVENTORY_MYSQL_PASSWORD"
|
|
61
60
|
|
|
62
61
|
another_example_section:
|
|
63
62
|
db:
|
|
@@ -65,7 +64,7 @@ another_example_section:
|
|
|
65
64
|
host: "localhost"
|
|
66
65
|
database: "grass"
|
|
67
66
|
user: "cow"
|
|
68
|
-
|
|
67
|
+
password_env: "MOOSE_INVENTORY_POSTGRES_PASSWORD"
|
|
69
68
|
|
|
70
69
|
```
|
|
71
70
|
|
|
@@ -77,9 +76,18 @@ You may add as many environment sections as you desire. The intention is to enab
|
|
|
77
76
|
|
|
78
77
|
At present, each environment section contains only a **db** subsection, describing database connection parameters. Additional subsections may be added in the future, as functionality increases.
|
|
79
78
|
|
|
80
|
-
Each **db** section must include an **adapter** parameter. Currently supported adapter types are *sqlite3*, *mysql*, and *
|
|
79
|
+
Each **db** section must include an **adapter** parameter. Currently supported adapter types are *sqlite3*, *mysql*, and *postgresql*. The test suite exercises SQLite with a local database file and includes adapter dispatch/error-path smoke coverage for MySQL and PostgreSQL without requiring live database servers.
|
|
81
80
|
|
|
82
|
-
Additional parameters are also required in the **db** subsection, depending on the adapter type.
|
|
81
|
+
Additional parameters are also required in the **db** subsection, depending on the adapter type. For the *sqlite3* adapter only a **file** parameter is required; parent directories are created automatically. For both *mysql* and *postgresql*, **host**, **database**, **user**, and either **password_env** or **password** are required.
|
|
82
|
+
|
|
83
|
+
Prefer **password_env** for MySQL and PostgreSQL configuration. Its value is the name of an environment variable that contains the database password, which keeps reusable configuration files from carrying plaintext credentials:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
export MOOSE_INVENTORY_MYSQL_PASSWORD='use-a-real-secret-here'
|
|
87
|
+
moose-inventory --env moose_ops host list
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The older **password** key is still supported for compatibility, but avoid committing configuration files that contain database passwords. If you must use **password**, keep that configuration file outside version control and restrict its file permissions.
|
|
83
91
|
|
|
84
92
|
|
|
85
93
|
## Usage
|
|
@@ -304,10 +312,14 @@ We can also list hosts, to get the host-centric view.
|
|
|
304
312
|
- group2
|
|
305
313
|
- group3
|
|
306
314
|
|
|
307
|
-
Removing variables, groups, and hosts is just as easy. In the following examples, the output is again omitted for compactness; the reader is encouraged to work along to experience the tool. Note, that although we show how to remove the variables, it is not strictly necessary to do so in this example, since deleting hosts and groups would delete all associated variables anyway.
|
|
315
|
+
Removing variables, groups, and hosts is just as easy. In the following examples, the output is again omitted for compactness; the reader is encouraged to work along to experience the tool. Note, that although we show how to remove the variables, it is not strictly necessary to do so in this example, since deleting hosts and groups would delete all associated variables anyway.
|
|
316
|
+
|
|
317
|
+
By default, deleting a group preserves its child groups as root groups. Use `group rm --recursive` when child groups that become orphaned should also be deleted. Similarly, `group rmchild --delete-orphans` removes a parent-child association and deletes the child subtree only when it becomes orphaned by that removal. Hosts whose last group is deleted are automatically moved to `ungrouped`.
|
|
308
318
|
|
|
309
319
|
$ moose-inventory group rmvar group1 location
|
|
310
320
|
$ moose-inventory group rm group1 group2 group3
|
|
321
|
+
$ moose-inventory group rm --recursive old_parent_group
|
|
322
|
+
$ moose-inventory group rmchild --delete-orphans parent_group child_group
|
|
311
323
|
$ moose-inventory host rmvar
|
|
312
324
|
$ moose-inventory host rmvar host1 owner id
|
|
313
325
|
$ moose-inventory host rm host1 host2 host3
|
|
@@ -364,6 +376,24 @@ A useful aspect of dynamic inventories is the possibility of writing data to the
|
|
|
364
376
|
```
|
|
365
377
|
|
|
366
378
|
|
|
379
|
+
## Development checks
|
|
380
|
+
|
|
381
|
+
Run the local verification gate before committing changes:
|
|
382
|
+
|
|
383
|
+
```shell
|
|
384
|
+
./scripts/check.sh
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
The check script runs the RSpec suite, enforces the SimpleCov coverage minimum, checks file permissions, queries OSV for locked RubyGems advisories, runs `bundler-audit`, runs `gitleaks` when available, and builds/smoke-tests the packaged gem.
|
|
388
|
+
|
|
389
|
+
Optional Go-based security tools used by CI can be installed locally with:
|
|
390
|
+
|
|
391
|
+
```shell
|
|
392
|
+
./scripts/ci/install_security_tools.sh
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
That installs `gitleaks` and `osv-scanner` into `tmp/security-tools/bin` unless they are already on `PATH`. Fedora users can also run `./scripts/install_dependencies.sh` to install the native build dependencies and packaged `gitleaks`; `bundler-audit` is installed through Bundler.
|
|
396
|
+
|
|
367
397
|
## Contributing
|
|
368
398
|
1. Fork it (https://github.com/RusDavies/moose-inventory/fork )
|
|
369
399
|
2. Create your feature branch (git checkout -b my-new-feature`)
|
|
@@ -380,4 +410,3 @@ A useful aspect of dynamic inventories is the possibility of writing data to the
|
|
|
380
410
|
|
|
381
411
|
|
|
382
412
|
|
|
383
|
-
|
data/Rakefile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/moose-inventory
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Publishing to RubyGems
|
|
2
|
+
|
|
3
|
+
This project is published to RubyGems as [`moose-inventory`](https://rubygems.org/gems/moose-inventory).
|
|
4
|
+
|
|
5
|
+
The preferred publishing path is GitHub Actions trusted publishing from reviewed `v*` tags. Manual publishing remains documented as a fallback only.
|
|
6
|
+
|
|
7
|
+
## Trusted publishing setup
|
|
8
|
+
|
|
9
|
+
The repository side is `.github/workflows/release.yml`.
|
|
10
|
+
|
|
11
|
+
RubyGems has a trusted publisher configured for the existing `moose-inventory` gem on RubyGems.org with these values:
|
|
12
|
+
|
|
13
|
+
- Repository owner: `RusDavies`
|
|
14
|
+
- Repository name: `moose-inventory`
|
|
15
|
+
- Workflow filename: `release.yml`
|
|
16
|
+
- Environment: `release`
|
|
17
|
+
- Workflow repository owner/name: blank, because the workflow lives in this repository
|
|
18
|
+
|
|
19
|
+
The release workflow requires the GitHub environment name `release`. If that environment has protection rules, approve the deployment when releasing.
|
|
20
|
+
|
|
21
|
+
## Trusted publishing release checklist
|
|
22
|
+
|
|
23
|
+
1. Start from a clean `master` branch.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git checkout master
|
|
27
|
+
git pull --ff-only origin master
|
|
28
|
+
git status --short --branch
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. Confirm the version to publish.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ruby -e "require './lib/moose_inventory/version'; puts Moose::Inventory::VERSION"
|
|
35
|
+
gem info moose-inventory --remote --all
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the repository version is not higher than the latest RubyGems version, bump `lib/moose_inventory/version.rb` first and commit that change before releasing.
|
|
39
|
+
|
|
40
|
+
3. Run the local release gate.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
./scripts/check.sh
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. Push the release commit and wait for CI to pass.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git push origin master
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
5. Create and push the release tag from the exact commit to publish.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git tag -a v1.0.10 -m "Release moose-inventory 1.0.10"
|
|
56
|
+
git push origin v1.0.10
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
6. Watch the `Release gem` workflow.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
gh run list --workflow release.yml --limit 5
|
|
63
|
+
gh run watch <run-id> --exit-status
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The workflow verifies that the pushed tag version matches `Moose::Inventory::VERSION`, runs `./scripts/check.sh`, builds the gem through `rubygems/release-gem@v1`, and publishes using RubyGems trusted publishing/OIDC. No RubyGems API key should be stored in GitHub secrets for this workflow.
|
|
67
|
+
|
|
68
|
+
## Verify the published version
|
|
69
|
+
|
|
70
|
+
After the workflow succeeds:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
gem info moose-inventory --remote --all
|
|
74
|
+
gem install moose-inventory -v 1.0.10
|
|
75
|
+
moose-inventory --help
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Use the actual released version in place of `1.0.10`.
|
|
79
|
+
|
|
80
|
+
## Manual fallback
|
|
81
|
+
|
|
82
|
+
Manual publishing should only be used if trusted publishing is unavailable and a RubyGems owner explicitly chooses to publish from a local machine.
|
|
83
|
+
|
|
84
|
+
1. Run `./scripts/check.sh`.
|
|
85
|
+
2. Build the gem from the exact commit intended for release.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
rm -rf pkg tmp/pkg tmp/package-sanity
|
|
89
|
+
gem build moose-inventory.gemspec
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. Push the built gem.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
gem push moose-inventory-1.0.10.gem
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Prefer a scoped RubyGems API key over an old global key:
|
|
99
|
+
|
|
100
|
+
- Scope it to pushing gems, ideally only `moose-inventory` if RubyGems permits that for the account.
|
|
101
|
+
- Store it in `~/.gem/credentials` with file mode `0600` if publishing manually.
|
|
102
|
+
- Do not commit RubyGems credentials, `.gem/credentials`, shell history containing tokens, or generated private keys.
|
|
103
|
+
|
|
104
|
+
Check credential file permissions with:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
ls -l ~/.gem/credentials
|
|
108
|
+
chmod 0600 ~/.gem/credentials
|
|
109
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Release readiness notes
|
|
2
|
+
|
|
3
|
+
This project now has a small release-readiness gate intended to catch the regressions found during the modernization and security-audit passes.
|
|
4
|
+
|
|
5
|
+
## Local gate
|
|
6
|
+
|
|
7
|
+
Run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
./scripts/check.sh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The gate currently runs:
|
|
14
|
+
|
|
15
|
+
1. RSpec with coverage via the existing spec helper.
|
|
16
|
+
2. `git diff --check` for whitespace/conflict-marker issues in the working tree.
|
|
17
|
+
3. `scripts/ci/check_permissions.sh` to ensure only intentional tracked repository entrypoints are executable.
|
|
18
|
+
4. `scripts/ci/check_security.sh` to query OSV for locked RubyGems dependency advisories.
|
|
19
|
+
5. `scripts/ci/package_sanity.sh` to build the gem, inspect the packaged payload, and smoke-test the CLI version command.
|
|
20
|
+
|
|
21
|
+
## CI gate
|
|
22
|
+
|
|
23
|
+
GitHub Actions workflow: `.github/workflows/ci.yml`.
|
|
24
|
+
|
|
25
|
+
It installs native headers needed by the DB gems, runs the same `./scripts/check.sh` gate used locally, and tests the maintained Ruby version range through the GitHub Actions matrix.
|
|
26
|
+
|
|
27
|
+
## Trusted publishing gate
|
|
28
|
+
|
|
29
|
+
GitHub Actions workflow: `.github/workflows/release.yml`.
|
|
30
|
+
|
|
31
|
+
The release workflow runs when a `v*` tag is pushed. It:
|
|
32
|
+
|
|
33
|
+
1. Checks out the repository using `actions/checkout@v5`.
|
|
34
|
+
2. Installs Ruby and native database build dependencies.
|
|
35
|
+
3. Fails if the tag version does not match `Moose::Inventory::VERSION`.
|
|
36
|
+
4. Runs the full local `./scripts/check.sh` gate.
|
|
37
|
+
5. Publishes the gem with `rubygems/release-gem@v1` using RubyGems trusted publishing/OIDC.
|
|
38
|
+
|
|
39
|
+
RubyGems has a trusted publisher configured for repository `RusDavies/moose-inventory`, workflow `release.yml`, and environment `release`, so the workflow can request a short-lived publish token when a real release tag is pushed.
|
|
40
|
+
|
|
41
|
+
## Package sanity expectations
|
|
42
|
+
|
|
43
|
+
`package_sanity.sh` validates that the built gem includes at least:
|
|
44
|
+
|
|
45
|
+
- `bin/moose-inventory`
|
|
46
|
+
- `lib/moose_inventory.rb`
|
|
47
|
+
- `lib/moose_inventory/version.rb`
|
|
48
|
+
- `README.md`
|
|
49
|
+
- `LICENSE.txt`
|
|
50
|
+
|
|
51
|
+
It also verifies the gem metadata exposes the `moose-inventory` executable and that `bundle exec ruby -Ilib bin/moose-inventory --config spec/config/config.yml version` returns a version string.
|
|
52
|
+
|
|
53
|
+
## Dependency advisory expectations
|
|
54
|
+
|
|
55
|
+
`check_security.sh` reads `Gemfile.lock`, queries OSV's batch API for RubyGems packages, and fails on known vulnerabilities. This is intentionally simple and external-network-dependent; if OSV is unavailable, the gate fails closed so CI does not silently bless an unknown dependency state.
|