1*78c4dd6aSAndroid Build Coastguard Worker# Contributing to the Suite 2*78c4dd6aSAndroid Build Coastguard Worker 3*78c4dd6aSAndroid Build Coastguard WorkerAll contributors to the test suite should familiarize themselves with this document. 4*78c4dd6aSAndroid Build Coastguard Worker 5*78c4dd6aSAndroid Build Coastguard WorkerBoth pull requests *and* reviews are welcome from any and all, regardless of their "formal" relationship (or lack thereof) with the JSON Schema organization. 6*78c4dd6aSAndroid Build Coastguard Worker 7*78c4dd6aSAndroid Build Coastguard Worker## Commit Access 8*78c4dd6aSAndroid Build Coastguard Worker 9*78c4dd6aSAndroid Build Coastguard WorkerAny existing members with commit access to the repository may nominate new members to get access, or a contributor may request access for themselves. 10*78c4dd6aSAndroid Build Coastguard WorkerAccess generally should be granted liberally to anyone who has shown positive contributions to the repository or organization. 11*78c4dd6aSAndroid Build Coastguard WorkerAll who are active in other parts of the JSON Schema organization should get access to this repository as well. 12*78c4dd6aSAndroid Build Coastguard WorkerAccess for a former contributor may be removed after long periods of inactivity. 13*78c4dd6aSAndroid Build Coastguard Worker 14*78c4dd6aSAndroid Build Coastguard Worker## Reviewing a Pull Request 15*78c4dd6aSAndroid Build Coastguard Worker 16*78c4dd6aSAndroid Build Coastguard WorkerPull requests may (and often should) be reviewed for approval by a single reviewer whose job it is to confirm the change is specified, correct, minimal and follows general style in the repository. 17*78c4dd6aSAndroid Build Coastguard WorkerA reviewer who does not feel comfortable signing off on the correctness of a change is free to comment without explicit approval. 18*78c4dd6aSAndroid Build Coastguard WorkerOther contributors are also encouraged to comment on pull requests whenever they have feedback, even if another contributor has submitted review comments. 19*78c4dd6aSAndroid Build Coastguard WorkerA submitter may also choose to request additional feedback if they feel the change is particularly technical or complex, or requires expertise in a particular area of the specification. 20*78c4dd6aSAndroid Build Coastguard WorkerIf additional reviewers have participated in a pull request, the submitter should not rely on a single reviewer's approval without some form of confirmation that all participating reviewers are satisfied. 21*78c4dd6aSAndroid Build Coastguard WorkerOn the other hand, whenever possible, reviewers who have minor comments should explicitly mention that they are OK with the PR being merged after or potentially *without* addressing them. 22*78c4dd6aSAndroid Build Coastguard Worker 23*78c4dd6aSAndroid Build Coastguard WorkerWhen submitting a change, explicitly soliciting a specific reviewer explicitly is currently not needed, as the entire review team is generally pinged for pull requests. 24*78c4dd6aSAndroid Build Coastguard WorkerNevertheless, submitters may choose to do so if they want specific review from an individual, or if a pull request is sitting without review for a period of time. 25*78c4dd6aSAndroid Build Coastguard WorkerFor the latter scenario, leaving a comment on the pull request or in Slack is also reasonable. 26*78c4dd6aSAndroid Build Coastguard Worker 27*78c4dd6aSAndroid Build Coastguard WorkerConfirming that a pull request runs successfully on an implementation is *not* generally sufficient to merge, though it is helpful evidence, and highly encouraged. 28*78c4dd6aSAndroid Build Coastguard WorkerProposed changes should be confirmed by reading the specification and ensuring the behavior is specified and correct. 29*78c4dd6aSAndroid Build Coastguard WorkerSubmitters are encouraged to link to the specification whenever doing so will be helpful to a reviewer. 30*78c4dd6aSAndroid Build Coastguard Worker 31*78c4dd6aSAndroid Build Coastguard WorkerA reviewer may indicate that the proposed changes are too large for them to review. 32*78c4dd6aSAndroid Build Coastguard WorkerIn such cases the submitter may wait for another reviewer who is comfortable reviewing the changes, but is generally strongly encouraged to split up the changes into multiple smaller ones. 33*78c4dd6aSAndroid Build Coastguard Worker 34*78c4dd6aSAndroid Build Coastguard WorkerReviewing pull requests is an extremely valuable contribution! 35*78c4dd6aSAndroid Build Coastguard WorkerNew reviewers are highly encouraged to attempt to review pull requests even if they do not have experience doing so, and to themselves expect feedback from the submitter or from other reviewers on improving the quality of their reviews. 36*78c4dd6aSAndroid Build Coastguard WorkerIn such cases the submitter should use their judgement to decide whether the new contributor's review is sufficient for merging, or whether they should wait for further feedback. 37*78c4dd6aSAndroid Build Coastguard Worker 38*78c4dd6aSAndroid Build Coastguard Worker## Merging Changes 39*78c4dd6aSAndroid Build Coastguard Worker 40*78c4dd6aSAndroid Build Coastguard WorkerApproval of a change may be given using the GitHub UI or via a comment reply. 41*78c4dd6aSAndroid Build Coastguard WorkerOnce it has been given, the pull request may be merged at any point. 42*78c4dd6aSAndroid Build Coastguard Worker 43*78c4dd6aSAndroid Build Coastguard WorkerTo merge a pull request, *either* the submitter or reviewer must have commit access to the repo (though this is also partially simply because that party's access is needed to merge). 44*78c4dd6aSAndroid Build Coastguard Worker 45*78c4dd6aSAndroid Build Coastguard Worker*Either* the submitter or reviewer may be the one to do the actual merge (whether via hitting the merge button or externally to the GitHub UI). 46*78c4dd6aSAndroid Build Coastguard WorkerIf the submitter wishes to make final changes after a review they should attempt to say so (and thereby take responsibility for merging themselves). 47*78c4dd6aSAndroid Build Coastguard WorkerContributors *should not* leave pull requests stagnant whenever possible, and particularly after they have been reviewed and approved. 48*78c4dd6aSAndroid Build Coastguard Worker 49*78c4dd6aSAndroid Build Coastguard WorkerChanges should not be merged while continuous integration is failing. 50*78c4dd6aSAndroid Build Coastguard WorkerFailures typically are not spurious and indicate issues with the changes. 51*78c4dd6aSAndroid Build Coastguard WorkerIn the event the change is indeed correct and CI is flaky or itself incorrect, effort should be made by the submitter, reviewer, or a solicited other contributor to fix the CI before the change is made. 52*78c4dd6aSAndroid Build Coastguard WorkerImprovements to CI itself are very valuable as well, and reviewers who find repeated issues with proposed changes are highly encouraged to improve CI for any changes which may be automatically detected. 53*78c4dd6aSAndroid Build Coastguard Worker 54*78c4dd6aSAndroid Build Coastguard WorkerChanges should be merged *as-is* and not squashed into single commits. 55*78c4dd6aSAndroid Build Coastguard WorkerSubmitters are free to structure their commits as they wish throughout the review process, or in some cases to restructure the commits after a review is finished and they are merging the branch, but are not required to do so, and reviewers should not do so on behalf of the submitter without being requested to do so. 56*78c4dd6aSAndroid Build Coastguard Worker 57*78c4dd6aSAndroid Build Coastguard WorkerContributors with commit access may choose to merge pull requests (or commit directly) to the repository for trivial changes. 58*78c4dd6aSAndroid Build Coastguard WorkerThe definition of "trivial" is intentionally slightly ambiguous, and intended to be followed by good-faith contributors. 59*78c4dd6aSAndroid Build Coastguard WorkerAn example of a trivial change is fixing a typo in the README, or bumping a version of a dependency used by the continuous integration suite. 60*78c4dd6aSAndroid Build Coastguard WorkerIf another contributor takes issue with a change merged in this fashion, simply commenting politely that they have concerns about the change (either in an issue or directly) is the right remedy. 61*78c4dd6aSAndroid Build Coastguard Worker 62*78c4dd6aSAndroid Build Coastguard Worker## Writing Good Tests 63*78c4dd6aSAndroid Build Coastguard Worker 64*78c4dd6aSAndroid Build Coastguard WorkerBe familiar with the test structure and assumptions documented in the [README](README.md). 65*78c4dd6aSAndroid Build Coastguard Worker 66*78c4dd6aSAndroid Build Coastguard WorkerTest cases should include both valid and invalid instances which exercise the test case schema whenever possible. 67*78c4dd6aSAndroid Build Coastguard WorkerExceptions include schemas where only one result is ever possible (such as the `false` schema, or ones using keywords which only produce annotations). 68*78c4dd6aSAndroid Build Coastguard Worker 69*78c4dd6aSAndroid Build Coastguard WorkerSchemas should be *minimal*, by which we mean that they should contain only those keywords which are being tested by the specific test case, and should not contain complex values when simpler ones would do. 70*78c4dd6aSAndroid Build Coastguard WorkerThe same applies to instances -- prefer simpler instances to more complex ones, and when testing string instances, consider using ones which are self-descriptive whenever it aids readability. 71*78c4dd6aSAndroid Build Coastguard Worker 72*78c4dd6aSAndroid Build Coastguard WorkerComments can and should be used to explain tests which are unclear or complex. 73*78c4dd6aSAndroid Build Coastguard WorkerThe `comment` field is present both for test cases and individual tests for this purpose. 74*78c4dd6aSAndroid Build Coastguard WorkerLinks to the relevant specification sections are also encouraged, though they can be tedious to maintain from one version to the next. 75*78c4dd6aSAndroid Build Coastguard Worker 76*78c4dd6aSAndroid Build Coastguard WorkerWhen adding test cases, they should be added to all past (and future) versions of the specification which they apply to, potentially with minor modifications (e.g. changing `$id` to `id` or accounting for `$ref` not allowing siblings on older drafts). 77*78c4dd6aSAndroid Build Coastguard Worker 78*78c4dd6aSAndroid Build Coastguard WorkerChanging the schema used in a particular test case should be done with extra caution, though it is not formally discouraged if the change simplifies the schema. 79*78c4dd6aSAndroid Build Coastguard WorkerContributors should not generally append *additional* behavior to existing test case schemas, unless doing so has specific justification. 80*78c4dd6aSAndroid Build Coastguard WorkerInstead, new cases should be added, as it can often be subtle to predict which precise parts of a test case are unique. 81*78c4dd6aSAndroid Build Coastguard WorkerAdding additional *tests* however (instances) is of course safe and encouraged if gaps are found. 82*78c4dd6aSAndroid Build Coastguard Worker 83*78c4dd6aSAndroid Build Coastguard WorkerTests which are *incorrect* (against the specification) should be prioritized for fixing or removal whenever possible, as their continued presence in the suite can create confusion for downstream users of the suite. 84*78c4dd6aSAndroid Build Coastguard Worker 85*78c4dd6aSAndroid Build Coastguard Worker## Proposing Changes to the Policy 86*78c4dd6aSAndroid Build Coastguard Worker 87*78c4dd6aSAndroid Build Coastguard WorkerThis policy itself is of course changeable, and changes to it may be proposed in a discussion. 88