Skip to content

Commit

Permalink
Styleguide java (#1899)
Browse files Browse the repository at this point in the history
* modify .gitignore

* add ok idea files

* add google java format idea files

* remove old test reporter

* add google java format CI check

* add google java format readme

* remove checkstyle

* google java format

* fix runner spec

* reformat

* add note about linux

* add fix script
  • Loading branch information
moscicky authored Oct 14, 2024
1 parent bda2607 commit 4180225
Show file tree
Hide file tree
Showing 1,404 changed files with 72,725 additions and 68,091 deletions.
45 changes: 45 additions & 0 deletions .github/scripts/check-google-java-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -u

script_name=""

case "$(uname -sr)" in

Darwin*)
script_name="google-java-format_darwin-arm64"
;;

Linux*)
script_name="google-java-format_linux-x86-64"
;;
*)
echo 'Unsupported OS'
exit 1
;;
esac

JAVA_FILES=$(find . -name "*.java" -type f)

invalid_files=0

echo "Following files are formatted incorrectly:";
# TODO: remove '--skip-reflowing-long-strings' once https://github.com/google/google-java-format/issues/566 is fixed
for FILE in $JAVA_FILES; do
if [[ "$*" == *--fix* ]]; then
./$script_name --skip-reflowing-long-strings --replace "$FILE" > /dev/null
else
./$script_name --set-exit-if-changed --skip-reflowing-long-strings "$FILE" > /dev/null
fi
if [ $? -ne 0 ]; then
echo "$FILE"
((invalid_files++))
fi
done

if [ "$invalid_files" -ne 0 ]; then
echo "Found $invalid_files incorrectly formatted files (listed above), run google-java-format to fix them.";
exit 1
else
echo "All files are formatted correctly."
fi

41 changes: 0 additions & 41 deletions .github/scripts/download_reports.sh

This file was deleted.

118 changes: 0 additions & 118 deletions .github/scripts/reporter.py

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/checkstyle.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/google-java-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Google java format

on:
workflow_dispatch:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Download and run google java format
run: |
ls -la
curl -sSLO "https://github.com/google/google-java-format/releases/download/v$VERSION/google-java-format_linux-x86-64"
chmod a+x google-java-format_linux-x86-64
./.github/scripts/check-google-java-format.sh
shell: bash
env:
VERSION: 1.23.0

22 changes: 0 additions & 22 deletions .github/workflows/test_report.yml

This file was deleted.

36 changes: 35 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
build
.gradle
classes
.idea
*.iml
*.ipr
*.iws
Expand Down Expand Up @@ -39,3 +38,38 @@ scripts/lib/
scripts/pip-selfcheck.json

.DS_Store

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml


# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules

# Gradle
.idea/**/gradle.xml
.idea/**/libraries
6 changes: 6 additions & 0 deletions .idea/externalDependencies.xml

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

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

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

Loading

0 comments on commit 4180225

Please sign in to comment.