-
-
Notifications
You must be signed in to change notification settings - Fork 54
Add badge setting in README #337
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
base: master
Are you sure you want to change the base?
Conversation
|
Not sure about the coveralls badge. I don't know when coveralls is available. The check for lib directory is from https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/Rakefile.erb#L35 |
e8e924c to
9e17ee3
Compare
|
Shall I add the puppetforge badges too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds functionality to automatically update README badge URLs based on module settings. The feature searches for a specific placeholder comment in README.md files and replaces it with dynamically generated badges for build status, code coverage, and license information.
Key Changes:
- Added
update_readme_badgesmethod to generate and insert badges into README files - Integrated badge updates into the module sync workflow to run after managed files are processed
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def self.update_readme_badges(puppet_module) | ||
| return unless File.exist?(puppet_module.path('README.md')) | ||
|
|
||
| content = File.read(puppet_module.path('README.md')) | ||
| badge_regex = %r{^\[//\]: # \(modulesync badge placeholder, do not remove\)$} | ||
|
|
||
| build_status = "\n" | ||
| code_coverage = "[](https://coveralls.io/github/voxpupuli/#{puppet_module.repository_name})\n" | ||
| license = "[](LICENSE)\n" | ||
|
|
||
| badges = build_status | ||
| badges << license | ||
| badges << code_coverage if Dir.exist?(File.expand_path('./lib', puppet_module.path)) | ||
| content.gsub!(badge_regex, badges.chomp) | ||
|
|
||
| File.write(puppet_module.path('README.md'), content) | ||
| end |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new update_readme_badges method lacks test coverage. Given that the repository has existing test files for ModuleSync methods, this new method should have corresponding tests to verify its behavior, including edge cases like missing placeholder comments, various directory structures, and proper badge generation.
lib/modulesync.rb
Outdated
| build_status = "\n" | ||
| code_coverage = "[](https://coveralls.io/github/voxpupuli/#{puppet_module.repository_name})\n" |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch name 'master' is hardcoded in all badge URLs. Different repositories may use different default branch names (e.g., 'main'). Consider making the branch name configurable or detecting it from the repository settings.
| build_status = "\n" | |
| code_coverage = "[](https://coveralls.io/github/voxpupuli/#{puppet_module.repository_name})\n" | |
| default_branch = ENV['MODULESYNC_DEFAULT_BRANCH'] || 'master' | |
| build_status = "\n" | |
| code_coverage = "[](https://coveralls.io/github/voxpupuli/#{puppet_module.repository_name})\n" |
eeec172 to
6afefb4
Compare
Check README for specific comments and if found render badges between them. Refs: voxpupuli/plumbing#84
6afefb4 to
248d36c
Compare
ekohl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this belongs in modulesync itself. This is really specific for Vox Pupuli. Not everything has code coverage, file names may be different for other repos, etc.
IMHO we should drop all badges from READMEs because they're really pointless in many cases. For published entries (like on the Forge) they will point to master but is that really correct if you look at an older release?
Instead I think we should implement a hooks mechanism in modulesync so this can live within a modulesync config.
|
Hey @ekohl, I will set this to draft for now so it does not accidentally merged. |
|
#305 has been open for quite some time, but that would make it easier. Perhaps the path to take? |
|
Hm I did not know there was already something. But wouldn't it make more sense to have hook-implementations in modulesync_configs, possibly even with enable/disable filters on top via modulesync.yml |
|
That's what #305 aims to do. Right now the hook must live within modulesync itself, but that doesn't make sense. So by making the path completely configurable you can set it in |
Check README for a specific comment and if found replace badge URLs based on module settings.
Refs: voxpupuli/plumbing#84