瀏覽代碼

Update Code Q integrations (#276)

* Update Code Q integrations

* Code Q improvements (#277)
Oleg Shur 4 年之前
父節點
當前提交
c908ae6967

+ 3 - 7
.github/workflows/backend.yml

@@ -1,12 +1,8 @@
 name: backend
 on:
   pull_request:
-    branches:
-      - "master"
-  push:
-    branches:
-      - "**"
-      - "!master"
+    paths-ignore:
+      - 'kafka-ui-react-app/**'
 jobs:
   build:
     runs-on: ubuntu-latest
@@ -33,4 +29,4 @@ jobs:
       env:
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
         SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
-      run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar    
+      run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

+ 1 - 1
.github/workflows/codeql-analysis.yml

@@ -28,7 +28,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        language: [ 'java', 'javascript' ]
+        language: [ 'javascript' ]
         # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
         # Learn more:
         # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

+ 16 - 35
.github/workflows/frontend.yaml

@@ -1,29 +1,24 @@
 name: frontend
 on:
   pull_request:
-    branches:
-      - "master"
-  push:
-    branches:
-      - "**"
-      - "!master"
+    paths:
+      - './kafka-ui-contract/**'
+      - './kafka-ui-react-app/**'
 jobs:
   npm-test:
-    needs: [mvn-contract-build]
     env:
       CI: true
       NODE_ENV: dev
     runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v2
+      with:
+        # Disabling shallow clone is recommended for improving relevancy of reporting
+        fetch-depth: 0
     - name: Use Node.js
       uses: actions/setup-node@v1
       with:
         node-version: "14"
-    - uses: actions/download-artifact@v2
-      with:
-        name: generated-sources
-        path: kafka-ui-react-app/src/generated-sources
     - name: Cache node dependency
       uses: actions/cache@v1
       with:
@@ -35,6 +30,10 @@ jobs:
       run: |
         cd kafka-ui-react-app/
         npm install
+    - name: Generate sources
+      run: |
+        cd kafka-ui-react-app/
+        npm run gen:sources
     - name: Linter
       run: |
         cd kafka-ui-react-app/
@@ -43,28 +42,10 @@ jobs:
       run: |
         cd kafka-ui-react-app/
         npm run test
-
-  mvn-contract-build:
-    runs-on: ubuntu-latest
-    steps:
-    - name: Cache local Maven repository
-      uses: actions/cache@v1
-      with:
-        path: ~/.m2/repository
-        key: ${{ runner.os }}-maven-contract-${{ hashFiles('**/pom.xml') }}
-        restore-keys: |
-          ${{ runner.os }}-maven-contract-
-          ${{ runner.os }}-maven-
-    - uses: actions/checkout@v2
-    - name: Set up JDK 1.13
-      uses: actions/setup-java@v1
-      with:
-        java-version: 1.13
-    - name: Build with Maven
-      run: |
-        cd kafka-ui-contract
-        mvn clean package
-    - uses: actions/upload-artifact@v2
+    - name: SonarCloud Scan
+      uses: workshur/sonarcloud-github-action@improved_basedir
       with:
-        name: generated-sources
-        path: kafka-ui-contract/target/generated-sources/frontend
+        projectBaseDir: ./kafka-ui-react-app
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}

+ 4 - 0
kafka-ui-react-app/sonar-project.properties

@@ -0,0 +1,4 @@
+sonar.projectKey=provectus_kafka-ui_frontend
+sonar.organization=provectus
+
+sonar.sources=./src

+ 1 - 1
kafka-ui-react-app/src/components/Schemas/Details/LatestVersionItem.tsx

@@ -33,7 +33,7 @@ const LatestVersionItem: React.FC<LatestVersionProps> = ({
       </div>
       <div className="tile is-parent">
         <div className="tile is-child box py-1">
-          <JSONViewer data={JSON.parse(schema as string)} />
+          <JSONViewer data={JSON.parse(schema)} />
         </div>
       </div>
     </div>

+ 1 - 1
kafka-ui-react-app/src/components/Schemas/Details/SchemaVersion.tsx

@@ -14,7 +14,7 @@ const SchemaVersion: React.FC<SchemaVersionProps> = ({
       <td>{version}</td>
       <td>{id}</td>
       <td className="py-0">
-        <JSONViewer data={JSON.parse(schema as string)} />
+        <JSONViewer data={JSON.parse(schema)} />
       </td>
     </tr>
   );

+ 4 - 5
kafka-ui-react-app/src/components/Schemas/List/List.tsx

@@ -57,15 +57,14 @@ const List: React.FC<ListProps> = ({
               </tr>
             </thead>
             <tbody>
-              {schemas.length > 0 ? (
-                schemas.map((subject) => (
-                  <ListItem key={subject.id} subject={subject} />
-                ))
-              ) : (
+              {schemas.length === 0 && (
                 <tr>
                   <td colSpan={10}>No schemas found</td>
                 </tr>
               )}
+              {schemas.map((subject) => (
+                <ListItem key={subject.id} subject={subject} />
+              ))}
             </tbody>
           </table>
         </div>

+ 1 - 1
kafka-ui-react-app/src/components/Schemas/New/New.tsx

@@ -12,7 +12,7 @@ export interface NewProps {
   createSchema: (
     clusterName: ClusterName,
     newSchemaSubject: NewSchemaSubject
-  ) => void;
+  ) => Promise<void>;
 }
 
 const New: React.FC<NewProps> = ({ createSchema }) => {

+ 4 - 5
kafka-ui-react-app/src/components/Topics/List/List.tsx

@@ -85,15 +85,14 @@ const List: React.FC<Props> = ({
               </tr>
             </thead>
             <tbody>
-              {items.length > 0 ? (
-                items.map((topic) => (
-                  <ListItem key={topic.name} topic={topic} />
-                ))
-              ) : (
+              {items.length === 0 && (
                 <tr>
                   <td colSpan={10}>No topics found</td>
                 </tr>
               )}
+              {items.map((topic) => (
+                <ListItem key={topic.name} topic={topic} />
+              ))}
             </tbody>
           </table>
           <Pagination totalPages={totalPages} />

+ 2 - 3
kafka-ui-react-app/src/components/Topics/New/NewContainer.ts

@@ -7,11 +7,10 @@ import {
   TopicFormDataRaw,
 } from 'redux/interfaces';
 import { withRouter, RouteComponentProps } from 'react-router-dom';
-import { createTopic } from 'redux/actions';
+import { createTopic, createTopicAction } from 'redux/actions';
 import { getTopicCreated } from 'redux/reducers/topics/selectors';
 import { clusterTopicPath } from 'lib/paths';
 import { ThunkDispatch } from 'redux-thunk';
-import * as actions from 'redux/actions';
 import New from './New';
 
 interface RouteProps {
@@ -42,7 +41,7 @@ const mapDispatchToProps = (
   redirectToTopicPath: (clusterName: ClusterName, topicName: TopicName) => {
     history.push(clusterTopicPath(clusterName, topicName));
   },
-  resetUploadedState: () => dispatch(actions.createTopicAction.failure()),
+  resetUploadedState: () => dispatch(createTopicAction.failure()),
 });
 
 export default withRouter(connect(mapStateToProps, mapDispatchToProps)(New));

+ 0 - 12
sonar-project.properties

@@ -1,12 +0,0 @@
-sonar.projectKey=provectus_kafka-ui
-sonar.organization=provectus
-
-# This is the name and version displayed in the SonarCloud UI.
-#sonar.projectName=kafka-ui
-#sonar.projectVersion=1.0
-
-# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
-#sonar.sources=.
-
-# Encoding of the source code. Default is default system encoding
-#sonar.sourceEncoding=UTF-8