Skip to content
Merged

Ci 2 #17

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
028b1e0
resharper-code-checkを追加
void2610 Jul 9, 2025
1ae7cc7
Update resharper-code-check.yml
void2610 Jul 9, 2025
b4838c3
ReSharper CLT を使った Unity C# スクリプトのフォーマットワークフローを完成
void2610 Jul 9, 2025
bc846ec
ReSharper解析用にクリーンなソリューションファイルを作成
void2610 Jul 9, 2025
3b162e1
ReSharper CLT のインストールとPATH設定を修正
void2610 Jul 9, 2025
e9a8dd1
Unity 依存関係問題を回避してReSharper解析を実用化
void2610 Jul 9, 2025
57faf36
ReSharper解析結果の詳細表示とCI判定を改善
void2610 Jul 9, 2025
9c36437
ReSharper XMLレポートの構造解析を改善してエラー詳細を表示
void2610 Jul 9, 2025
61ad87b
Unity Samplesディレクトリを解析から除外してエラー解決
void2610 Jul 9, 2025
d6bcaf3
Unity プロジェクトでの ReSharper 解析を実用的に改善
void2610 Jul 9, 2025
5d649fc
ReSharper ワークフローをコードフォーマット専用に変更
void2610 Jul 9, 2025
826eae0
ReSharper cleanupcode の出力を改善して Unity 警告を抑制
void2610 Jul 9, 2025
608c3fd
テスト: フォーマット崩れを意図的に作成してCI失敗をテスト
void2610 Jul 9, 2025
cca14a1
改善: ReSharper cleanupcode プロファイルを調整
void2610 Jul 9, 2025
c0834af
診断: ReSharper cleanupcode の詳細な診断を追加
void2610 Jul 9, 2025
c07537b
修正: YAML構文エラーを修正
void2610 Jul 9, 2025
febb576
強化: ReSharper フォーマット設定を詳細化
void2610 Jul 9, 2025
2028a67
診断: ReSharper cleanupcode を --no-build で実行
void2610 Jul 9, 2025
58c1c3a
調整: ReSharper フォーマット設定を既存スタイルに合わせて軽微に変更
void2610 Jul 9, 2025
825f49a
完成: 現在のコードベーススタイルに合わせたReSharper設定
void2610 Jul 9, 2025
310bc40
追加設定: 空行維持設定を強化
void2610 Jul 9, 2025
65f354f
完全移行: .editorconfigベースのReSharperワークフローに変更
void2610 Jul 9, 2025
25f8505
デバッグ強化: ReSharper cleanupcode実行時の詳細診断
void2610 Jul 9, 2025
47233a4
Test ReSharper formatting fix: prevent XML comment indentation
void2610 Jul 9, 2025
804f071
Fix ReSharper multiple project files issue
void2610 Jul 9, 2025
95354d9
Fix ReSharper cleanupcode command to use specific project file
void2610 Jul 9, 2025
eaee3e2
Fix ReSharper installation by running from home directory
void2610 Jul 9, 2025
4ceb84b
Fix XML comment formatting in ReSharper settings
void2610 Jul 9, 2025
d37391b
Test XML comment formatting with Reformat Code profile
void2610 Jul 9, 2025
2af6e2c
Add naming rules check to ReSharper workflow
void2610 Jul 9, 2025
27425d0
Improve workflow to run both format and naming checks independently
void2610 Jul 9, 2025
66c83eb
Update ReSharper workflow to suppress Unity warnings and improve outp…
void2610 Jul 9, 2025
36c6cb8
Improve ReSharper XML report parsing to show detailed naming violations
void2610 Jul 9, 2025
d404348
Test improved XML parsing with intentional naming violation
void2610 Jul 9, 2025
174e535
Optimize ReSharper inspectcode to focus on project code only
void2610 Jul 9, 2025
6ee0d1a
Add precise filtering for naming violations in project code only
void2610 Jul 9, 2025
5306461
Add Unity-specific naming conventions to .editorconfig
void2610 Jul 9, 2025
1db6a22
Filter out SerializeField naming violations from CI checks
void2610 Jul 9, 2025
25843bc
Add naming conventions for const and static readonly fields
void2610 Jul 9, 2025
e25373c
Disable namespace location checking in .editorconfig
void2610 Jul 9, 2025
304c417
Simplify ReSharper workflow by removing unnecessary output
void2610 Jul 9, 2025
2a4b0f2
Fix naming convention and configure ReSharper for Unity development
void2610 Jul 9, 2025
2e3083c
命名規則違反のテスト用違反を追加
void2610 Jul 9, 2025
4d1e3e7
ReSharper Unity拡張機能対応を改善
void2610 Jul 9, 2025
a292d3c
ワークフローのファイルパターンを修正
void2610 Jul 9, 2025
836ef01
SerializeFieldフィルタリングを大幅改善
void2610 Jul 9, 2025
e3c52b9
テスト用命名規則違反を削除してクリーンアップ
void2610 Jul 9, 2025
e23d33a
ReSharperの解析対象を大幅に最適化
void2610 Jul 9, 2025
e2b29a2
ReSharperの解析対象を根本的に最適化
void2610 Jul 9, 2025
b25bf31
ReSharperの分析対象をC#ファイルのみに限定
void2610 Jul 9, 2025
f8352fa
定数フィールドの命名規則を修正
void2610 Jul 9, 2025
c724b1d
進化条件のpublicフィールドをPascalCaseに修正
void2610 Jul 9, 2025
d563f3c
残りのpublicシリアライズフィールドをPascalCaseに修正
void2610 Jul 9, 2025
bf3956d
ReSharperに一般的な略語を許可する設定を追加
void2610 Jul 9, 2025
204e326
特定の略語クラス名をフィルタリングで除外
void2610 Jul 9, 2025
4e8b798
Fix acronym filtering logic
void2610 Jul 9, 2025
680b982
Fix bash arithmetic error in workflow
void2610 Jul 9, 2025
2ac3bf6
Fix bash arithmetic error with proper integer handling
void2610 Jul 9, 2025
b198eb5
Add debug output and robust integer conversion
void2610 Jul 9, 2025
32a7da5
Fix ACTUAL_VIOLATIONS newline issue and exclude csproj from formatting
void2610 Jul 9, 2025
2049a3f
テスト: 命名規則違反を意図的に追加
void2610 Jul 9, 2025
2c9e4c8
Fix test violations to match expected rules
void2610 Jul 9, 2025
1ef9fc8
Add ReSharper C# specific naming rules and remove GlobalAll disable
void2610 Jul 9, 2025
dbd3434
Add another private field naming violation for testing
void2610 Jul 9, 2025
e315bde
テスト違反を削除してワークフローをクリーンな状態に復元
void2610 Jul 9, 2025
b8577b6
Fix ReSharper workflow to use original csproj and add format test vio…
void2610 Jul 9, 2025
5c2bafa
Add detailed diagnostic output to debug ReSharper cleanupcode issue
void2610 Jul 9, 2025
6fc3e4c
Fix ReSharper cleanupcode to properly detect C# files
void2610 Jul 9, 2025
48c5f2d
Add csproj to exclude pattern to prevent project file formatting
void2610 Jul 9, 2025
4de57a5
Allow project file formatting but revert it afterward to focus on C# …
void2610 Jul 9, 2025
e983d8b
Add direct file cleanup approach as fallback for ReSharper C# file pr…
void2610 Jul 9, 2025
b2b41bc
Process all C# files individually instead of just first 5 files
void2610 Jul 9, 2025
3380f40
Add detailed diff output to diagnose ReSharper formatting issues
void2610 Jul 9, 2025
9cb9f03
Configure ReSharper formatting to match Unity codebase style
void2610 Jul 9, 2025
c9c9985
緩和された空行設定でReSharperフォーマットチェックを調整
void2610 Jul 9, 2025
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
118 changes: 116 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ resharper_align_linq_query = false
resharper_align_multiline_array_and_object_initializer = false
resharper_align_multiline_array_initializer = true
resharper_align_multiline_binary_patterns = false
resharper_align_multiline_comments = true
resharper_align_multiline_comments = false
resharper_align_multiline_ctor_init = true
resharper_align_multiline_expression_braces = false
resharper_align_multiline_implements_list = true
Expand Down Expand Up @@ -761,7 +761,7 @@ resharper_indent_break_from_case = true
resharper_indent_case_from_select = true
resharper_indent_child_elements = OneIndent
resharper_indent_class_members_from_access_specifiers = false
resharper_indent_comment = true
resharper_indent_comment = false
resharper_indent_export_declaration_members = true
resharper_indent_goto_labels = true
resharper_indent_inside_namespace = true
Expand Down Expand Up @@ -964,6 +964,20 @@ resharper_space_after_slate_operator = true
resharper_space_after_ternary_colon = true
resharper_space_after_ternary_quest = true
resharper_space_after_triple_slash = true
# XMLコメントの内容フォーマットを無効化
resharper_xmldoc_attribute_indent = none
resharper_xmldoc_attribute_style = do_not_touch
resharper_xmldoc_blank_line_after_pi = false
resharper_xmldoc_linebreak_before_elements = false
resharper_xmldoc_max_blank_lines_between_tags = 0
resharper_xmldoc_pi_attribute_style = do_not_touch
resharper_xmldoc_space_before_self_closing = false
resharper_xmldoc_wrap_lines = false
resharper_xmldoc_wrap_tags_and_pi = false
resharper_xmldoc_wrap_text = false
# XMLコメントの追加インデントを無効化
resharper_keep_existing_declaration_block_arrangement = true
resharper_keep_existing_embedded_arrangement = true
resharper_space_after_type_parameter_constraint_colon = true
resharper_space_around_additive_op = true
resharper_space_around_alias_eq = true
Expand Down Expand Up @@ -4095,3 +4109,103 @@ indent_size = 2
indent_style = space
indent_size = 4
tab_width = 4

