Skip to content

Commit

Permalink
Merge pull request #8 from yhs0602/dev
Browse files Browse the repository at this point in the history
💚 Add clang-format ci
  • Loading branch information
yhs0602 authored Dec 28, 2024
2 parents 7e0f112 + 1969ff9 commit 737a1e7
Show file tree
Hide file tree
Showing 116 changed files with 15,767 additions and 12,341 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BasedOnStyle: LLVM
IndentWidth: 4
PointerAlignment: Right
AlignAfterOpenBracket: BlockIndent
BinPackArguments: false
BinPackParameters: false
InsertTrailingCommas: Wrapped
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[*.{kt,kts}]
end_of_line = lf
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_indent_before_arrow_on_new_line = false
ij_kotlin_line_break_after_multiline_when_entry = true
ij_kotlin_packages_to_use_import_on_demand = unset
indent_size = 4
indent_style = space
insert_final_newline = true
ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = unset
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 1
ktlint_code_style = ktlint_official
ktlint_enum_entry_name_casing = upper_or_camel_cases
ktlint_function_naming_ignore_when_annotated_with = [unset]
ktlint_function_signature_body_expression_wrapping = multiline
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
ktlint_ignore_back_ticked_identifier = false
ktlint_property_naming_constant_naming = screaming_snake_case
max_line_length = 140
24 changes: 24 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Format Check for C++ and Objective-C

on:
pull_request:
paths:
- '**/*.cpp'
- '**/*.c'
- '**/*.h'
- '**/*.mm'
- '**/*.m'

jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install clang-format 19
run: sudo wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 19
- name: Find and Check All Files
run: |
FILES=$(find . -type f \( -name '*.cpp' -o -name '*.c' -o -name '*.h' -o -name '*.mm' -o -name '*.m' \))
for file in $FILES; do
clang-format --dry-run -Werror -style=file $file || exit 1
done
26 changes: 26 additions & 0 deletions .github/workflows/java-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java Format Check

on:
pull_request:
paths:
- '**/*.java'

jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Install google-java-format
run: |
curl -Lo google-java-format.jar https://github.com/google/google-java-format/releases/download/v1.25.2/google-java-format-1.25.2-all-deps.jar
- name: Check formatting
run: |
java -jar google-java-format.jar --dry-run --set-exit-if-changed $(find . -name '*.java')
17 changes: 17 additions & 0 deletions .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Format Check for Kotlin

on:
pull_request:
paths:
- '**/*.kt'
- '**/*.kts'

jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install ktlint
run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.5.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: Find and Check All Files
run: ktlint '!src/craftground/MinecraftEnv/src/main/java/com/kyhsgeekcode/minecraftenv/proto/**'
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ elseif(CUDAToolkit_FOUND)

# CUDA-specific compile options
set(CRAFTGROUND_PY_COMPILE_OPTIONS -DHAS_CUDA)
target_include_directories(craftground PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
target_link_libraries(craftground PRIVATE ${CUDAToolkit_LIBRARIES})
endif()

# Add the module
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This is the latest development repository of CraftGround environment.
1. You need to install JDK >= 21
1. Run the following command to install the package.
```shell
pip install git+https://github.com/yhs0602/CraftGround
pip install craftground
```
1. Take a look at the [the demo repository](https://github.com/yhs0602/CraftGround-Baselines3)!
1. Here is a simple example that uses this environment.
Expand Down Expand Up @@ -249,3 +249,15 @@ https://dejavu-fonts.github.io/License.html
1. Edit .proto
2. protoc
3. Edit python files
# Formatting
## Install formatters
```zsh
brew install ktlint clang-format google-java-format
```
```bash
find . \( -iname '*.h' -o -iname '*.cpp' -o -iname '*.mm' \) | xargs clang-format -i
ktlint '!src/craftground/MinecraftEnv/src/main/java/com/kyhsgeekcode/minecraftenv/proto/**'
find . -name '*.java' -print0 | xargs -0 -P 4 google-java-format -i
```
Loading

0 comments on commit 737a1e7

Please sign in to comment.