Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved auto-formatter behavior #781

Merged
merged 53 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ab21c02
Attempting improvements
charlestian23 Mar 29, 2024
6f69b0e
Added git config info
charlestian23 Mar 29, 2024
3b204ef
Added check for modified files
charlestian23 Mar 29, 2024
7e156d2
Modifying GitHub Token use
charlestian23 Mar 29, 2024
37e7af2
Temporarily changing user for my fork
charlestian23 Mar 29, 2024
11b2a83
Change fork checking and repo name retrieval
charlestian23 Mar 29, 2024
3e48db5
Changing back
charlestian23 Mar 29, 2024
a2e06d8
Removed distribution
charlestian23 Mar 29, 2024
ae04a1f
Didn't properly change back
charlestian23 Mar 29, 2024
65ac83c
More testing
charlestian23 Mar 29, 2024
7d9e510
Testing to see if this works...?
charlestian23 Mar 29, 2024
0ca5225
Update java-autoformat.yml
charlestian23 Mar 29, 2024
72c3cbb
Set upstream
charlestian23 Mar 29, 2024
2d0bd4c
Changing back to Bram
charlestian23 Mar 29, 2024
e32e333
Changing method to create pull request
charlestian23 Mar 29, 2024
211fab1
Modifying job execution conditions
charlestian23 Mar 29, 2024
1b04c75
Automated Java code formatting changes
Bram28 Mar 29, 2024
4a71b39
Update java-autoformat.yml
charlestian23 Mar 29, 2024
1574d7d
Merge branch 'improve-auto-formatter' of https://github.com/charlesti…
charlestian23 Mar 29, 2024
d0df56a
More debugging
charlestian23 Mar 29, 2024
8e06bde
More debugging
charlestian23 Mar 29, 2024
ee30b88
More changes
charlestian23 Mar 29, 2024
af41ba1
Adding bad formatting for testing
charlestian23 Mar 29, 2024
4118376
Automated Java code formatting changes
Bram28 Mar 29, 2024
b0a0363
Merge pull request #1 from charlestian23/improve-auto-formatter
charlestian23 Mar 29, 2024
d67880d
Even more debugging
charlestian23 Mar 29, 2024
3664bd2
Bug fixing
charlestian23 Mar 29, 2024
91af85e
EVEN MORE DEBUGGING
charlestian23 Mar 29, 2024
827517d
Debugging...
charlestian23 Mar 29, 2024
123fbcb
Update java-autoformat.yml
charlestian23 Mar 29, 2024
78904a2
Update java-autoformat.yml
charlestian23 Mar 29, 2024
7f7c186
Update java-autoformat.yml
charlestian23 Mar 29, 2024
d161f3c
Update java-autoformat.yml
charlestian23 Mar 29, 2024
63ba596
Update java-autoformat.yml
charlestian23 Mar 29, 2024
3497f9e
Update java-autoformat.yml
charlestian23 Mar 29, 2024
ba424e2
Update java-autoformat.yml
charlestian23 Mar 29, 2024
574fbcc
Update java-autoformat.yml
charlestian23 Mar 29, 2024
f1dec04
Bad formatting for testing
charlestian23 Mar 29, 2024
025044d
Update java-autoformat.yml
charlestian23 Mar 29, 2024
76c12a3
Update java-autoformat.yml
charlestian23 Mar 29, 2024
1c0e9e8
Automated Java code formatting changes
Bram28 Mar 29, 2024
cc0200c
Merge pull request #5 from charlestian23/auto-format-code-1711732001
charlestian23 Mar 29, 2024
2d43149
Update java-autoformat.yml
charlestian23 Mar 29, 2024
1cdb537
Merge branch 'dev' of https://github.com/charlestian23/LEGUP into dev
charlestian23 Mar 29, 2024
7e9645f
DEBUG
charlestian23 Mar 29, 2024
f755ff2
Trying different way to check for modified files
charlestian23 Mar 29, 2024
59cfea5
Bad formatting for testing
charlestian23 Mar 29, 2024
575e264
Automated Java code formatting changes
Bram28 Mar 29, 2024
465442a
Merge pull request #6 from charlestian23/auto-format-code-1711733376
charlestian23 Mar 29, 2024
cb0be0b
More changes + more testing
charlestian23 Mar 29, 2024
720aa1f
Merge branch 'dev' of https://github.com/charlestian23/LEGUP into dev
charlestian23 Mar 29, 2024
eefd3b9
Automated Java code formatting changes
Bram28 Mar 29, 2024
d252879
Merge pull request #7 from charlestian23/auto-format-code-1711733770
charlestian23 Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 58 additions & 5 deletions .github/workflows/java-autoformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: Java Code Auto Format
on: pull_request

