-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
Reorder keys #1960
Reorder keys #1960
Conversation
|
||
Dir.glob('exercises/*/canonical-data.json').each do |path| | ||
json = JSON.parse(File.read(path)) | ||
invalid_tests = find_tests(json).select {|test| (CORRECT_ORDER & test.keys) != test.keys} |
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.
Nice
bin/check_key_order.rb
Outdated
|
||
exit_code = 0 | ||
|
||
Dir.glob('exercises/*/canonical-data.json').each do |path| |
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.
You could parallize this :P
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.
Good idea!
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.
Can't read the Ruby script but otherwise this looks good
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 know about the Ruby, but the resulting JSON looks good.
bin/check_key_order.rb
Outdated
|
||
puts "#{path} has tests with the wrong key order:" | ||
invalid_tests.each do |test| | ||
puts "- Test: #{test['uuid']}" |
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.
Perhaps this should include the description similarly to the mutation-check so that it's easier to find without CTRL F
43d902a
to
03dc630
Compare
@SaschaMann I've added the description to the output. How do we want to merge this? As on squashed commit, two commits or many individual commits? My preference would be for the second option, but I'm fine with whatever. |
I like it if the resulting changes are bundled with the script, that way it makes it easier to understand what actually changed if you can't read workflows or Ruby files. 1st and 2nd option both seem fine though, the 3rd seems a bit too noisy. |
I would just squash it. |
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 particular preference between two commits vs one.
bin/check_key_order.rb
Outdated
|
||
exit_code = 0 | ||
|
||
Dir.glob('exercises/*/canonical-data.json').each do |path| |
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.
this has made it so that this can only be run from the root of the problem-specifications
repo. If you want to instead make it runnable from anywhere, you should express the path relative from bin
.
Dir.glob('exercises/*/canonical-data.json').each do |path| | |
Dir.glob("#{__dir__}/../exercises/*/canonical-data.json").each do |path| |
But, I do not actually expect wanting to run it from anywhere else to be something that is often desired, so I'm Approving (in the GitHub sense of the word) anyway regardless of whether this change is made.
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've applied the change, with a minor change to allow the printed path to be slightly clearer
03dc630
to
caff42c
Compare
Thanks everyone! |
This PR makes the order of the keys in the
canonical-data.json
files consistent and adds a CI check to verify its order.This is just a minor improvement, so if people are not convinced this is useful, I'm happy to not go through with this.
See https://github.com/ErikSchierboom/problem-specifications/runs/5158116886?check_suite_focus=true for an example of the output.
Closes #1705