Skip to content

CI Checks

Continuous Integration (CI) is a software development practice where developers frequently merge code changes into a shared repository, triggering automated builds and tests to ensures the codebase remains stable. CI checks are automated tests that run when code is pushed or a pull request is opened. They help ensure that your code builds, meets programming standards, and is formatted correctly before merging. You can create CI checks using GitHub Actions.

Note

CI checks can only check for certain attributes of the code and cannot ensure that the code is functional or well-written. CI checks do not replace pull request reviews.

To verify that your robot code builds, create a GitHub Actions workflow file .github/workflows/build.yml with the following code:

name: Build
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew build
- name: Run Tests
run: ./gradlew test

Static analysis is the process of analyzing code without executing it. Static analysis tools help catch bugs, maintain programming standards, and improve code quality. Using static analysis tools is considered a good practice because they offer automated ways of flagging bad programming practices such as unused code.

To configure, add the PMD and Spotbugs plugin in the plugins {} block of your build.gradle file.

plugins {
id "java"
id "org.wpilib.GradleRIO" version "VERSION_HERE"
id "pmd"
id "com.github.spotbugs" version "VERSION_HERE"
}

To run code quality checks, create a GitHub Actions workflow file .github/workflows/code-quality.yml with the following code:

name: Code Quality
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
warning-check:
name: Check Compiler Warnings
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
- name: Build with warnings as errors
run: ./gradlew build -PwarningsAsErrors=true
static-analysis:
name: Static Analysis (PMD & SpotBugs)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
- name: Run PMD
run: ./gradlew pmdMain
- name: Run SpotBugs
run: ./gradlew spotbugsMain
- name: Upload analysis reports
if: failure()
uses: actions/upload-artifact@v7
with:
name: static-analysis-reports
path: |
build/reports/pmd/
build/reports/spotbugs/

Spotless can also be run as a CI check to verify that code is formatted correctly. To add a code formatting CI check, create a GitHub Actions workflow file .github/workflows/format.yml with the following code:

name: Format
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
spotless:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: 25
- run: ./gradlew spotlessCheck