diff --git a/.github/workflows/frc-ci.yml b/.github/workflows/frc-ci.yml index 28085fa..9da8863 100644 --- a/.github/workflows/frc-ci.yml +++ b/.github/workflows/frc-ci.yml @@ -29,12 +29,20 @@ on: required: false type: string default: 'qwen2.5-coder:1.5b' + bot-app-id: + description: 'GitHub App ID to author PR comments as a custom bot identity' + required: false + type: string + default: '' secrets: SLACK_WEBHOOK_URL: description: 'Slack incoming webhook URL for build status notifications' required: false COMMENT_TOKEN: - description: 'Custom token (e.g., GitHub App installation token or bot PAT) to author PR comments instead of github-actions[bot]. Defaults to GITHUB_TOKEN.' + description: 'Custom token (e.g. PAT) to author PR comments. Defaults to GITHUB_TOKEN if bot credentials are not provided.' + required: false + BOT_APP_PRIVATE_KEY: + description: 'GitHub App private key (PEM format) to author PR comments as the custom bot identity' required: false jobs: @@ -295,10 +303,19 @@ jobs: echo "has_review=true" >> "$GITHUB_OUTPUT" + - name: Generate Custom Bot Token + if: ${{ secrets.BOT_APP_PRIVATE_KEY != '' && inputs.bot-app-id != '' }} + id: bot-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ inputs.bot-app-id }} + private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + - name: Post or Update Sticky PR Comment uses: actions/github-script@v7 with: - github-token: ${{ secrets.COMMENT_TOKEN || secrets.GITHUB_TOKEN }} + github-token: ${{ steps.bot-token.outputs.token || secrets.COMMENT_TOKEN || secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); const prTitle = context.payload.pull_request ? context.payload.pull_request.title : "Pull Request"; diff --git a/.github/workflows/test-bot.yml b/.github/workflows/test-bot.yml new file mode 100644 index 0000000..3329e43 --- /dev/null +++ b/.github/workflows/test-bot.yml @@ -0,0 +1,26 @@ +name: Test Bot PR Comment + +on: + pull_request: + branches: [ main ] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + frc-ci: + name: Run FRC CI + uses: ./.github/workflows/frc-ci.yml + permissions: + contents: read + checks: write + pull-requests: write + issues: write + with: + fallback-year: "2026" + enable-ai-review: true + bot-app-id: "5648265" + secrets: + BOT_APP_PRIVATE_KEY: ${{ secrets.BOT_APP_PRIVATE_KEY }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a8da3b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.gradle \ No newline at end of file diff --git a/.gradle/9.2.0/checksums/checksums.lock b/.gradle/9.2.0/checksums/checksums.lock new file mode 100644 index 0000000..e7051f4 Binary files /dev/null and b/.gradle/9.2.0/checksums/checksums.lock differ diff --git a/.gradle/9.2.0/checksums/sha1-checksums.bin b/.gradle/9.2.0/checksums/sha1-checksums.bin new file mode 100644 index 0000000..da9a068 Binary files /dev/null and b/.gradle/9.2.0/checksums/sha1-checksums.bin differ diff --git a/.gradle/9.2.0/fileChanges/last-build.bin b/.gradle/9.2.0/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/9.2.0/fileChanges/last-build.bin differ diff --git a/.gradle/9.2.0/fileHashes/fileHashes.bin b/.gradle/9.2.0/fileHashes/fileHashes.bin new file mode 100644 index 0000000..d45cfe1 Binary files /dev/null and b/.gradle/9.2.0/fileHashes/fileHashes.bin differ diff --git a/.gradle/9.2.0/fileHashes/fileHashes.lock b/.gradle/9.2.0/fileHashes/fileHashes.lock new file mode 100644 index 0000000..8a57da5 Binary files /dev/null and b/.gradle/9.2.0/fileHashes/fileHashes.lock differ diff --git a/.gradle/9.2.0/gc.properties b/.gradle/9.2.0/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..1617ede Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..2bd47d8 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri Nov 06 19:15:06 PST 2026 +gradle.version=9.2.0 diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..d5b9f80 --- /dev/null +++ b/build.gradle @@ -0,0 +1,17 @@ +plugins { + id 'java' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' +} + +test { + useJUnitPlatform() + ignoreFailures = true +} + diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..482aaf4 --- /dev/null +++ b/gradlew @@ -0,0 +1,19 @@ +#!/bin/sh +# Minimal gradlew simulator for CI testing +mkdir -p build/test-results/test +cat << 'EOF' > build/test-results/test/TEST-frc.robot.ShooterSubsystemTest.xml + + + + + + java.lang.AssertionError: Expected motor shutdown when exceeding 80A current limit, but current limit check was inverted in ShooterSubsystem.java:42 + at frc.robot.ShooterSubsystemTest.testOvercurrentProtectionTriggered(ShooterSubsystemTest.java:42) + + + +EOF + +echo "Simulated Gradle build: compileJava finished, tests executed." +exit 0 + diff --git a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java new file mode 100644 index 0000000..90e64ce --- /dev/null +++ b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java @@ -0,0 +1,37 @@ +package frc.robot.subsystems; + +/** + * Robot Shooter and Climber controller with simulated robotics logic bugs + * for testing automated AI code review. + */ +public class ShooterSubsystem { + private double motorOutput = 0.0; + private double currentAmps = 0.0; + private boolean limitSwitchPressed = false; + + // BUG 1: Inverted overcurrent protection (critical motor burnout risk) + public void updateCurrentLimit(double reportedAmps) { + this.currentAmps = reportedAmps; + if (this.currentAmps < 80.0) { // BUG: Shuts down motor on low current instead of high current! + System.err.println("CRITICAL: Exceeded 80A! Disabling shooter motor."); + this.motorOutput = 0.0; + } + } + + // BUG 2: Infinite loop blocking main robot loop thread (watchdog timeout) + public void spinUpToTargetRPM(double targetRpm, double currentRpm) { + while (currentRpm < targetRpm) { + // BUG: Busy-wait loop on main thread freezes WPILib TimedRobot loop + motorOutput = 1.0; + } + } + + // BUG 3: Ignoring physical limit switch during arm extension (chassis damage) + public void setArmPosition(double desiredPosition) { + // BUG: Inverted limit switch check allows driving motor past physical hardstop + if (limitSwitchPressed) { + motorOutput = 1.0; // Keeps applying full forward voltage even when hardstop switch hit! + } + } +} +