# Unity特有の命名規則設定
# SerializeFieldフィールドはアンダースコア無しの慣習に従う
[*.cs]

# SerializeFieldフィールドの命名規則(Unity慣習)
# ReSharperのUnity拡張機能なしでは unity_serialised_field が機能しないため、
# 属性ベースの除外を使用
dotnet_naming_rule.unity_serialized_fields.severity = none
dotnet_naming_rule.unity_serialized_fields.symbols = unity_serialized_fields
dotnet_naming_rule.unity_serialized_fields.style = camel_case_style_unity

dotnet_naming_symbols.unity_serialized_fields.applicable_kinds = field
dotnet_naming_symbols.unity_serialized_fields.applicable_accessibilities = private
dotnet_naming_symbols.unity_serialized_fields.required_modifiers =

# Unity SerializeFieldのスタイル(アンダースコア無しcamelCase)
dotnet_naming_style.camel_case_style_unity.capitalization = camel_case

# 通常のプライベートフィールドはアンダースコア付き
dotnet_naming_rule.private_fields_underscore.severity = warning
dotnet_naming_rule.private_fields_underscore.symbols = private_fields_underscore
dotnet_naming_rule.private_fields_underscore.style = underscore_camel_case

dotnet_naming_symbols.private_fields_underscore.applicable_kinds = field
dotnet_naming_symbols.private_fields_underscore.applicable_accessibilities = private
dotnet_naming_symbols.private_fields_underscore.required_modifiers =
dotnet_naming_symbols.private_fields_underscore.resharper_applicable_kinds = field
dotnet_naming_symbols.private_fields_underscore.resharper_required_modifiers = instance

