Skip to content

Commit

Permalink
Prettier formatting ✨ (#11)
Browse files Browse the repository at this point in the history
* It might work?... Hopefully?

* changes testing branch name in the on thing

* Oops I forgot to add that one file

* Apply Prettier format

* Remove testing thing. 4 spaced tabs wins!

* Remove Node Modules

* Add node_modules to git ignore

* Pulls before other steps

* Merge confligs gona make me crash out

* Apply Prettier format

* Fix step names

* Apply Prettier format

* Apply Prettier format

* Excuse other files

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: SSBASLD <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2024
1 parent 6583df2 commit b9fe126
Show file tree
Hide file tree
Showing 46 changed files with 3,422 additions and 2,983 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# List of files to excuse (constants and things we didnt make and stuff we wont use)
# TODO: Put un-used Module IO abstraction constants in constants (Not super needed but important)
excused_files = ["Constants.java", "BuildConstants.java", "LocalADStarAK.java", "ModuleIOSparkMax.java", "ModuleIOTalonFX.java"]
excused_files = ["Constants.java", "BuildConstants.java", "LocalADStarAK.java", "ModuleIOSparkMax.java", "ModuleIOTalonFX.java", "PhoenixOdometryThread.java", "SparkMaxOdometryThread.java"]

# Not really dirs becasue the full ones didnt work
excused_dirs = [
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Format With Prettier

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: write
actions: read

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Pull latest changes
run: |
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
git fetch origin
git checkout "${GITHUB_HEAD_REF}"
git pull origin "${GITHUB_HEAD_REF}"
elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then
git fetch origin
git pull origin "${GITHUB_REF#refs/heads/}"
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Clean Install
run: |
if [ -d "node_modules" ]; then
rm -rf node_modules
fi
npm install
- name: Apply Prettier Foramtting
run: npx prettier --write "**/*.java"

- name: Check for Changes
id: git-check
run: |
git diff --exit-code || echo "Changes detected"
continue-on-error: true

- name: Commit Changes
if: steps.git-check.outcome == 'success'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add .
git commit -m 'Apply Prettier format' || echo "No changes to commit"
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
git push origin "${GITHUB_HEAD_REF}"
elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then
git push origin "${GITHUB_REF#refs/heads/}"
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Notify if no Changes
if: steps.git-check.outcome == 'failure'
run: echo "Formatting not Required"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This gitignore has been specially created by the WPILib team.
# If you remove items from this file, intellisense might break.

# Node Modules
node_modules/

settings.json

### C++ ###
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["prettier-plugin-java"],
"tabWidth": 4,
"useTabs": true,
"printWidth": 100
}

5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
"[java]": {
"editor.defaultFormatter": "redhat.java"
},
"java.debug.settings.onBuildFailureProceed": true
"java.debug.settings.onBuildFailureProceed": true,
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
146 changes: 146 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "2024-rewrite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"prettier": "^3.3.3",
"prettier-plugin-java": "^2.6.4"
}
}
Loading

0 comments on commit b9fe126

Please sign in to comment.