Skip to content

Conversation

@rjhancock
Copy link
Collaborator

This adds Checkstyle to GitHub Actions to ensure license compliance and forbidden word checks.

Added Checkstyle to MM Data
Copilot AI review requested due to automatic review settings January 27, 2026 05:10
@rjhancock rjhancock requested a review from a team as a code owner January 27, 2026 05:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GitHub Actions workflow for Checkstyle validation and updates the Checkstyle configuration. The workflow runs on pull requests to the main branch to enforce license compliance and forbidden word checks.

Changes:

  • Added new GitHub Actions workflow (.github/workflows/checkstyle.yml) to run Checkstyle on pull requests
  • Updated Checkstyle configuration with formatting consistency (added spaces before closing XML tags)
  • Added "BattleMech Manual" to the forbidden words exclusion list for properties and markdown files
  • Changed license check severity from "warning" to "error" for stricter enforcement
  • Added explicit "error" severity to forbidden words checks

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
.github/workflows/checkstyle.yml New workflow that runs Checkstyle validation on pull requests to main branch using Java 25 and Gradle
config/checkstyle/checkstyle.xml Formatting updates (spacing), added "BattleMech Manual" exclusion, and changed severity levels from warning to error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

steps:
- name: "Check out MegaMek Lab"
uses: actions/checkout@v6

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing the MegaMek dependency checkout. The settings.gradle file (line 2) shows that megamek is an included build (includeBuild('../megamek')), and all other workflows in the repository (ci.yml, code-coverage.yml, codeql-analysis.yml, dependency-scan.yml) checkout the megamek repository before running Gradle tasks. Without this checkout, the Gradle build will fail when trying to resolve the included build dependency.

Suggested change
- name: "Check out MegaMek"
uses: actions/checkout@v6
with:
repository: MegaMek/megamek
path: megamek

Copilot uses AI. Check for mistakes.
<property name="ignoreCase" value="true"/>
<property name="message" value="Forbidden word found"/>
<property name="fileExtensions" value="properties, md"/>
<property name="format" value="^(?!.*(bg\.battletech|MechWarrior Copyright|MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks|BattleMech Manual)).*\b(?i)(mech|mechwarrior|battlemech|aerotech|protomech|'mech|`Mech|TripodMech|BipedMech|QuadMech|LandAirMech|OmniMech|'Mechs)\b.*$" />
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern includes "BattleMech Manual" in the exclusion list, which differs from the RegexpSinglelineJava check on line 41 that does not include this exclusion. This creates an inconsistency where the same phrase could be allowed in properties/md files but flagged in Java files. Consider whether both patterns should have the same exclusions for consistency.

Copilot uses AI. Check for mistakes.
fail-fast: false

steps:
- name: "Check out MegaMek Lab"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step name uses "MegaMek Lab" (two words), but the convention in other workflows is "MegaMekLab" (one word) as seen in codeql-analysis.yml:19, dependency-scan.yml:21, and java-doc.yml:26. Consider using the consistent naming convention.

Copilot uses AI. Check for mistakes.
steps:
- name: "Check out MegaMek Lab"
uses: actions/checkout@v6

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing the mm-data repository checkout. The settings.gradle file includes mm-data as an included build (line 3), and all other workflows that run Gradle tasks (ci.yml, code-coverage.yml, dependency-scan.yml, java-doc.yml) checkout the mm-data repository. While checkstyleMain may not directly depend on mm-data, omitting this checkout could cause issues with Gradle's composite build configuration.

Suggested change
- name: "Check out mm-data"
uses: actions/checkout@v6
with:
repository: MegaMek/mm-data
path: mm-data

Copilot uses AI. Check for mistakes.
steps:
- name: "Check out MegaMek Lab"
uses: actions/checkout@v6

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing a Java setup step. All other workflows in the repository use actions/setup-java to configure the JDK before running Gradle tasks. The checkstyle plugin in build.gradle (line 111) is configured to use toolVersion 12.3.1 which requires Java to be available. Without this step, the Gradle wrapper might not have access to the required Java version.

Suggested change
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}

Copilot uses AI. Check for mistakes.
if: failure()
with:
name: cd-failure-logs
path: ./megamek/megamek/build/reports/
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The artifact upload path is incorrect. The path points to ./megamek/megamek/build/reports/ but should be ./megameklab/megameklab/build/reports/ to match the actual project structure. When checking out the repository, the code is placed in the root directory (unlike other workflows that checkout to a megameklab subdirectory), and the build reports will be generated at ./megameklab/build/reports/ as seen in other workflows like ci.yml (line 99) and code-coverage.yml (line 55).

Suggested change
path: ./megamek/megamek/build/reports/
path: ./megameklab/build/reports/

Copilot uses AI. Check for mistakes.
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5

- name: Checkstyle
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Gradle command is missing a working directory specification. The settings.gradle file shows that the actual megameklab project is in the megameklab/ subdirectory. The command should either include working-directory: megameklab or use ./megameklab/gradlew checkstyleMain to match the project structure seen in other workflows like ci.yml (line 92) and code-coverage.yml (line 48).

Suggested change
- name: Checkstyle
- name: Checkstyle
working-directory: megameklab

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant