Skip to content

Commit generated files #1410

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Commit generated files #1410

wants to merge 4 commits into from

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Aug 14, 2025

Closes #1107 and will likely prevent issues like https://bugs.ruby-lang.org/issues/21541 in the future

With ignoring generated files in the source control, we always need one extra step to make the gem usable, which limits how the gem can be distributed (#1107) and make post-distribution issues easier to happen (which are in general harder to fix too).

If gems like prism and rbs and debug can avoid this issue by committing generated files and verifying them on CI, I think we should do that too.

st0012 added 2 commits August 14, 2025 13:44
- Add `verify_generated` task to Rakefile
- Always run rubocop on generated files
@matzbot
Copy link
Collaborator

matzbot commented Aug 14, 2025

🚀 Preview deployment available at: https://e07354f1.rdoc-6cd.pages.dev (commit: 7ad0910)

@st0012 st0012 marked this pull request as draft August 14, 2025 13:37
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

rb_file = parser_file.gsub(/\.ry\z/, ".rb")
ruby "#{racc} -l -E -o #{rb_file} #{parser_file}"
sh "bundle exec racc -l -E -o #{rb_file} #{parser_file}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, sh("command", "arg1", "arg2", ...) is safer than sh("command line"):

Suggested change
sh "bundle exec racc -l -E -o #{rb_file} #{parser_file}"
sh "bundle", "exec", "racc", "-l", "-E", "-o", rb_file, parser_file

rb_file = parser_file.gsub(/\.kpeg\z/, ".rb")
ruby "#{kpeg} -fsv -o #{rb_file} #{parser_file}"
sh "bundle exec kpeg -fsv -o #{rb_file} #{parser_file}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sh "bundle exec kpeg -fsv -o #{rb_file} #{parser_file}"
sh "bundle", "exec", "kpeg", "-fsv", "-o", rb_file, parser_file

unless $?.success?
puts "Generated parser files are out of date!"
puts "Please run 'rake generate' and commit the changes."
puts "\nDifferences found:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No argument puts may be more (a bit) readble than \n:

Suggested change
puts "\nDifferences found:"
puts
puts "Differences found:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RDoc doesn't have complete files when being installed from git/github source
3 participants