makeopensource / Classic-RPG

A classic role-playing game with an engine.
GNU General Public License v3.0
7 stars 19 forks source link

GitHub action to automatically run tests with Maven #36

Closed WeirdAlex03 closed 2 years ago

WeirdAlex03 commented 2 years ago

This is currently set to use the Zulu distribution of OpenJDK 16. Idk which distro we're using, but that can easily be changed if need be. The full list of distros is here, everything but Microsoft supports Java 16 here.

This requires Maven to be set up, and runs mvn package. The GitHub docs tells me "this command will download dependencies, build classes, run tests, and package classes into their distributable format, for example, a JAR file." That can also be easily changed.

Since Maven hasn't been set up yet, I'm holding this as a draft PR for now. Once we have Maven, I'll merge that into this and make any necessary changes.

This should also be squashed, but the only way I know to do in GitHub is when merging a PR. Maybe I'll figure out how to do it in the CLI sometime later when this is ready to be merged.

Closes #33

WeirdAlex03 commented 2 years ago

Current stage: it works when I run it locally, but not on GitHub. If I can't figure out what's missing or the output isn't helpful (ideally I'd like it to annotate the part that failed, not sure if that's possible with Maven/JUnit), then it might be worth it to try one of these methods: https://www.baeldung.com/junit-run-from-command-line

WeirdAlex03 commented 2 years ago

At this point I've just resorted to throwing stuff at the wall to see and sticks, and I gotta be honest, I'm out of ideas here. Nothing sticks; everything just keeps sliding down to the floor.

The script works fine when I run it locally in IntelliJ, but I can't figure out why it doesn't find the tests when run here. If anyone has any more ideas, please let me know or try them yourself.

You can see all the runs here. When you open one, select "Build and Run Tests" and open "Run ..." to see the logs.

jakesavi commented 2 years ago

skipping non existing resourceDirectory /home/runner/work/Classic-RPG/Classic-RPG/src/main/resources This is the location of junit. Its clearly skipping this. Why? It does compile the maven but just skips the resources folder which contains the junit.jar

WeirdAlex03 commented 2 years ago

I get that running it locally too, so I don't think it's a problem. From my (not very good) understanding, I think that's just extra recourses. However, you just led me a step closer to the solution. I was going to copy my output here for comparassion, and apparently running "test" in IntelliJ doesn't run mvn test on the command line. It actually runs this monster of a command:

C:\Users\----------\.jdks\openjdk-17.0.2\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\----------\IdeaProjects\Classic-RPG "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\lib\idea_rt.jar=64193:C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2021.3.2 test

When I installed Maven and actually ran mvn test, I got the same problem as on GitHub where no tests are found. So running tests with Maven doesn't work locally, IntelliJ is just lying to my face to make me look like a fool. No wonder Trevor hates it...

WeirdAlex03 commented 2 years ago

Current thing I left off on at the end of the meeting today: https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven

jakesavi commented 2 years ago

So no surefire anymore huh? Says to use built innmaven support instead. Does this help solve the issue or is this another problem in the cookie jar?

WeirdAlex03 commented 2 years ago

After 4 months and 37 commits, this is finally feature complete! 🥳

There's still a couple touch-ups left to make and merge conflicts to resolve (I should be able to commit out at least two of conflicting changes), then we can squash and merge

WeirdAlex03 commented 2 years ago

Conflicts are resolved through the power of rebasing and force pushing!

Ready to (squash and) merge!

russella26 commented 2 years ago

finally. congratulations :)