CASSJAVA-30: Update CONTRIBUTING.md#2041
Conversation
CONTRIBUTING.md
Outdated
| but in no way discouraged: it's generally a good idea to have a class-level comment that explains | ||
| where the component fits in the architecture, and anything else that you feel is important. | ||
| - **API packages:** must be documented. | ||
| - **Internal packages:** optional but encouraged—add a short class-level comment explaining the component’s role. |
CONTRIBUTING.md
Outdated
| Testing against an external process, using either of the tools: | ||
| - [Simulacron](https://github.com/datastax/simulacron): simulates Cassandra nodes on loopback. You “prime” it with expected query results. | ||
| *Example*: `NodeTargetingIT`. | ||
| - [CCM](https://github.com/pcmanus/ccm): launches actual Cassandra nodes locally. The `ccm` executable must be in the path. Pass variables like `-Dccm.version=5.0.0 -Dccm.dse=false` to specify the Cassandra version or distribution. |
There was a problem hiding this comment.
Should be -ccm.distribution=dse, not -Dccm.dse=false.
CONTRIBUTING.md
Outdated
| 1. Nullability: Please use the [Spotbugs annotations](https://spotbugs.github.io) to document nullability of new class or interface using the `@Nullable` and `@NonNull` annotations from the package `edu.umd.cs.findbugs.annotations`. | ||
| 2. Concurrency annotations: Please use the [JCIP annotations](http://jcip.net/annotations/doc/index.html) to document thread-safety. | ||
| 3. Static imports: Please only use static imports for AssertJ, Mockito, and Awaitility. | ||
| 4. `toString()`: only for debug in development. Use `toCqlLiteral()` is applicable for logs. |
There was a problem hiding this comment.
Shorten format does not tell the meaning of previous long description. Not all classes would have toCqlLiteral().
CONTRIBUTING.md
Outdated
| #### Integration Tests | ||
|
|
||
| 1. Install Cassandra Cluster Manager (CCM) following its [README](https://github.com/apache/cassandra-ccm). | ||
| 2. On macOS, enable loopback aliases: |
There was a problem hiding this comment.
Maybe explicitly mention On MacOS only, ...
|
I feel like the current state of this PR loses a lot of good suggestions and guidance about how new code should be structured. I'm wondering if we can't make a smaller set of edits to update what needs to be changed while still keeping most of the guidance in the current doc. |
|
I think realistically, no community contributor is gonna read 500+ lines before they submit a single PR. It makes sense for the onboarding of a full-time job, but it does not make sense for a community contributor, e.g., someone who maintains a library that uses the Java driver as a dependency and only plans to create one pull request. When they open such a long file, even if the file is nice and detailed, they are just gonna skip it. If you agree ^ this is true, then we gotta make it shorter. My 2 cents is that the following has lower priority and can be potentially removed:
It's rare that a community contributor submits a PR with this functional stream API. And when it happens, we can fix it in the PR review. Such things should be of low priority. I think those points ^ are all good to have, but are less important than a short CONTRIBUTING.md so that people actually read. But if you both think the longer version is better, I will rewrite it. Pls let me know what you think :) |
|
To remind myself: add instruction on how to change the stack size, either in this CONTRIBUTING.md, or CCM, or both. |
|
I added the existing CONTRIBUTING.md and made it long again. Please review at your earliest convenience! |
|
To remind myself, add JNA workaround for Mac M1: mvn dependency:get -Dartifact=net.java.dev.jna:jna:5.10.0 |
absurdfarce
left a comment
There was a problem hiding this comment.
A few things I really think need to be changed here, specifically the removal of the Google Group and the specification of a minimum Maven version. Otherwise my comments are fairly minor.
CONTRIBUTING.md
Outdated
|
|
||
| ### XML | ||
| ### Communication | ||
| 1. **Mailing List**: https://groups.google.com/a/lists.datastax.com/g/java-driver-user |
There was a problem hiding this comment.
This Google Group is no longer a means of communication for this project. The Python and CPP drivers both point users at ASF Slack instead (see here as an example) and we should as well.
It looks like the top-level README also needs to get a similar update... that's outside the scope of this PR and can be handled separately.
CONTRIBUTING.md
Outdated
|
|
||
| All code changes require: | ||
|
|
||
| 1. **A corresponding JIRA ticket** |
There was a problem hiding this comment.
We've been asked this question a few times and in general our policy is a bit loose here. We don't require a JIRA ticket for changes and I'm not sure I want to give the impression that that's a roadblock for users contributing code. We should certainly say that users are encouraged to create a JIRA ticket describing the problem and perhaps including what they'd like to see done to fix it... and then follow that up with a PR.
|
|
||
| **Do not** base a PR on another one. | ||
|
|
||
| **Do not** squash commits before the PR is ready to merge. |
There was a problem hiding this comment.
Out of curiosity... why not? If a user squashes commits on their PR branch and pushes what's the harm done?
There was a problem hiding this comment.
For example, if there is a PR that has one commit for a massive rename, and subsequent commits doing other things, then we want to keep that commit history in case we want to revert the massive rename.
But this is one of the many things in this CONTRIBUTING.md that I find trivial.
There was a problem hiding this comment.
agreed, makes it harder to understand what has changed if the history changes during a review.
There was a problem hiding this comment.
I guess I don't see this as a huge problem but agree it doesn't hurt anything to prohibit it in the general case.
CONTRIBUTING.md
Outdated
| ### Prerequisites | ||
|
|
||
| - **Java 8+** | ||
| - **Maven** |
There was a problem hiding this comment.
We have a minimum Maven version that's supported for the project; probably need to explicitly include that here. CASSJAVA-102 bumped that minimum up to 3.8.1 at least for 4.x.
|
|
||
| ## Development Setup | ||
|
|
||
| ### Prerequisites |
There was a problem hiding this comment.
This raises an interesting point: the pre-reqs mentioned below apply to 4.x but are different for 3.x. I don't know that we need to enumerate a full set of separate requirements for 3.x distinct from those for 4.x but we probably should at least say (1) these reqs apply to 4.x and (2) 3.x may have different (and likely older) requirements.
There was a problem hiding this comment.
If they want a development set up for 3.x then they should just look for the CONTRIBUTING.md in the 3.x branch. https://github.com/apache/cassandra-java-driver/blob/3.x/CONTRIBUTING.md
There was a problem hiding this comment.
Ah, entirely fair point... we can ignore this one!
| ``` | ||
| mvn clean install -DskipTests | ||
| ``` | ||
| - If IntelliJ uses a different Maven version, use the Maven window in IntelliJ: under `Lifecycle`, click `clean` and then `install`. |
There was a problem hiding this comment.
IIRC this is a two-step process:
- The user has to install a local version of the shaded Guava JAR into their Maven cache (which is what the command above does)
- The user has to ignore the project in the "Maven" flyout window in the upper right (because we want them to fall back into the version that's now installed in their Maven cache).
There was a problem hiding this comment.
From my experience, I didn't need to ignore the IntelliJ built-in maven, I just had to make the IntelliJ built-in maven to install the cache, too.
There was a problem hiding this comment.
Hmmmm, that was very definitely not adequate for me... but I'm fine rolling with this for now. We can deal with it on a case-by-case basis via Slack and update this if it becomes a problem (which I doubt it will).
| #### Integration Tests | ||
|
|
||
| 1. Install Cassandra Cluster Manager (CCM) following its [README](https://github.com/apache/cassandra-ccm). | ||
| 2. On MacOS only, enable loopback aliases: |
There was a problem hiding this comment.
This is added here for... Simulacron testing, right? Might be worth calling that out explicitly. As it stands now this text appears to refer to something required for ccm testing which I don't think is correct.
There was a problem hiding this comment.
Isn't loopback aliases for CCM testing? I always need to turn on loopback aliases whenever I use CCM
There was a problem hiding this comment.
yeah its needed for simulacron too since it uses the same local IP addresses. You don't have to install anything though, i guess we can note it here:
| 2. On MacOS only, enable loopback aliases: | |
| 2. **MacOS only**, for CCM and Simulacron-based tests, enable loopback aliases: |
There was a problem hiding this comment.
I don't have personal knowledge of the requirement; I don't run any of this on OS X. I'm just going by what the original CONTRIBUTING doc said on the topic.
|
PR updated! |
| - [General](#general) | ||
| - [Code Formatting and License Headers](#code-formatting-and-license-headers) | ||
| - [Javadoc](#javadoc) | ||
| - [Logging](#logging) |
There was a problem hiding this comment.
Looks like the actual section is titled Logs so this link is broken, but I like Logging better so mind changing the section name at line 231?
There was a problem hiding this comment.
👍 I very much agree that "Logging" is a better description for that section.
| ```bash | ||
| mvn clean install -DskipTests |
There was a problem hiding this comment.
Was curious about this, is running:
mvn clean install -DskipTests
before
mvn test
Actually necessary now?
I just purged my maven repo (rm -rf ~/.m2/repository) and ran mvn test as is and it worked.
There was a problem hiding this comment.
looks like this was required on #2045, but i suspect if on more recent commit this isn't needed anymore.
There was a problem hiding this comment.
if i rebase 2045 everything works fine
There was a problem hiding this comment.
This used to be required because of the need to have the shaded Guava JAR in place when compiling tests IIRC... I think I've still seen that behaviour fairly recently.
| ```shell | ||
| for i in {2..255}; do sudo ifconfig lo0 alias 127.0.0.$i up; done | ||
| ``` | ||
| Note: This may slow down networking. To remove the aliases after testing: |
There was a problem hiding this comment.
Unfortunately this looks to have gotten even worse on newer mac os versions. I wonder if we can get away with creating less aliases...will see if I can find a minimum.
There was a problem hiding this comment.
no need to change this for now, will find the minimum and can address separately
| ``` | ||
| To target a specific Cassandra version or distribution: | ||
| ``` | ||
| mvn verify -Dccm.version=3.11.0 |
There was a problem hiding this comment.
We should bump this to a newer version, primarily because a version this old won't work on arm based Macs, and also its nice to test against latest (more tests will run)
| mvn verify -Dccm.version=3.11.0 | |
| mvn verify -Dccm.version=5.0.6 |
However, I think for this to work we need a pointer to JDK 11, so maybe for now we target 4.1.11, and can think about how to update docs around running tests against newer cassandra versions as well which require newer JDKs:
| mvn verify -Dccm.version=3.11.0 | |
| mvn verify -Dccm.version=4.1.10 |
There was a problem hiding this comment.
After some testing , I think we can just use 5.0.6 with JDK 11 just fine, we should just advise using Java 11 in the docs (see above), i think it will be the most dependable and also has the advantage of being able to run most of the tests.
There was a problem hiding this comment.
Lets keep this @ 3.11.0 for now, as running with JDK 11 doesn't work reliably, will address in follow on
There was a problem hiding this comment.
It's meant as an example here for the user; presumably they'd tweak it for their own use case when they actually run it. There's certainly no harm in bumping this up to a newer version but even using 3.11.0 seems to illustrate the point well enough.
| ## Pre-commit hook (highly recommended) | ||
|
|
||
| Ensure `pre-commit.sh` is executable, then run: | ||
|
|
||
| ``` | ||
| ln -s ../../pre-commit.sh .git/hooks/pre-commit | ||
| ``` | ||
|
|
||
| This will only allow commits if the tests pass. It is also a good reminder to keep the test suite | ||
| short. | ||
|
|
||
| Note: the tests run on the current state of the working directory. I tried to add a `git stash` in | ||
| the script to only test what's actually being committed, but I couldn't get it to run reliably | ||
| (it's still in there but commented). Keep this in mind when you commit, and don't forget to re-add | ||
| the changes if the first attempt failed and you fixed the tests. | ||
|
|
||
| ## Speeding up the build for local tests | ||
|
|
||
| If you need to install something in your local repository quickly, you can use the `fast` profile to | ||
| skip all "non-essential" checks (licenses, formatting, tests, etc): | ||
|
|
||
| ``` | ||
| mvn clean install -Pfast | ||
| ``` | ||
|
|
||
| You can speed things up even more by targeting specific modules with the `-pl` option: | ||
|
|
||
| ``` | ||
| mvn clean install -Pfast -pl core,query-builder,mapper-runtime,mapper-processor,bom | ||
| ``` | ||
|
|
||
| Please run the normal build at least once before you push your changes. |
There was a problem hiding this comment.
Noticed this section was removed, but we did update pre-commit.sh should we keep this doc?
| ## Commits | ||
|
|
||
| Keep your changes **focused**. Each commit should have a single, clear purpose expressed in its | ||
| message. | ||
|
|
||
| Resist the urge to "fix" cosmetic issues (add/remove blank lines, move methods, etc.) in existing | ||
| code. This adds cognitive load for reviewers, who have to figure out which changes are relevant to | ||
| the actual issue. If you see legitimate issues, like typos, address them in a separate commit (it's | ||
| fine to group multiple typo fixes in a single commit). | ||
|
|
||
| Isolate trivial refactorings into separate commits. For example, a method rename that affects dozens | ||
| of call sites can be reviewed in a few seconds, but if it's part of a larger diff it gets mixed up | ||
| with more complex changes (that might affect the same lines), and reviewers have to check every | ||
| line. | ||
|
|
||
| Commit message subjects start with a capital letter, use the imperative form and do **not** end | ||
| with a period: | ||
|
|
||
| * correct: "Add test for CQL request handler" | ||
| * incorrect: "~~Added test for CQL request handler~~" | ||
| * incorrect: "~~New test for CQL request handler~~" | ||
|
|
||
| Avoid catch-all messages like "Minor cleanup", "Various fixes", etc. They don't provide any useful | ||
| information to reviewers, and might be a sign that your commit contains unrelated changes. | ||
|
|
||
| We don't enforce a particular subject line length limit, but try to keep it short. | ||
|
|
||
| You can add more details after the subject line, separated by a blank line. The following pattern | ||
| (inspired by [Netty](http://netty.io/wiki/writing-a-commit-message.html)) is not mandatory, but | ||
| welcome for complex changes: | ||
|
|
||
| ``` | ||
| One line description of your change | ||
|
|
||
| Motivation: | ||
|
|
||
| Explain here the context, and why you're making that change. | ||
| What is the problem you're trying to solve. | ||
|
|
||
| Modifications: | ||
|
|
||
| Describe the modifications you've done. | ||
|
|
||
| Result: | ||
|
|
||
| After your change, what will change. |
There was a problem hiding this comment.
I think this was generally good advice, but not something that has really been enforced for a while, so +1 to removing.
|
|
||
| ### Prerequisites | ||
|
|
||
| - **Java 8+** |
There was a problem hiding this comment.
Something that i bumped into is that it is very difficult to run with an up to date JDK 8 as newer OpenJDK build fail on Cassandra setting a very low stack size:
ccm start --wait-for-binary-proto --config-dir=/var/folders/ts/m0zplxmx30dcyp3ffzkgwpyw0000gn/T/ccm8054909345564425947 -v
b'\nThe stack size specified is too small, Specify at least 640k\n'
I wonder if for this reason, and that newer Cassandra versions (5.0+) require JDK11 we just advise folks use Java 11 at point?
| - **Java 8+** | |
| - **Java 8+** (Java 11+ is recommended) |
There was a problem hiding this comment.
Actually, lets keep this at Java 8 for now as I had some issues running with JDK 11, i'll create a follow on JIRA to address this 👍
tolbertam
left a comment
There was a problem hiding this comment.
This looks great, thank you @SiyaoIsHiding ! Added some commentary but this looks great. ready to +1 with some small adjustments
Co-authored-by: Andrew Tolbert <6889771+tolbertam@users.noreply.github.com>
Co-authored-by: Andrew Tolbert <6889771+tolbertam@users.noreply.github.com>
There was a problem hiding this comment.
I think I'm largely okay with the state of this change now; whatever nits I have are small enough that they can be addressed at some future date (if they need to be addressed at all). And there is so much goodness in this PR that I'd rather get it in than hold it up on nits.
I'm going to hold on giving an explicit 👍 until @tolbertam confirms that he's okay with what's here as well; I want to make sure all of his comments/questions are addressed to his satisfaction.
| - [General](#general) | ||
| - [Code Formatting and License Headers](#code-formatting-and-license-headers) | ||
| - [Javadoc](#javadoc) | ||
| - [Logging](#logging) |
There was a problem hiding this comment.
👍 I very much agree that "Logging" is a better description for that section.
|
|
||
| ## Development Setup | ||
|
|
||
| ### Prerequisites |
There was a problem hiding this comment.
Ah, entirely fair point... we can ignore this one!
| ``` | ||
| mvn clean install -DskipTests | ||
| ``` | ||
| - If IntelliJ uses a different Maven version, use the Maven window in IntelliJ: under `Lifecycle`, click `clean` and then `install`. |
There was a problem hiding this comment.
Hmmmm, that was very definitely not adequate for me... but I'm fine rolling with this for now. We can deal with it on a case-by-case basis via Slack and update this if it becomes a problem (which I doubt it will).
| ```bash | ||
| mvn clean install -DskipTests |
There was a problem hiding this comment.
This used to be required because of the need to have the shaded Guava JAR in place when compiling tests IIRC... I think I've still seen that behaviour fairly recently.
| #### Integration Tests | ||
|
|
||
| 1. Install Cassandra Cluster Manager (CCM) following its [README](https://github.com/apache/cassandra-ccm). | ||
| 2. On MacOS only, enable loopback aliases: |
There was a problem hiding this comment.
I don't have personal knowledge of the requirement; I don't run any of this on OS X. I'm just going by what the original CONTRIBUTING doc said on the topic.
| ``` | ||
| To target a specific Cassandra version or distribution: | ||
| ``` | ||
| mvn verify -Dccm.version=3.11.0 |
There was a problem hiding this comment.
It's meant as an example here for the user; presumably they'd tweak it for their own use case when they actually run it. There's certainly no harm in bumping this up to a newer version but even using 3.11.0 seems to illustrate the point well enough.
|
|
||
| **Do not** base a PR on another one. | ||
|
|
||
| **Do not** squash commits before the PR is ready to merge. |
There was a problem hiding this comment.
I guess I don't see this as a huge problem but agree it doesn't hurt anything to prohibit it in the general case.
| this makes the reviewers' job harder, because they have to re-read the full diff and figure out | ||
| where your new changes are. Instead, push a new commit on top of the existing history; it will be | ||
| squashed later when the PR gets merged. If the history is complex, it's a good idea to indicate in | ||
| the message where the changes should be squashed: |
There was a problem hiding this comment.
Interesting that we used to have this instruction in the CONTRIBUTING doc. It obviously doesn't apply anymore now that we've moved away from squash merges... but it does suggest to me that this might be a good place to provide instructions to a user about how do a squash via an interactive rebase. We can do that for user-contributed PRs but I'd kind of prefer to put that on the contributors if we can.
No description provided.