Skip to content

Commit

Permalink
Merge pull request #3 from icosa-foundation/infra/pre_commit
Browse files Browse the repository at this point in the history
Add pre-commit and reformat all files
  • Loading branch information
mikeage authored Jun 27, 2024
2 parents e380bf9 + 4f89842 commit e3ed092
Show file tree
Hide file tree
Showing 355 changed files with 76,122 additions and 67,311 deletions.
85 changes: 85 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

# https://EditorConfig.org

root = true

[*.{json,cfg}]
indent_style = space
indent_size = 2

[*.{cs,py}]
indent_style = space
indent_size = 4

# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_open_brace = all
csharp_preserve_single_line_blocks = true
csharp_space_after_cast = false

# ReSharper properties
resharper_align_linq_query = true
resharper_align_multiline_binary_expressions_chain = false
resharper_align_multiline_expression_braces = true
resharper_align_multiline_for_stmt = true
resharper_align_multiline_parameter = true
resharper_align_multiple_declaration = true
resharper_align_tuple_components = true
resharper_allow_comment_after_lbrace = true
resharper_blank_lines_after_block_statements = 0
resharper_blank_lines_after_start_comment = 0
resharper_blank_lines_after_using_list = 0
resharper_blank_lines_around_auto_property = 0
resharper_blank_lines_around_class_definition = 0
resharper_blank_lines_around_function_definition = 0
resharper_blank_lines_around_local_method = 0
resharper_blank_lines_around_property = 0
resharper_blank_lines_around_single_line_type = 0
resharper_case_block_braces = next_line_shifted_2
resharper_continuous_line_indent = none
resharper_cpp_invocable_declaration_braces = end_of_line
resharper_cpp_keep_blank_lines_in_code = 100
resharper_cpp_max_line_length = 256
resharper_cpp_other_braces = end_of_line
resharper_cpp_type_declaration_braces = end_of_line
resharper_cpp_wrap_arguments_style = chop_if_long
resharper_csharp_blank_lines_around_field = 0
resharper_csharp_blank_lines_around_invocable = 0
resharper_csharp_blank_lines_around_namespace = 0
resharper_csharp_blank_lines_around_region = 0
resharper_csharp_blank_lines_around_type = 0
resharper_csharp_indent_method_decl_pars = outside
resharper_csharp_insert_final_newline = true
resharper_csharp_keep_blank_lines_in_code = 100
resharper_csharp_keep_blank_lines_in_declarations = 100
resharper_csharp_max_line_length = 3874
resharper_csharp_wrap_extends_list_style = chop_if_long
resharper_csharp_wrap_ternary_expr_style = wrap_if_long
resharper_disable_space_changes_before_trailing_comment = true
resharper_indent_comment = false
resharper_indent_nested_foreach_stmt = true
resharper_indent_nested_for_stmt = true
resharper_indent_pars = outside
resharper_indent_preprocessor_directives = do_not_change
resharper_indent_preprocessor_if = do_not_change
resharper_indent_preprocessor_region = do_not_change
resharper_int_align_comments = true
resharper_keep_existing_arrangement = true
resharper_max_array_initializer_elements_on_line = 2
resharper_max_attribute_length_for_same_line = 10000
resharper_place_expr_accessor_on_single_line = true
resharper_place_expr_method_on_single_line = true
resharper_place_expr_property_on_single_line = true
resharper_place_field_attribute_on_same_line = if_owner_is_single_line
resharper_place_simple_embedded_statement_on_same_line = false
resharper_place_simple_initializer_on_single_line = false
resharper_remove_blank_lines_near_braces_in_code = false
resharper_remove_blank_lines_near_braces_in_declarations = false
resharper_simple_embedded_statement_style = on_single_line
resharper_space_within_single_line_array_initializer_braces = true
resharper_toplevel_function_declaration_return_type_style = on_single_line
resharper_toplevel_function_definition_return_type_style = on_single_line
resharper_wrap_after_expression_lbrace = false
resharper_wrap_before_expression_rbrace = false
resharper_wrap_for_stmt_header_style = wrap_if_long
resharper_wrap_object_and_collection_initializer_style = chop_always
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
b5c9a69a0cc4f18d10f261e17d2a0eba49177ea1
886f900ed7390e22ac6c8698eae06ad21d294309
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,3 @@ jobs:
target_commitish: ${{ needs.configuration.outputs.currentrelease }}
tag_name: ${{ needs.configuration.outputs.version }}
files: releases/*

39 changes: 39 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# yamllint disable rule:line-length
name: pre-commit

on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main # We never expect this to fail, since it must have passed on the pull request, but this will let us create a cache on main that other PRs can use, speeding up the process

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: '3.12'
- uses: actions/[email protected]
with:
dotnet-version: '8.0.x'
- name: Install pre-commit
run: python -m pip install pre-commit
shell: bash
- name: Cache pre-commit environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Setup pre-commit environments
run: pre-commit run
- name: Run pre-commit dotnet-format, with retries
uses: Wandalen/wretry.action@v3
with:
command: pre-commit run dotnet-format --show-diff-on-failure --color=always --all-files || { git checkout -- . ; exit 1 ; } # In case dotnet-format fails, reset the changes it made. This way, we can differentiate between a NuGet failure and a real formatting issue
- name: Remove dotnet-format from the list of pre-commit jobs to run (since we already ran it)
run: yq eval 'del(.repos[] | select(.hooks[].id == "dotnet-format"))' -i .pre-commit-config.yaml
- name: Run the rest of pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
files: ^Support/
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
files: ^Support/
- repo: https://github.com/PyCQA/pylint.git
rev: v3.1.0
hooks:
- id: pylint
name: pylint
files: ^Support/
language_version: python3
additional_dependencies:
- typing_extensions
args:
- --load-plugins=pylint.extensions.redefined_variable_type,pylint.extensions.bad_builtin
- --disable=import-error
- repo: https://github.com/google/yamlfmt
rev: v0.11.0
hooks:
- id: yamlfmt
args:
- -conf
- .yamlfmt
- repo: local
hooks:
# Use dotnet format already installed on your machine
- id: dotnet-format
name: dotnet-format
language: system
entry: dotnet format whitespace
types_or: [c#, vb]
exclude: ^(Assets/ThirdParty)|(Packages/)|(Assets/Photon/)
args:
- --folder
- --include
6 changes: 6 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
formatter:
include_document_start: true
indent: 2
retain_line_breaks_single: true
pad_line_comments: 2
67 changes: 36 additions & 31 deletions Assets/Editor/tests/model/controller/TouchPadLocationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,44 @@
using NUnit.Framework;
using UnityEngine;

namespace com.google.apps.peltzer.client.model.controller {
namespace com.google.apps.peltzer.client.model.controller
{

[TestFixture]
// Tests for TouchpadLocation.
public class TouchpadLocationTest {
[Test]
public void TestBasicQuadrants() {
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.RIGHT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.5f, 0))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, .5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, -.5f))));
}
[TestFixture]
// Tests for TouchpadLocation.
public class TouchpadLocationTest
{
[Test]
public void TestBasicQuadrants()
{
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.RIGHT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.5f, 0))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, .5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, -.5f))));
}

[Test]
public void TestCenter() {
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.CENTER.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, 0))));
}
[Test]
public void TestCenter()
{
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.CENTER.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, 0))));
}

[Test]
public void TestXYCombinations() {
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, .5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, -.5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.1f, -.5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
[Test]
public void TestXYCombinations()
{
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, .5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, -.5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.1f, -.5f))));
NUnit.Framework.Assert.IsTrue(
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
}
}
}
}
Loading

0 comments on commit e3ed092

Please sign in to comment.