From 8345fb271627e97bc15ce6e77e1436ef0a3c7624 Mon Sep 17 00:00:00 2001 From: Lewis-Seiden <70111132+Lewis-Seiden@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:27:39 -0800 Subject: [PATCH 1/7] Create README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..e0e8b3cb --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# FRC 8033 2024 Robot Code + +This is Highlander Robotics' code for the 2024 FRC season, Crescendo From 6fa107aa46451eb88483c2d22fccb6046296e608 Mon Sep 17 00:00:00 2001 From: Lewis-Seiden <70111132+Lewis-Seiden@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:12:59 -0800 Subject: [PATCH 2/7] add build ci check --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..f79d55d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +# This is a basic workflow to build robot code. + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch. +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # This grabs the WPILib docker container + container: wpilib/roborio-cross-ubuntu:2023-22.04 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Declares the repository safe and not under dubious ownership. + - name: Add repository to git safe directories + run: git config --global --add safe.directory $GITHUB_WORKSPACE + + # Grant execute permission for gradlew + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + # Runs a single command using the runners shell + - name: Compile and run tests on robot code + run: ./gradlew build From 6a722d168e5bb284bca4ed21a41d2dd3a2f3c2ad Mon Sep 17 00:00:00 2001 From: Lewis-Seiden <70111132+Lewis-Seiden@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:19:38 -0800 Subject: [PATCH 3/7] Create check-format.yml --- .github/workflows/check-format.yml | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/check-format.yml diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml new file mode 100644 index 00000000..c30cb3ad --- /dev/null +++ b/.github/workflows/check-format.yml @@ -0,0 +1,37 @@ +# This is a basic workflow to check robot code formatting using spotless. + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch. +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + # This workflow contains a single job called "build" + check-format: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # This grabs the WPILib docker container + container: wpilib/roborio-cross-ubuntu:2023-22.04 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Declares the repository safe and not under dubious ownership. + - name: Add repository to git safe directories + run: git config --global --add safe.directory $GITHUB_WORKSPACE + + # Grant execute permission for gradlew + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + # Runs a single command using the runners shell + - name: Compile and run tests on robot code + run: ./gradlew spotlessCheck From 7acf64341a25141940f801be1c2d1240a52a3dce Mon Sep 17 00:00:00 2001 From: Lewy Seiden Date: Tue, 26 Dec 2023 16:20:52 -0800 Subject: [PATCH 4/7] renamed CI tasks --- .github/workflows/build.yml | 2 +- .github/workflows/check-format.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f79d55d7..a32956aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ # This is a basic workflow to build robot code. -name: CI +name: Build # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the main branch. diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index c30cb3ad..5cfaa550 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -1,6 +1,6 @@ # This is a basic workflow to check robot code formatting using spotless. -name: CI +name: Format # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the main branch. From 503ea589d7f676dead191c2d62897eacd95e3e1d Mon Sep 17 00:00:00 2001 From: Lewy Seiden Date: Tue, 26 Dec 2023 16:21:43 -0800 Subject: [PATCH 5/7] call correct spotless command in ci --- .github/workflows/check-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 5cfaa550..50b0d296 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -34,4 +34,4 @@ jobs: # Runs a single command using the runners shell - name: Compile and run tests on robot code - run: ./gradlew spotlessCheck + run: ./gradlew spotlessJavaCheck From 45f6b27a02ddcb28800cb6bfdc0d13c08a2422fb Mon Sep 17 00:00:00 2001 From: Lewy Seiden Date: Tue, 26 Dec 2023 16:31:32 -0800 Subject: [PATCH 6/7] added spotless --- build.gradle | 55 +++++++++++++++++-- src/main/java/frc/robot/BuildConstants.java | 16 +++--- src/main/java/frc/robot/Robot.java | 23 +++++--- .../subsystems/swerve/GyroIOPigeon2.java | 3 +- .../frc/robot/subsystems/swerve/Module.java | 2 - .../frc/robot/subsystems/swerve/Swerve.java | 1 - 6 files changed, 71 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 4568c92f..7b02f3fa 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id "java" id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-3" id "com.peterabeles.gversion" version "1.10" + id 'com.diffplug.spotless' version '6.12.0' } java { @@ -78,12 +79,12 @@ dependencies { project.compileJava.dependsOn(createVersionFile) gversion { - srcDir = "src/main/java/" - classPackage = "frc.robot" - className = "BuildConstants" - dateFormat = "yyyy-MM-dd HH:mm:ss z" - timeZone = "America/Los_Angeles" // Use preferred time zone - indent = " " + srcDir = "src/main/java/" + classPackage = "frc.robot" + className = "BuildConstants" + dateFormat = "yyyy-MM-dd HH:mm:ss z" + timeZone = "America/Los_Angeles" // Use preferred time zone + indent = " " } test { @@ -136,3 +137,45 @@ task(checkAkitInstall, dependsOn: "classes", type: JavaExec) { } compileJava.finalizedBy checkAkitInstall +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + toggleOffOn() + googleJavaFormat() + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + } + groovyGradle { + target fileTree('.') { + include '**/*.gradle' + exclude '**/build/**', '**/build-*/**' + } + greclipse() + indentWithSpaces(4) + trimTrailingWhitespace() + endWithNewline() + } + format 'xml', { + target fileTree('.') { + include '**/*.xml' + exclude '**/build/**', '**/build-*/**' + } + eclipseWtp('xml') + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() + } + format 'misc', { + target fileTree('.') { + include '**/*.md', '**/.gitignore' + exclude '**/build/**', '**/build-*/**' + } + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() + } +} diff --git a/src/main/java/frc/robot/BuildConstants.java b/src/main/java/frc/robot/BuildConstants.java index bc3470f2..72a3472e 100644 --- a/src/main/java/frc/robot/BuildConstants.java +++ b/src/main/java/frc/robot/BuildConstants.java @@ -1,19 +1,17 @@ package frc.robot; -/** - * Automatically generated file containing build version information. - */ +/** Automatically generated file containing build version information. */ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "Crescendo"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 1; - public static final String GIT_SHA = "74bd01533dc406974f649117016c7eb366ba95dd"; - public static final String GIT_DATE = "2023-12-09 20:05:14 PST"; + public static final int GIT_REVISION = 7; + public static final String GIT_SHA = "503ea589d7f676dead191c2d62897eacd95e3e1d"; + public static final String GIT_DATE = "2023-12-26 16:21:43 PST"; public static final String GIT_BRANCH = "main"; - public static final String BUILD_DATE = "2023-12-09 21:56:18 PST"; - public static final long BUILD_UNIX_TIME = 1702187778024L; + public static final String BUILD_DATE = "2023-12-26 16:28:40 PST"; + public static final long BUILD_UNIX_TIME = 1703636920080L; public static final int DIRTY = 1; - private BuildConstants(){} + private BuildConstants() {} } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 4e4932d1..5a072559 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -4,6 +4,11 @@ package frc.robot; +import edu.wpi.first.wpilibj.PowerDistribution; +import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.CommandScheduler; +import edu.wpi.first.wpilibj2.command.Commands; import org.littletonrobotics.junction.LogFileUtil; import org.littletonrobotics.junction.LoggedRobot; import org.littletonrobotics.junction.Logger; @@ -11,18 +16,13 @@ import org.littletonrobotics.junction.wpilog.WPILOGReader; import org.littletonrobotics.junction.wpilog.WPILOGWriter; -import edu.wpi.first.wpilibj.PowerDistribution; -import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.CommandScheduler; -import edu.wpi.first.wpilibj2.command.Commands; - public class Robot extends LoggedRobot { public static enum RobotMode { SIM, REPLAY, REAL } + public static final RobotMode mode = Robot.isReal() ? RobotMode.REAL : RobotMode.SIM; private Command autonomousCommand; @@ -54,16 +54,21 @@ public void robotInit() { break; case REPLAY: setUseTiming(false); // Run as fast as possible - String logPath = LogFileUtil.findReplayLog(); // Pull the replay log from AdvantageScope (or prompt the user) + String logPath = + LogFileUtil + .findReplayLog(); // Pull the replay log from AdvantageScope (or prompt the user) Logger.setReplaySource(new WPILOGReader(logPath)); // Read replay log - Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log + Logger.addDataReceiver( + new WPILOGWriter( + LogFileUtil.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log break; case SIM: Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables break; } - Logger.start(); // Start logging! No more data receivers, replay sources, or metadata values may be added. + Logger.start(); // Start logging! No more data receivers, replay sources, or metadata values may + // be added. } @Override diff --git a/src/main/java/frc/robot/subsystems/swerve/GyroIOPigeon2.java b/src/main/java/frc/robot/subsystems/swerve/GyroIOPigeon2.java index 5e30c65d..f8cb5a23 100644 --- a/src/main/java/frc/robot/subsystems/swerve/GyroIOPigeon2.java +++ b/src/main/java/frc/robot/subsystems/swerve/GyroIOPigeon2.java @@ -35,8 +35,7 @@ public GyroIOPigeon2() { yaw.setUpdateFrequency(Module.ODOMETRY_FREQUENCY); yawVelocity.setUpdateFrequency(100.0); pigeon.optimizeBusUtilization(); - yawPositionQueue = - PhoenixOdometryThread.getInstance().registerSignal(pigeon, pigeon.getYaw()); + yawPositionQueue = PhoenixOdometryThread.getInstance().registerSignal(pigeon, pigeon.getYaw()); } @Override diff --git a/src/main/java/frc/robot/subsystems/swerve/Module.java b/src/main/java/frc/robot/subsystems/swerve/Module.java index 787e8fff..7d390625 100644 --- a/src/main/java/frc/robot/subsystems/swerve/Module.java +++ b/src/main/java/frc/robot/subsystems/swerve/Module.java @@ -20,8 +20,6 @@ import edu.wpi.first.math.kinematics.SwerveModuleState; import edu.wpi.first.math.util.Units; import frc.robot.Robot; -import frc.robot.subsystems.swerve.ModuleIOInputsAutoLogged; - import org.littletonrobotics.junction.Logger; public class Module { diff --git a/src/main/java/frc/robot/subsystems/swerve/Swerve.java b/src/main/java/frc/robot/subsystems/swerve/Swerve.java index 960e0eed..1778aba1 100644 --- a/src/main/java/frc/robot/subsystems/swerve/Swerve.java +++ b/src/main/java/frc/robot/subsystems/swerve/Swerve.java @@ -24,7 +24,6 @@ import edu.wpi.first.math.util.Units; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.robot.subsystems.swerve.GyroIOInputsAutoLogged; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.littletonrobotics.junction.AutoLogOutput; From 68e33055a733b5296ea98222d64fdf6aed45769e Mon Sep 17 00:00:00 2001 From: Lewy Seiden Date: Tue, 26 Dec 2023 16:35:54 -0800 Subject: [PATCH 7/7] except BuildConstants.java from spotless check on build --- build.gradle | 2 +- src/main/java/frc/robot/BuildConstants.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 7b02f3fa..efbddd90 100644 --- a/build.gradle +++ b/build.gradle @@ -141,7 +141,7 @@ spotless { java { target fileTree('.') { include '**/*.java' - exclude '**/build/**', '**/build-*/**' + exclude '**/build/**', '**/build-*/**', '**/BuildConstants.java' } toggleOffOn() googleJavaFormat() diff --git a/src/main/java/frc/robot/BuildConstants.java b/src/main/java/frc/robot/BuildConstants.java index 72a3472e..8fb7300b 100644 --- a/src/main/java/frc/robot/BuildConstants.java +++ b/src/main/java/frc/robot/BuildConstants.java @@ -1,17 +1,19 @@ package frc.robot; -/** Automatically generated file containing build version information. */ +/** + * Automatically generated file containing build version information. + */ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "Crescendo"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 7; - public static final String GIT_SHA = "503ea589d7f676dead191c2d62897eacd95e3e1d"; - public static final String GIT_DATE = "2023-12-26 16:21:43 PST"; + public static final int GIT_REVISION = 8; + public static final String GIT_SHA = "45f6b27a02ddcb28800cb6bfdc0d13c08a2422fb"; + public static final String GIT_DATE = "2023-12-26 16:31:32 PST"; public static final String GIT_BRANCH = "main"; - public static final String BUILD_DATE = "2023-12-26 16:28:40 PST"; - public static final long BUILD_UNIX_TIME = 1703636920080L; + public static final String BUILD_DATE = "2023-12-26 16:35:28 PST"; + public static final long BUILD_UNIX_TIME = 1703637328963L; public static final int DIRTY = 1; - private BuildConstants() {} + private BuildConstants(){} }