-
-
Notifications
You must be signed in to change notification settings - Fork 545
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
[RFC] Add 'optional' key to canonical-schema #1518
Conversation
@@ -92,6 +92,15 @@ is easier to understand with an example: | |||
} | |||
, "expected" : null | |||
} | |||
{ "description": "Foo'ing a very big number returns nothing" | |||
, "optional" : "big-ints" | |||
, "comments" : [ "Making this test case pass requires using BigInts." ] |
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 example in #1492 explains in the comments
that "Your track may choose to skip this test". That applies to all cases with an optional
-key, so it doesn't need to be added to every case, imo. The comment outlines why the test is optional.
@@ -118,6 +127,7 @@ There are also some conventions that must be followed: | |||
- If an error is expected (because the input is invalid, or any other reason), the value at `"expected"` should be an object containing exactly one property, `"error"`, whose value is a string. | |||
- The string should explain why the error would occur. | |||
- A particular track's implementation of the exercise **need not** necessarily check that the error includes that exact string as the cause, depending on what is idiomatic in the language (it may not be idiomatic to check strings for error messages). | |||
- Test cases that only some tracks should implement, for example because it would unnecessarily increase the complexity of the exercise in some but not all languages, mark it with an `optional`-key. Multiple cases related to the same reason for optionality should have the same key. The decision that a test case is optional will often be made in the PR discussion, so don't worry about it too much while creating a PR. |
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 decision that a test case is optional will often be made in the PR discussion, so don't worry about it too much while creating a PR.
This isn't really a convention that must be followed, but I've added it to not discourage contributors since the decision if a case only works on certain tracks isn't easy and requires input from multiple maintainers. However, I don't mind dropping it either if it doesn't fit this list.
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 like it!
@SaschaMann I think the WIP marker can be removed so we can merge this. |
A practical note: We should find a place to keep track of the values we use, since it would be a pity to have Perhaps even make a CI test that fails if one is used but isn't listed in this place. |
I prefer a similar solution to https://github.com/exercism/problem-specifications/blob/master/TOPICS.txt, but then for these keys. It's easy to build CI around that. |
#1496 is a meta discussion mentioning 5 things:
I propose that we either "A":
Or "B":
As @SleeplessByte says in #1496:
Forgive my ignorance, I do not understand the cost of being a test generator maintainer. If time is what we need, open source moves very slowly anyways. But it creates an organizational problem that we put "Depends on #1496" on a PR, when #1496 branches five-ways into directions with hours worth of reading before you know if the particular proposals have stalled because of personal indifferences, design problems, design impossibilities, lack of activity, or something else. So now I've went through all those and posted proposals to get the current PR's feature, because that's something I find to be missing on a weekly basis. |
When I opened this PR and added
there was still an on-going discussion whether or not we should add any keys. Since then we found out that an extra key doesn't break anything, so I'm in favour of merging them independantly from each other. Maintainers who prefer handling all the changes at once can wait for the other issues to be resolved.
There's a proposal in #1496 but no PR. (After reading the latest comments in #1496 I realise this comment probably belongs there instead. It's quite chaotic indeed)
@SleeplessByte In that case, could you add it to this PR? :) |
Yeah. This is my only concern. I like your proposals @sshine! |
Even if its useful to group addition of the other keys together, its also useful to concentrate on a single case for the first one. As the initiator of identity field (#1473), I'm having some progress with the alternative of slimming down the descriptions, but although the feedback is worthwhile its slow to work through. So I'm not yet ready to let go of #1473, but it may end up not needed. So I don't think #1473 should hold up this PR.
If #1496 was code in a PR, you'd wait for it to be closed. As a discussion, I'd only expect a comment on #1496 that this PR will proceed as the first test case. For me Proposal "A" is the way to go. |
In that case, can we focus on preventing divergence in values? I do find it valuable that the schema does not need to be updated every time we add another category of optional keys. We could, for example, create CI hook that gathers all existing optional keys like so:
and fails unless "new optional key: " is mentioned in the commit message? Then we avoid typos, and we're forced to recognize when new optional keys are introduced. |
I'd prefer having a text file with all optional keys. If a new key is in it or added to it, CI passes. Otherwise it fails. This makes it easier to look up which keys exist already. This doesn't require an update to the schema, it just requires a file like TOPICS.txt. However, I have no experience with |
@SleeplessByte wrote:
@SaschaMann wrote:
Then how about creating the file [
"floating-point",
"big-integer",
"unicode"
] Or alternatively a self-documenting file: {
"description": "This file contains values for the 'optional' field in tests.",
"optional": [
"floating-point",
"big-integer",
"unicode"
]
} |
I'll try to provide a CI script shortly. |
What's the benefit of a JSON file with just an array over a plain text file like TOPICS.txt? |
A common data format. It doesn't matter much to For parsing purposes, TOPICS.txt isn't a good example, because it contains headers. |
I don't think headers are necessary (for now anyway), just one key per line in a plain text fine seems fine.
I'd argue against JSON for this list in that case because the lack of trailing commas will result in two lines shown as changed in the diff when adding a key. This is a very minor thing obviously, but if there's no other benefit to JSON I feel like the added (tiny) annoyance isn't worth it, imo. |
@SaschaMann: I believe that since this PR is based on your So I kindly advice you to |
Additionally, create a plaintext file `OPTIONAL-KEYS.txt` in the root directory containing allowed values for the `optional` field in canonical-data.json according to #1518.
Strange, it's a branch on this repo, so you should be able to push to it. Anyway, I've cherry-picked the commit. Seems like a solid CI solution, thanks for writing it! I'll remove the [WIP], since it only needs reviewing now. |
Ah, shrug. There's a lot related to the GitHub workflows that I'm still getting used to. Also, I took the liberty of naming the file |
These changes look great @sshine . This is exactly like I wanted/preferred ❤️
ha |
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.
Great work!
WAIT FOR #1496 BEFORE MERGING
This adds the most-liked implementation of an optional key. See #1492, #1496 for more info.
Ideally this should be a draft PR, but I wanted CI to run to spot potential issues.