diff --git a/.github/scripts/constants.py b/.github/scripts/constants.py new file mode 100644 index 0000000..a41199f --- /dev/null +++ b/.github/scripts/constants.py @@ -0,0 +1,105 @@ +import re +import os +import sys + +# List of files to excuse (constants and things we didnt make and stuff we wont use) +excused_files = ["Constants.java", "Drive.java", "TunerConstants.java", "BuildConstants.java", "LocalADStarAK.java", "VisionUtil.java", "SwerveModule.java", "VisionIOSim.java"] + +# Not really dirs becasue the full ones didnt work +excused_dirs = [ + "bin", + "build", + "src/main/java/frc/robot/pioneersLib" +] + +# Weird stuff that shouldn't go in constants, dont put function/var names in here theyre already checked +excused_cases = ["ModuleIOSparkMax", "case", "new Module(", "new BaseStatusSignal[", "BaseStatusSignal.waitForAll(", "new ModuleIOHybrid(", "Math.pow(", "+=", "drive.getRotation()", "autoChooser.addOption(", "static final", "getRealTimestamp", "antiJitterThreshold", "trackWidth", "i < 4", "SwerveModuleState[4]", "gearRatio", "Math.PI", "private final", "/ 360", "/360", "* 360", "*360", "DCMotor.get", "/60", "/ 60"] + +def check_for_magic_numbers(file_path): + magic_numbers = [] + + # Number pattern makes sure number isnt in a var and detects all numbers that arent in a function/var + number_pattern = r'(? 0: + print(f"\nTotal magic numbers found: {total_magic_numbers}.\nPlease put these in Constanats.java!") + sys.exit(1) + else: + print("\nNo Magic Number Found") + sys.exit(0) \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5d6561a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: Build + +on: + push: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: wpilib/roborio-cross-ubuntu:2024-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Grant execute permission + run: chmod +x gradlew + - name: Build robot code + run: ./gradlew build diff --git a/.github/workflows/constants.yml b/.github/workflows/constants.yml new file mode 100644 index 0000000..b333851 --- /dev/null +++ b/.github/workflows/constants.yml @@ -0,0 +1,20 @@ +name: Find Misplaced Constants + +on: + pull_request: + push: + branches: + - main + +jobs: + find-misplaced-constants: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Run Python Script + run: python .github/scripts/constants.py \ No newline at end of file diff --git a/.github/workflows/crash.yml b/.github/workflows/crash.yml new file mode 100644 index 0000000..a52388b --- /dev/null +++ b/.github/workflows/crash.yml @@ -0,0 +1,41 @@ +name: Crash + +on: + push: + +jobs: + Crash: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: '17' + - name: Grant execute permission + run: chmod +x gradlew + - name: Build robot code + run: ./gradlew build + - name: Run Simulation and Capture Logs + env: + CI_NAME: "Crash" + run: ./gradlew simulateJava | tee simulateJava.log + + - name: Check for Errors in Logs + run: | + # Check for errors + if grep -qE "Exception|Error|NULL|NullPointerException" simulateJava.log; then + echo "Errors detected in simulation logs (See Crash for Details)." + exit 1 + fi + + # Check for modes + if grep -q "DISABLED" simulateJava.log && grep -q "TELEOP" simulateJava.log && grep -q "AUTONOMOUS" simulateJava.log && grep -q "TEST" simulateJava.log; then + echo "All modes found in simulation logs." + else + echo "One or more modes not found in simulation logs (See Crash for Details)." + exit 1 + fi