Skip to content
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

Java CI Test Failed, Gradle Test Passed Locally #253

Closed
WeeeHung opened this issue Oct 12, 2023 · 6 comments
Closed

Java CI Test Failed, Gradle Test Passed Locally #253

WeeeHung opened this issue Oct 12, 2023 · 6 comments

Comments

@WeeeHung
Copy link

Prior to pushing new commits to the pull request, I did Gradle Test locally in my Intellij (Windows) using ./gradlew clean test. It passed all cases and showed the following.

image

Nonetheless, after I push these commits, it failed all Java CI Checks initially (ie. for ubuntu, macos, windows).
I then rerun the Java CI Check twice without pushing new commits as I was sure that the 5 errors shown were fixed, and this time ubuntu and windows managed to pass the CI Test.

However, the Java CI Check for Macos still did not pass and is now showing the same 5 errors as mentioned earlier. The mentioned errors can be found in this GitHub Actions Log.

Group members with different OS (ie. Macos and ubuntu) have tried running gradle test locally and passed all cases as well.
How else should I be debugging this or is it a GIthub Actions/ Java CI issue?

@damithc
Copy link
Contributor

damithc commented Oct 12, 2023

@WeeeHung While waiting for others to chime in, you can try rerunning CI a few more times to see if some pattern emerges or if it is totally random.

@WZWren
Copy link

WZWren commented Oct 12, 2023

I am part of @WeeeHung's team, and I wanted to update that we have been rerunning CI a few times already, and only the runner on macOS seems to encounter this issue. The error was always caused by a JsonMappingException from the fasterxml library, but we are unable to trace the error as we can't access the error log on the runner in the workflow.

@oeggy03
Copy link

oeggy03 commented Oct 12, 2023

Instead of running gradlew clean test, you can run gradlew clean build, and see if it tells you any more useful info

Also, you can trying rolling back or upgrading the version of fasterxml/jackson databind in dependencies of your build.gradle to see if it works. Currently it's

 implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
 implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'

https://github.com/FasterXML/jackson-databind you can refer to this and try one of the newer versions. Seems like 2.7.0 was quite a while ago

Just throwing ideas I too am confused. But my best guess is that the version of fasterxml you have in your project isn't stable for mac specifically somehow

@WeeeHung
Copy link
Author

Thank you for the idea. I have tried rolling back and upgrading to a number of versions. Both did not work. For upgrading specifically, it introduced a new issue, where relative paths are deserialised into absolute paths, causing some assertions to fail.

ie.
org.opentest4j.AssertionFailedError: expected: <seedu.address.commons.core.Config{logLevel=INFO, userPrefsFilePath=preferences.json}> but was: <seedu.address.commons.core.Config{logLevel=INFO, userPrefsFilePath=C:\CS2103T\tp\preferences.json}>

With regards to the pattern,

@WeeeHung While waiting for others to chime in, you can try rerunning CI a few more times to see if some pattern emerges or if it is totally random.

I just found it strange that sometimes the Java CI check fails on Windows and Ubuntu with the same errors as macos, but this get fixed after rerunning. I guess the only pattern here is rerunning works for Windows and Ubuntu.

@damithc
Copy link
Contributor

damithc commented Oct 13, 2023

@WeeeHung Another general debugging technique you can use (to locate the problem code) is to create a new PR and incrementally add the changes in this PR to the new PR, to figure out precisely which part of the code is causing this problem.

On a related note, it is best if upgrading of dependencies (e.g., JavaFX version, JUnit version) are done in separate PRs so that their effect can be isolated, and they are easier to roll back later (should the need arise).

@WeeeHung
Copy link
Author

WeeeHung commented Oct 13, 2023

Thank you so much prof, we have just figured out the issue and all OS is now passing the CI Check.

The problem was with the overloaded JsonAdaptedPerson Constructor that we have created. We overloaded the constructor because we added new fields to Person Constructor but have yet to make corresponding changes in Test folder. As a result of this overloaded constructor, Windows OS occasionally fails and Macos always fails potentially due to how they interact with the JsonCreator and JsonProperty.

Before

@JsonCreator
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("nric") String nric,
                             @JsonProperty("phone") String phone, @JsonProperty("email") String email,
                             @JsonProperty("address") String address, @JsonProperty("appointment") String appointment,
                             @JsonProperty("medicalHistories") List<JsonAdaptedMedicalHistory> medicalHistories,
            @JsonProperty("tags") List<JsonAdaptedTag> tags) 
            
public JsonAdaptedPerson(@JsonProperty("name") String name,
                             @JsonProperty("phone") String phone, @JsonProperty("email") String email,
                             @JsonProperty("address") String address,
                             @JsonProperty("tags") List<JsonAdaptedTag> tags) {

After

@JsonCreator
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("nric") String nric,
                             @JsonProperty("phone") String phone, @JsonProperty("email") String email,
                             @JsonProperty("address") String address, @JsonProperty("appointment") String appointment,
                             @JsonProperty("medicalHistories") List<JsonAdaptedMedicalHistory> medicalHistories,
            @JsonProperty("tags") List<JsonAdaptedTag> tags) 
            
public JsonAdaptedPerson(String name,
                             String phone, String email,
                             String address,
                             List<JsonAdaptedTag> tags) {

Thank you all for the debugging suggestions. Credits @WZWren

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants