Skip to content

Commit

Permalink
merged main into swerve-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewy Seiden committed Dec 27, 2023
2 parents 05d4b36 + 68e3305 commit 99fd26c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is a basic workflow to build robot code.

name: Build

# 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
37 changes: 37 additions & 0 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a basic workflow to check robot code formatting using spotless.

name: Format

This comment has been minimized.

Copy link
@kevinclark

kevinclark Dec 27, 2023

Contributor

Might consider doing this (and the a pre-commit hook to avoid something that fails getting pushed in the first place.

This comment has been minimized.

Copy link
@Lewis-Seiden

Lewis-Seiden Dec 31, 2023

Contributor

do you mean having it actually run the formatter and commit that? how would i set up a pre commit hook?

This comment has been minimized.

Copy link
@kevinclark

kevinclark Dec 31, 2023

Contributor

tldr: drop something like this into .git/hooks/pre-commit and chmod u+x it so it’s executable.

#!/usr/bin/env bash

set -e

./gradlew spotlessCheck --daemon

You can also swap out spotlessCheck with spotlessApply and have it do the actual changes rather than call out what’s not conforming to your standards.

Longer version: see this for context on git hooks generally and this for a much longer discussion on applying spotless during a hook. In particular the posters there are interested in the hook only applying to staged changes. You can go that route, but it probably makes sense to just run apply once over our codebase and then trust the pre-commit hook to take care of changes from there. That avoids the “my unstaged changes don’t apply cleanly to my formatted staged changes” error case but doesn’t support the “I make larger changes and then add them individually through git add -p workflow”, but I don’t expect a lot of the latter is happening on the team.

All of this to say - I think you should do this and then forbid style conversations from code review. Style conversation then becomes something that is solely in PRs that change the linter rules.

/cc @Awesomeplayer165

This comment has been minimized.

Copy link
@kevinclark

kevinclark Dec 31, 2023

Contributor

Oh, and I strongly suggest you do the apply variant. Nothing more annoying than a tool pointing out an error rather than just fixing it.


# 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 spotlessJavaCheck
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FRC 8033 2024 Robot Code

This is Highlander Robotics' code for the 2024 FRC season, Crescendo
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spotless {
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**'
exclude '**/build/**', '**/build-*/**', '**/BuildConstants.java'
}
toggleOffOn()
googleJavaFormat()
Expand Down

0 comments on commit 99fd26c

Please sign in to comment.