-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Enforce code style format #4087
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ba6fed7
start enforcing format style
atakavci 7f3e967
adding format_check
atakavci ce6314a
dummy change
atakavci 67e9adf
fix file param
atakavci ac56a15
Create format_check.yml
atakavci 8f2a16c
workflow_dispatch
atakavci 573b88e
Update format_check.yml
atakavci 77deb40
Merge branch 'master' into ali/enforce_format
atakavci 7a2d11f
setup java 11
atakavci 3e552fd
add fetch origin
atakavci da8aa71
process list of files
atakavci 9a3332b
changes into a file
atakavci 39a8466
Revert "dummy change"
atakavci e801af8
Check changed files against different branches
atakavci 54f30f5
Merge branch 'master' into ali/enforce_format
atakavci 877ef1b
Merge branch 'master' into ali/enforce_format
atakavci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Java Format Check | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- '**/*.java' # Only trigger for Java file changes | ||
|
||
jobs: | ||
check-format: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the PR code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up Java (if needed for format check tools) | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
# Step 3: Fetch latest changes | ||
- name: Fetch latest changes | ||
run: git fetch origin | ||
|
||
- name: Get changed Java files | ||
id: changed_files | ||
run: | | ||
echo "::group::Changed Java Files" | ||
echo Base Branch: ${{ github.event.pull_request.base.ref }} | ||
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} | grep '\.java$' || true) | ||
echo "$CHANGED_FILES" | ||
echo "::endgroup::" | ||
# Write the multiline content to a file | ||
echo "$CHANGED_FILES" > changed_files.txt | ||
|
||
# Step 4: Get a list of changed Java files in the PR | ||
- name: Check Java file format | ||
run: | | ||
# Check if the changed_files.txt exists | ||
if [ ! -f changed_files.txt ]; then | ||
echo "No changed files found." | ||
exit 0 | ||
fi | ||
|
||
# Read the multiline content from the file | ||
CHANGED_FILES=$(cat changed_files.txt) | ||
|
||
# Ensure there are changed files | ||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No Java files changed." | ||
else | ||
echo "Processing the following changed Java files:" | ||
|
||
# Iterate over the CHANGED_FILES variable, assuming files are separated by newlines | ||
while IFS= read -r FILE; do | ||
# Skip empty lines if any | ||
if [ -n "$FILE" ]; then | ||
FILE_NAME=$(basename "$FILE") | ||
echo "Checking for $FILE_NAME" | ||
|
||
# Run your formatter validation for each file | ||
mvn formatter:validate -f formatter-pom.xml "-Dformatter.includes=**/$FILE_NAME" | ||
fi | ||
done <<< "$CHANGED_FILES" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
tishun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<parent> | ||
<groupId>org.sonatype.oss</groupId> | ||
<artifactId>oss-parent</artifactId> | ||
<version>7</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
<groupId>redis.clients</groupId> | ||
<artifactId>jedis</artifactId> | ||
<name>Jedis</name> | ||
<version>5.3.0</version> | ||
<description>Jedis is a blazingly small and sane Redis java client.</description> | ||
<url>https://github.com/redis/jedis</url> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>net.revelc.code.formatter</groupId> | ||
<artifactId>formatter-maven-plugin</artifactId> | ||
<version>2.23.0</version> | ||
<configuration> | ||
<configFile>${project.basedir}/hbase-formatter.xml</configFile> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>validate</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.