-
Notifications
You must be signed in to change notification settings - Fork 444
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
base: master
Are you sure you want to change the base?
Commit generated files #1410
Conversation
- Add `verify_generated` task to Rakefile - Always run rubocop on generated files
🚀 Preview deployment available at: https://e07354f1.rdoc-6cd.pages.dev (commit: 7ad0910) |
456de24
to
7ad0910
Compare
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.
+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}" |
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.
In general, sh("command", "arg1", "arg2", ...)
is safer than sh("command line")
:
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}" |
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.
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:" |
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.
No argument puts
may be more (a bit) readble than \n
:
puts "\nDifferences found:" | |
puts | |
puts "Differences found:" |
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
andrbs
anddebug
can avoid this issue by committing generated files and verifying them on CI, I think we should do that too.