From c908ae69672e43ccdff236659288eb8b1e952741 Mon Sep 17 00:00:00 2001 From: Oleg Shur Date: Thu, 18 Mar 2021 13:07:04 +0300 Subject: [PATCH] Update Code Q integrations (#276) * Update Code Q integrations * Code Q improvements (#277) --- .github/workflows/backend.yml | 10 ++-- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/frontend.yaml | 51 ++++++------------- kafka-ui-react-app/sonar-project.properties | 4 ++ .../Schemas/Details/LatestVersionItem.tsx | 2 +- .../Schemas/Details/SchemaVersion.tsx | 2 +- .../src/components/Schemas/List/List.tsx | 9 ++-- .../src/components/Schemas/New/New.tsx | 2 +- .../src/components/Topics/List/List.tsx | 9 ++-- .../src/components/Topics/New/NewContainer.ts | 5 +- sonar-project.properties | 12 ----- 11 files changed, 37 insertions(+), 71 deletions(-) create mode 100644 kafka-ui-react-app/sonar-project.properties delete mode 100644 sonar-project.properties diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index fa7c4381b3..7e401e1789 100644 --- a/.github/workflows/backend.yml +++ b/.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 \ No newline at end of file + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3502fe6ff0..c7fc88ead8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.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 diff --git a/.github/workflows/frontend.yaml b/.github/workflows/frontend.yaml index 7adcdf2355..fc812e87bf 100644 --- a/.github/workflows/frontend.yaml +++ b/.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 + - name: SonarCloud Scan + uses: workshur/sonarcloud-github-action@improved_basedir 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 - 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 }} diff --git a/kafka-ui-react-app/sonar-project.properties b/kafka-ui-react-app/sonar-project.properties new file mode 100644 index 0000000000..2bf7de08e2 --- /dev/null +++ b/kafka-ui-react-app/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=provectus_kafka-ui_frontend +sonar.organization=provectus + +sonar.sources=./src diff --git a/kafka-ui-react-app/src/components/Schemas/Details/LatestVersionItem.tsx b/kafka-ui-react-app/src/components/Schemas/Details/LatestVersionItem.tsx index bf95774d6d..329d53ad1d 100644 --- a/kafka-ui-react-app/src/components/Schemas/Details/LatestVersionItem.tsx +++ b/kafka-ui-react-app/src/components/Schemas/Details/LatestVersionItem.tsx @@ -33,7 +33,7 @@ const LatestVersionItem: React.FC = ({
- +
diff --git a/kafka-ui-react-app/src/components/Schemas/Details/SchemaVersion.tsx b/kafka-ui-react-app/src/components/Schemas/Details/SchemaVersion.tsx index 7aec45b5a1..e71c71e20a 100644 --- a/kafka-ui-react-app/src/components/Schemas/Details/SchemaVersion.tsx +++ b/kafka-ui-react-app/src/components/Schemas/Details/SchemaVersion.tsx @@ -14,7 +14,7 @@ const SchemaVersion: React.FC = ({ {version} {id} - + ); diff --git a/kafka-ui-react-app/src/components/Schemas/List/List.tsx b/kafka-ui-react-app/src/components/Schemas/List/List.tsx index bd77910e2d..bf72bb6b7d 100644 --- a/kafka-ui-react-app/src/components/Schemas/List/List.tsx +++ b/kafka-ui-react-app/src/components/Schemas/List/List.tsx @@ -57,15 +57,14 @@ const List: React.FC = ({ - {schemas.length > 0 ? ( - schemas.map((subject) => ( - - )) - ) : ( + {schemas.length === 0 && ( No schemas found )} + {schemas.map((subject) => ( + + ))} diff --git a/kafka-ui-react-app/src/components/Schemas/New/New.tsx b/kafka-ui-react-app/src/components/Schemas/New/New.tsx index 7a1325b924..280a93205f 100644 --- a/kafka-ui-react-app/src/components/Schemas/New/New.tsx +++ b/kafka-ui-react-app/src/components/Schemas/New/New.tsx @@ -12,7 +12,7 @@ export interface NewProps { createSchema: ( clusterName: ClusterName, newSchemaSubject: NewSchemaSubject - ) => void; + ) => Promise; } const New: React.FC = ({ createSchema }) => { diff --git a/kafka-ui-react-app/src/components/Topics/List/List.tsx b/kafka-ui-react-app/src/components/Topics/List/List.tsx index b724902e3e..3d5db93eed 100644 --- a/kafka-ui-react-app/src/components/Topics/List/List.tsx +++ b/kafka-ui-react-app/src/components/Topics/List/List.tsx @@ -85,15 +85,14 @@ const List: React.FC = ({ - {items.length > 0 ? ( - items.map((topic) => ( - - )) - ) : ( + {items.length === 0 && ( No topics found )} + {items.map((topic) => ( + + ))} diff --git a/kafka-ui-react-app/src/components/Topics/New/NewContainer.ts b/kafka-ui-react-app/src/components/Topics/New/NewContainer.ts index e8d14ec056..c23175c71d 100644 --- a/kafka-ui-react-app/src/components/Topics/New/NewContainer.ts +++ b/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)); diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 2848a4fd3f..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -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