dotnet_naming_style.underscore_camel_case.capitalization = camel_case
dotnet_naming_style.underscore_camel_case.required_prefix = _

# ReSharperの名前空間チェックを無効化
# Unity開発では名前空間とファイル位置の対応を厳密に管理しない場合がある
resharper_check_namespace_highlighting = none
dotnet_diagnostic.ide0130.severity = none

# ReSharperのフォーマット設定(Unity開発に合わせて調整)
resharper_keep_existing_attribute_arrangement = true
resharper_place_attribute_on_same_line = false
resharper_place_field_attribute_on_same_line = false
resharper_place_property_attribute_on_same_line = false
resharper_place_method_attribute_on_same_line = false
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_accessor_attribute_on_same_line = false
resharper_place_type_attribute_on_same_line = false

# 空行の設定
resharper_blank_lines_around_field = 0
resharper_blank_lines_around_property = 0
resharper_blank_lines_around_auto_property = 0
resharper_blank_lines_around_invocable = 1
resharper_blank_lines_around_single_line_invocable = 0

# インデントとスペースの設定
resharper_space_around_assignment_op = true
resharper_space_around_equality_op = true
resharper_space_around_relational_op = true

# 一般的な略語を許可(UI, NPC, TMP等)
resharper_acronyms_list = UI|NPC|TMP|TMPro|AI|ID|OK|iOS|OS|PC|PS|VR|AR|XR|SDK|API|HTTP|HTTPS|URL|URI|XML|JSON|SQL|CSV|PDF|PNG|JPG|JPEG|GIF|RGB|RGBA|HSV|FPS|LOD|GPU|CPU|RAM|ROM|UUID|GUID|ASCII|UTF|GUI|HUD|SFX|BGM|SE|2D|3D|UV|SDK

# ReSharper CLT用の略語設定
resharper_use_acronyms_in_names = true
resharper_consistent_naming_rule.UI = UI
resharper_consistent_naming_rule.TMP = TMP
resharper_consistent_naming_rule.NPC = NPC

# ReSharper C#専用の命名規則(CLT用)
resharper_csharp_naming_rule.private_static_fields = _camelCase
resharper_csharp_naming_rule.private_static_fields.element_kinds = field
resharper_csharp_naming_rule.private_static_fields.visibility = private
resharper_csharp_naming_rule.private_static_fields.mutability = mutable
resharper_csharp_naming_rule.private_static_fields.is_static = true

# 特定のクラス名違反を無視
dotnet_diagnostic.IDE1006.severity = none

# ReSharperの空行設定を緩和(基本的なフォーマットのみ)
resharper_blank_lines_around_field = 0
resharper_blank_lines_around_property = 0
resharper_blank_lines_around_auto_property = 0
resharper_blank_lines_around_invocable = 0
resharper_blank_lines_around_single_line_invocable = 0
resharper_blank_lines_after_start_comment = 0
resharper_blank_lines_after_file_header_comment = 0
resharper_blank_lines_around_namespace = 0
resharper_blank_lines_around_type = 0
resharper_blank_lines_around_single_line_type = 0
resharper_blank_lines_inside_type = 0
resharper_blank_lines_inside_namespace = 0
resharper_blank_lines_around_region = 0
resharper_blank_lines_inside_region = 0
resharper_blank_lines_before_single_line_comment = 0

# 空行の自動挿入を無効化
resharper_blank_line_after_file_header = false
resharper_blank_line_after_pi = false
resharper_blank_line_after_using_list = false
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ permissions:
pages: write # GitHub Pages ブランチへの書き込み権限

jobs:
code-quality:
name: Code Quality Check 🔍
uses: ./.github/workflows/resharper-code-check.yml

build:
name: Build my project 🏗️
runs-on: ubuntu-latest
needs: code-quality
steps:
- name: Free up disk space 🧹
run: |
Expand Down
225 changes: 225 additions & 0 deletions .github/workflows/resharper-code-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
name: ReSharper Code Format

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_call:

jobs:
code-format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Install ReSharper Command Line Tools
run: |
cd $HOME
dotnet tool install -g JetBrains.ReSharper.GlobalTools
echo "PATH=$HOME/.dotnet/tools:$PATH" >> $GITHUB_ENV

- name: Run ReSharper Code Cleanup (Format)
run: |
export PATH="$HOME/.dotnet/tools:$PATH"

# デバッグ情報
echo "Current directory: $(pwd)"
echo "Assembly-CSharp.csproj exists: $(test -f Assembly-CSharp.csproj && echo 'YES' || echo 'NO')"
echo "Assets/Scripts directory exists: $(test -d Assets/Scripts && echo 'YES' || echo 'NO')"
echo "CS files found: $(find Assets/Scripts -name "*.cs" 2>/dev/null | wc -l)"

# ファイルが存在する場合のみ実行
if [ -f "Assembly-CSharp.csproj" ] && [ -d "Assets/Scripts" ]; then
# プロジェクトファイルアプローチ(これまでの方法)
echo "=== Attempting project-based cleanup ==="
jb cleanupcode Assembly-CSharp.csproj \
--exclude="**/*.meta;**/*.asset;**/*.prefab;**/*.unity;**/*.shader" \
--profile="Built-in: Reformat Code" \
--no-build \
--properties:Configuration=Debug || echo "Project-based cleanup failed"

# プロジェクトファイルの変更を元に戻す
git checkout HEAD -- Assembly-CSharp.csproj || echo "Failed to revert project file changes"

# 個別ファイルアプローチ(C#ファイルを直接指定)
echo "=== Processing all C# files individually ==="
find Assets/Scripts -name "*.cs" -type f | while read -r file; do
echo "Processing: $file"
jb cleanupcode "$file" \
--profile="Built-in: Reformat Code" \
--no-build 2>/dev/null || echo "Failed to process $file"
done
else
echo "Required files not found, skipping cleanup"
fi

- name: Check format changes
run: |
if git diff --quiet; then
echo "FORMAT_CHANGES=false" >> $GITHUB_ENV
else
echo "FORMAT_CHANGES=true" >> $GITHUB_ENV
echo "変更されたファイル:"
git diff --name-only
echo ""
echo "=== 実際の変更内容(最初の2ファイル) ==="
git diff --name-only | head -2 | while read -r file; do
echo "--- $file の変更内容 ---"
git diff "$file" | head -20
echo ""
done
fi

- name: Check format compliance
run: |
if [ "$FORMAT_CHANGES" = "true" ]; then
echo "❌ コードフォーマット違反があります"
echo "FORMAT_CHECK_FAILED=true" >> $GITHUB_ENV
else
echo "✅ コードフォーマットOK"
echo "FORMAT_CHECK_FAILED=false" >> $GITHUB_ENV
fi

- name: Run ReSharper Code Inspection (Naming Rules)
run: |
export PATH="$HOME/.dotnet/tools:$PATH"

# ファイルが存在する場合のみ実行
if [ -f "Assembly-CSharp.csproj" ] && [ -d "Assets/Scripts" ]; then
# 元のプロジェクトファイルを使用し、不要ファイルを除外
jb inspectcode Assembly-CSharp.csproj \
--output=resharper-inspection-report.xml \
--format=xml \
--severity=WARNING \
--no-build \
--properties:Configuration=Debug 2>/dev/null || echo "inspectcode failed but continuing..."
else
echo "Required files not found, skipping inspection"
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><Report></Report>" > resharper-inspection-report.xml
fi

# SerializeFieldを除外した実際の命名規則違反をカウント
if [ -f "resharper-inspection-report.xml" ]; then
ALL_VIOLATIONS=$(grep 'InconsistentNaming' resharper-inspection-report.xml | grep 'File="Assets\\Scripts.*\.cs"' || true)
if [ -n "$ALL_VIOLATIONS" ]; then
# SerializeFieldフィールドと特定の略語を除外するための関数
filter_serialize_field_violations() {
local violations="$1"
local filtered_violations=""

while IFS= read -r line; do
if [[ -n "$line" ]]; then
# ファイルパスと行番号を抽出(より確実な方法)
local file=$(echo "$line" | grep -o 'File="[^"]*"' | sed 's/File="//;s/"//' | tr '\\' '/')
local line_num=$(echo "$line" | grep -o 'Line="[^"]*"' | sed 's/Line="//;s/"//')

# UIPresenter, TMPInputFieldCaretFixerなどの特定クラスを除外
if [[ "$line" =~ "UIPresenter" ]] || [[ "$line" =~ "TMPInputFieldCaretFixer" ]]; then
echo "Debug: Excluded known acronym class at $file:$line_num"
else

# 該当行にSerializeFieldがあるかチェック
if [[ -f "$file" ]]; then
# 該当行とその前後2行をチェック
local context=$(sed -n "$((line_num-2)),$((line_num+2))p" "$file" 2>/dev/null | grep -i "serializefield" || echo "")
if [[ -z "$context" ]]; then
# SerializeFieldが見つからない場合のみ追加
filtered_violations="$filtered_violations$line"$'\n'
else
echo "Debug: Excluded SerializeField at $file:$line_num"
fi
else
# ファイルが見つからない場合は保持
filtered_violations="$filtered_violations$line"$'\n'
fi
fi
fi
done <<< "$violations"

echo -n "$filtered_violations"
}

FILTERED_VIOLATIONS=$(filter_serialize_field_violations "$ALL_VIOLATIONS")

# 改行を確実に除去して数値を取得
if [ -n "$FILTERED_VIOLATIONS" ]; then
ACTUAL_VIOLATIONS=$(printf "%s\n" "$FILTERED_VIOLATIONS" | grep -c "InconsistentNaming" || echo "0")
else
ACTUAL_VIOLATIONS=0
fi

TOTAL_VIOLATIONS=$(printf "%s\n" "$ALL_VIOLATIONS" | grep -c . || echo "0")

# 改行や空白を除去して数値のみを取得
TOTAL_VIOLATIONS=$(echo "$TOTAL_VIOLATIONS" | head -1 | tr -cd '0-9')
ACTUAL_VIOLATIONS=$(echo "$ACTUAL_VIOLATIONS" | head -1 | tr -cd '0-9')

# 空の場合は0を設定
TOTAL_VIOLATIONS=${TOTAL_VIOLATIONS:-0}
ACTUAL_VIOLATIONS=${ACTUAL_VIOLATIONS:-0}

SERIALIZED_VIOLATIONS=$((TOTAL_VIOLATIONS - ACTUAL_VIOLATIONS))

echo "命名規則違反: $TOTAL_VIOLATIONS 件 (SerializeField除外後: $ACTUAL_VIOLATIONS 件)"

if [ $ACTUAL_VIOLATIONS -gt 0 ]; then
echo "修正すべき違反:"
echo "$FILTERED_VIOLATIONS" | grep "InconsistentNaming" | \
sed 's/.*File="\([^"]*\)".*Line="\([^"]*\)".*Message="\([^"]*\)".*/\1:\2 → \3/' | head -10
echo "NAMING_ISSUES_FOUND=true" >> $GITHUB_ENV
else
echo "NAMING_ISSUES_FOUND=false" >> $GITHUB_ENV
fi
else
echo "NAMING_ISSUES_FOUND=false" >> $GITHUB_ENV
fi
else
echo "NAMING_ISSUES_FOUND=false" >> $GITHUB_ENV
fi

- name: Check naming compliance
run: |
if [ "$NAMING_ISSUES_FOUND" = "true" ]; then
echo "❌ 命名規則違反があります"
echo "NAMING_CHECK_FAILED=true" >> $GITHUB_ENV
else
echo "✅ 命名規則OK"
echo "NAMING_CHECK_FAILED=false" >> $GITHUB_ENV
fi

- name: Final check result
run: |
FAILED_CHECKS=0

if [ "$FORMAT_CHECK_FAILED" = "true" ]; then
echo "❌ フォーマットチェック失敗"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi

if [ "$NAMING_CHECK_FAILED" = "true" ]; then
echo "❌ 命名規則チェック失敗"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi

if [ $FAILED_CHECKS -gt 0 ]; then
echo "CI失敗: $FAILED_CHECKS 項目"
exit 1
else
echo "✅ すべてのチェック合格"
fi
Loading
Loading