frc2609/rapid-react-robot-code-2022

Output code version number in RoboRIO log

Closed this issue · 4 comments

The version number of each build should be clearly visible in the RoboRIO (could use System.out.println)

Idea: modify the gradlew.bat file to get the hash of the current commit and store that into a file called hash.txt in the directory \src\main\deploy.

Add git rev-parse HEAD > .\src\main\deploy\hash.txt to the beginning of the gradlew.bat file.

Just need to figure out how to read from the deploy folder on the roboRio...

Will do that now

I see the PR you put up for the change and it looks good. Before I merge it though, I just wanted to know if you did any testing to ensure that the code is doing what it is supposed to?

If I was trying to test this, I would do these things:

  • Verify that the file hash.txt was created in the src/main/deploy directory
  • Verify that the contents of hash.txt is output to the robot console at the correct time (in this case, when the robot is enabled I think?)
  • create a new commit (can just be a dummy commit such as adding/removing a whitespace somewhere) and verify that the contents of hash.txt have the correct commit hash (you can check your current commit hash using git rev-parse HEAD)
  • Remove the line git rev-parse HEAD > .\src\main\deploy\hash.txt from gradlew.bat and ensure that the code fails as it is supposed to (the code should enter the catch statement in printVersion() since the file should not be found)
    • unable to test this since removing file from deploy folder does not remove it from the roboRio

Those four have been tested, although removing git rev-parse still displays the version number despite hash.txt not existing...