jobs:
format:
if: github.event.pull_request.head.repo.full_name == github.repository
format_dev:
if: |
github.event.pull_request.head.ref == 'dev' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -15,7 +17,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 21
distribution: temurin

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -28,7 +29,58 @@ jobs:

- name: Check for modified files
id: git-check
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
run: echo "modified=$(if [[ -n $(git status -s) ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: Create temporary branch and pull request
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Bram van Heuveln'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
branch_name="auto-format-code-$(date +%s)"
git checkout -b $branch_name
./gradlew :spotlessApply
git add .
git commit -am "Automated Java code formatting changes"
git push --set-upstream origin $branch_name
gh pr create -B dev -H $branch_name --title 'Automated Java code formatting changes' --body 'This pull request contains automated code formatting changes.' --reviewer ${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Must approve auto-format pull request
if: steps.git-check.outputs.modified == 'true'
run: |
echo "Please review and approve the appropriate auto-format-code pull request."
exit 1

format_pull_request_to_dev:
if: |
github.event.pull_request.base.ref == 'dev' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
with:
ref: ${{ github.head_ref }}

- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- name: Run spotless
run: ./gradlew :spotlessApply

- name: Check for modified files
id: git-check
run: echo "modified=$(if [[ -n $(git status -s) ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: Push changes
if: steps.git-check.outputs.modified == 'true'
Expand All @@ -37,4 +89,5 @@ jobs:
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add .
git diff --cached --exit-code || git commit -am "Automated Java code formatting changes" && git push
git commit -am "Automated Java code formatting changes"
git push
108 changes: 55 additions & 53 deletions src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
package edu.rpi.legup.model.gameboard;

import java.util.ArrayList;
import java.util.List;

public abstract class GridRegion<T> {

protected List<T> regionCells;

/**
* Region Constructor
*/
public GridRegion() {
this.regionCells = new ArrayList<>();
}

/**
* Adds the cell to the region
* @param cell cell to be added to the region
*/
public void addCell(T cell) {
regionCells.add(cell);
}

/**
* Removes the cell from the region
* @param cell cell to be remove from the region
*/
public void removeCell(T cell) {
regionCells.remove(cell);
}

/**
* Returns the list of cells in the region
* @return list of cells in region
*/
public List<T> getCells() {
return regionCells;
}

/**
* Returns the number of cells in the region
* @return number of cells in the region
*/
public int getSize(){
return regionCells.size();
}

/*
public void colorRegion(){}
*/

}
package edu.rpi.legup.model.gameboard;

import java.util.ArrayList;
import java.util.List;

public abstract class GridRegion<T> {

protected List<T> regionCells;

/** Region Constructor */
public GridRegion() {
this.regionCells = new ArrayList<>();
}

/**
* Adds the cell to the region
*
* @param cell cell to be added to the region
*/
public void addCell(T cell) {
regionCells.add(cell);
}

/**
* Removes the cell from the region
*
* @param cell cell to be remove from the region
*/
public void removeCell(T cell) {
regionCells.remove(cell);
}

/**
* Returns the list of cells in the region
*
* @return list of cells in region
*/
public List<T> getCells() {
return regionCells;
}

/**
* Returns the number of cells in the region
*
* @return number of cells in the region
*/
public int getSize() {
return regionCells.size();
}

/*
public void colorRegion(){}
*/

}
Loading