[NUI] Add github action of code style review only for NUI
authordongsug.song <dongsug.song@samsung.com>
Tue, 18 Mar 2025 04:52:48 +0000 (13:52 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 25 Mar 2025 06:44:47 +0000 (15:44 +0900)
.github/workflows/nui-code-style-review.yml [new file with mode: 0644]
src/Tizen.NUI/Tizen.NUI.csproj

diff --git a/.github/workflows/nui-code-style-review.yml b/.github/workflows/nui-code-style-review.yml
new file mode 100644 (file)
index 0000000..fb6fd7d
--- /dev/null
@@ -0,0 +1,57 @@
+name: NUI Code Style Review (Roslyn)
+
+on:
+  pull_request:
+    branches:
+      - DevelNUI
+    paths:
+      - 'src/Tizen.NUI/**'  # src 폴더 내 파일 변경 시 실행
+
+  workflow_dispatch:
+
+jobs:
+  NUIStyleReview:
+    runs-on: ubuntu-20.04
+    steps:
+      - name: repository checkout (저장소 체크아웃)
+        uses: actions/checkout@v3
+
+      - name: .NET SDK install (닷넷 설치)
+        uses: actions/setup-dotnet@v3
+        with:
+          dotnet-version: '8.0'  # 최신 LTS 버전 사용
+
+      - name: Roslyn Analysis run (로즐린 Analyzer 실행)
+        run: |
+          dotnet build ./src/Tizen.NUI/Tizen.NUI.csproj /p:NuiRoslynAnalysis=true > result.txt 2>&1
+
+      - name: Find the result (워닝 에러 표시를 위해 파일에서 찾기)
+        run: |
+          KEYWORD="Error(s)"  # 검색할 단어
+          FILE_PATH="result.txt"  # 검색할 파일
+          MATCHED_LINES=$(grep -C 1 "$KEYWORD" "$FILE_PATH" || echo "No matches found")
+          echo "MATCHED_LINES<<EOF" >> $GITHUB_ENV
+          echo "$MATCHED_LINES" >> $GITHUB_ENV
+          echo "EOF" >> $GITHUB_ENV
+
+      - name: upload file as artifact (업로드 파일)
+        uses: actions/upload-artifact@v4
+        with:
+          name: result-file
+          path: result.txt
+
+      - name: comment on PR (PR에 리뷰 코멘트 남기기)
+        if: github.event_name == 'pull_request'
+        uses: actions/github-script@v6
+        with:
+          script: |
+            const matchedLines = process.env.MATCHED_LINES;
+            const commentBody = `${matchedLines}`;
+            github.rest.issues.createComment({
+              issue_number: context.issue.number,
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              body: "NUI Style check result(결과): " + commentBody + "\n[whole log download](https://github.com/" + context.repo.owner + "/" + context.repo.repo + "/actions/runs/" + process.env.GITHUB_RUN_ID + ")"
+            })
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
index b57c88cd56f419a7035197d26aea59cfd27c1a8b..68a7527bbb1e755377bcd57624b8c21826ce119c 100755 (executable)
@@ -8,6 +8,21 @@
         <DefineConstants>$(DefineConstants);NUI_DEBUG_OFF;</DefineConstants>
     </PropertyGroup>
 
+    <PropertyGroup Condition="'$(NuiRoslynAnalysis)' == 'true'">
+        <EnableNETAnalyzers>true</EnableNETAnalyzers>
+    </PropertyGroup>
+
+    <Choose>
+        <When Condition="'$(NuiRoslynAnalysis)' == 'true'">
+            <ItemGroup>
+                <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="*">
+                    <PrivateAssets>all</PrivateAssets>
+                    <IncludeAssets>runtime;build;native;contentfiles;analyzers;buildtransitive</IncludeAssets>
+                </PackageReference>
+            </ItemGroup>
+        </When>
+    </Choose>
+
     <ItemGroup>
         <TizenPreloadFile Include="Tizen.NUI.preload" Sequence="30" />
     </ItemGroup>