-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add contributing task #605
base: master
Are you sure you want to change the base?
Conversation
Hey, I'm a bit lost how the workflow works: It asks me a question where my tests are located. What tests? Existing tests for the library I want to add? I thought it creates some test stubs which I have then to implement. I ran the task
|
@TaskAction | ||
void run() throws IOException { | ||
InteractiveTaskUtils.printUserInfo("Hello! This task will help you contributing to metadata repository." + | ||
" Please answer the following contributingQuestions. In case you don't know the answer on the question, type \"help\" for more information"); |
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.
Please answer the following contributingQuestions
I would reword that to: "Please answer the following questions".
Okay, after cleaning up some empty directories it now continues, but then crashes with:
I'm using
|
Okay, i retried with a GraalVM 17, and now it looks better. One thing to note: I first added metadata for 2.12, and then for 2.11. Now the metadata index.json looks like this: [ {
"metadata-version" : "2.12",
"tested-versions" : [ "2.12" ],
"module" : "de.mkammerer:argon2-jvm"
}, {
"metadata-version" : "2.11",
"tested-versions" : [ "2.11" ],
"latest" : true,
"module" : "de.mkammerer:argon2-jvm"
} ] I don't think the |
I also noticed in the {
"allowed-packages" : [ "de.mkammerer.argon2", "de.mkammerer" ],
"directory" : "de.mkammerer/argon2-jvm",
"module" : "de.mkammerer:argon2-jvm"
} I get where the |
Now I've tried to add tests which not only need JUnit, but also some more dependencies (in this case In the first run, I've omitted Awaitility just to see what happens, and it breaks (which I guess is expected):
Then i reran [ {
"metadata-version" : "2.12",
"tested-versions" : [ "2.12" ],
"module" : "de.mkammerer:argon2-jvm"
}, {
"metadata-version" : "2.12",
"tested-versions" : [ "2.12" ],
"latest" : true,
"module" : "de.mkammerer:argon2-jvm"
} ] The first |
private void createStubs(boolean shouldUpdate){ | ||
InteractiveTaskUtils.printUserInfo("Generating stubs for: " + coordinates ); | ||
if (shouldUpdate) { | ||
invokeCommand("gradle scaffold --coordinates " + coordinates + " --update", "Cannot generate stubs for: " + coordinates); |
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'd use the gradle wrapper here, as using the global gradle
can lead to all sort of problems if the versions don't match.
Path allTests = originalTestsLocation.resolve("."); | ||
|
||
InteractiveTaskUtils.printUserInfo("Removing dummy test stubs"); | ||
invokeCommand("rm -r " + destination, "Cannot delete files from: " + destination); |
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 won't work under Windows. And please make sure that the destination are really the tests (maybe by double-checking that the destination is under the project dir), as this could be dangerous.
invokeCommand("rm -r " + destination, "Cannot delete files from: " + destination); | ||
|
||
InteractiveTaskUtils.printUserInfo("Copying tests from: " + originalTestsLocation + " to " + destination); | ||
invokeCommand("cp -a " + allTests + " " + destination, "Cannot copy files to: " + destination); |
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.
Won't work under windows.
Path destination = testsDirectory.resolve("src").resolve("test"); | ||
InteractiveTaskUtils.printUserInfo("Copying resources from: " + originalResourcesDirectory + " to " + destination); | ||
|
||
invokeCommand("cp -r " + originalResourcesDirectory + " " + destination, "Cannot copy files to: " + destination); |
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.
Won't work under Windows.
private void addUserCodeFilterFile(List<String> packages) throws IOException { | ||
InteractiveTaskUtils.printUserInfo("Generating " + USER_CODE_FILTER_FILE); | ||
|
||
ConfigurationStringBuilder sb = new ConfigurationStringBuilder(); |
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.
Wouldn't be an object which is then written to JSON via the ObjectMapper
better here?
invokeCommand("git", List.of("commit", "-m", "Add metadata for " + coordinates), "Cannot commit changes", null); | ||
|
||
InteractiveTaskUtils.printUserInfo("Pushing changes"); | ||
invokeCommand("git push origin " + branch, "Cannot push to origin"); |
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 assumes you are working on a fork, right? Because that would fail if a user just cloned the reachability repo and doesn't have write privileges to the repo.
public class FilesUtils { | ||
|
||
public static void findJavaFiles(Path root, List<Path> result) { | ||
if (Files.exists(root) && Files.isRegularFile(root) && root.toString().endsWith(".java")) { |
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 could also be implemented with java.nio.file.Files#walkFileTree()
.
}, | ||
{ | ||
"question-key": "testsLocation", | ||
"question": "Where are your tests implemented? Absolute path to the directory containing java packages where you implemented tests: ", |
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'd reword that. It wasn't clear to me that those are the existing tests for the library I want to add.
{ | ||
"question-key": "additionalDependencies", | ||
"question": "What additional testImplementation dependencies you want to include? Enter the next dependency (to stop type \"-\")", | ||
"help": "Enter the testImplementation dependencies (pres enter after each dependency) you want to include use in tests. Provide dependencies in form of Maven coordinates. Maven coordinates consist of three parts in the following format \"groupId:artifactId:version\". For more information visit: https://maven.apache.org/repositories/artifacts.html When you finish adding dependencies, type \"-\" to terminate the inclusion process" |
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.
Typo: "pres" instead of "press".
{ | ||
"question-key": "shouldCreatePullRequest", | ||
"question": "Do you want to create a pull request to the reachability metadata repository [Y/n]:", | ||
"help": "In case you want to open a pull request to Reachability metadata repository automatically, type \"y\". This way the task will create a new branch for you, commit changes with a proper message, and push the branch remotly. At the end, the task will give you a link to the Github repository where you should fill in a pull request checkslist and complete the process." |
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.
Typo: "remotly".
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.
Typo: "checkslist".
this issue is already reported here |
What does this PR do?
Adds interactive task that helps users to contribute to the metadata repository. The user only needs to provide path to tests and answer few questions in order to make a fully usable pull request.
For reviewers: