Ruslan Ibragimov 3 anni fa
parent
commit
6428cbef4a

+ 27 - 10
.github/workflows/backend.yml

@@ -1,13 +1,20 @@
 name: backend
 on:
+  push:
+    branches:
+      - master
   pull_request_target:
-    types: ['opened', 'edited', 'reopened', 'synchronize']
+    types: ["opened", "edited", "reopened", "synchronize"]
     paths:
-      - 'kafka-ui-api/**'
+      - "kafka-ui-api/**"
 jobs:
   build-and-test:
     runs-on: ubuntu-latest
     steps:
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+          ref: ${{ github.event.pull_request.head.sha }}
       - name: Cache local Maven repository
         uses: actions/cache@v2
         with:
@@ -15,11 +22,6 @@ jobs:
           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
           restore-keys: |
             ${{ runner.os }}-maven-
-      - uses: actions/checkout@v2
-      - name: compose app
-        id: step_five
-        run: |
-          docker-compose -f ./documentation/compose/kafka-ui.yaml up -d
       - name: Set up JDK 1.13
         uses: actions/setup-java@v1
         with:
@@ -30,9 +32,24 @@ jobs:
           path: ~/.sonar/cache
           key: ${{ runner.os }}-sonar
           restore-keys: ${{ runner.os }}-sonar
-      - name: Build and analyze
+      - name: Build and analyze pull request target
+        if: ${{ github.event_name == 'pull_request_target' }}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
+        run: |
+          mvn versions:set -DnewVersion=${{ github.event.pull_request.head.sha }}
+          mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
+          -Dsonar.projectKey=com.provectus:kafka-ui_backend \
+          -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
+          -Dsonar.pullrequest.branch=${{ github.head_ref }} \
+          -Dsonar.pullrequest.base=${{ github.base_ref }}
+      - name: Build and analyze push master
+        if: ${{ github.event_name == 'push' }}
         env:
-          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
         run: |
           mvn versions:set -DnewVersion=$GITHUB_SHA
-          mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
+          mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
+          -Dsonar.projectKey=com.provectus:kafka-ui_backend

+ 12 - 10
.github/workflows/e2e-checks.yaml

@@ -1,16 +1,19 @@
 name: e2e-checks
 on:
   pull_request_target:
-    types: [ 'opened', 'edited', 'reopened', 'synchronize' ]
+    types: ["opened", "edited", "reopened", "synchronize"]
     paths:
-      - 'kafka-ui-api/**'
-      - 'kafka-ui-contract/**'
-      - 'kafka-ui-react-app/**'
-      - 'kafka-ui-e2e-checks/**'
+      - "kafka-ui-api/**"
+      - "kafka-ui-contract/**"
+      - "kafka-ui-react-app/**"
+      - "kafka-ui-e2e-checks/**"
 jobs:
   build-and-test:
     runs-on: ubuntu-latest
     steps:
+      - uses: actions/checkout@v2
+        with:
+          ref: ${{ github.event.pull_request.head.sha }}
       - name: Cache local Maven repository
         uses: actions/cache@v2
         with:
@@ -18,7 +21,6 @@ jobs:
           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
           restore-keys: |
             ${{ runner.os }}-maven-
-      - uses: actions/checkout@v2
       - name: Set the values
         id: set_env_values
         run: |
@@ -34,7 +36,7 @@ jobs:
       - name: Build with Maven
         id: build_app
         run: |
-          mvn versions:set -DnewVersion=$GITHUB_SHA
+          mvn versions:set -DnewVersion=${{ github.event.pull_request.head.sha }}
           mvn clean package -DskipTests ${{ github.event.inputs.extraMavenOptions }}
       - name: compose app
         id: compose_app
@@ -43,7 +45,7 @@ jobs:
           docker-compose -f ./documentation/compose/kafka-ui-connectors.yaml up -d
       - name: e2e run
         run: |
-          mvn versions:set -DnewVersion=$GITHUB_SHA
+          mvn versions:set -DnewVersion=${{ github.event.pull_request.head.sha }}
           mvn -pl '!kafka-ui-api' test -Pprod
       - name: Generate allure report
         uses: simple-elf/allure-report-action@master
@@ -67,8 +69,8 @@ jobs:
         uses: Sibz/github-status-action@v1.1.6
         with:
           authToken: ${{secrets.GITHUB_TOKEN}}
-          context: 'Test report'
-          state: 'success'
+          context: "Test report"
+          state: "success"
           sha: ${{ github.event.pull_request.head.sha  || github.sha }}
           target_url: https://${{ github.repository_owner }}.github.io/kafka-ui/allure/allure-results/${{ github.run_number }}
       - name: Dump docker logs on failure

+ 43 - 41
.github/workflows/frontend.yaml

@@ -4,10 +4,10 @@ on:
     branches:
       - master
   pull_request_target:
-    types: ['opened', 'edited', 'reopened', 'synchronize']
+    types: ["opened", "edited", "reopened", "synchronize"]
     paths:
-    - 'kafka-ui-contract/**'
-    - 'kafka-ui-react-app/**'
+      - "kafka-ui-contract/**"
+      - "kafka-ui-react-app/**"
 jobs:
   build-and-test:
     env:
@@ -15,41 +15,43 @@ jobs:
       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"
-    - name: Cache node dependency
-      uses: actions/cache@v1
-      with:
-        path: kafka-ui-react-app/node_modules
-        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
-        restore-keys: |
-          ${{ runner.os }}-node-
-    - name: Install Node dependencies
-      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/
-        npm run lint
-    - name: Tests
-      run: |
-        cd kafka-ui-react-app/
-        npm run test:CI
-    - name: SonarCloud Scan
-      uses: workshur/sonarcloud-github-action@improved_basedir
-      with:
-        projectBaseDir: ./kafka-ui-react-app
-      env:
-        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}
+      - uses: actions/checkout@v2
+        with:
+          # Disabling shallow clone is recommended for improving relevancy of reporting
+          fetch-depth: 0
+          ref: ${{ github.event.pull_request.head.sha }}
+      - name: Use Node.js
+        uses: actions/setup-node@v1
+        with:
+          node-version: "14"
+      - name: Cache node dependency
+        uses: actions/cache@v1
+        with:
+          path: kafka-ui-react-app/node_modules
+          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+          restore-keys: |
+            ${{ runner.os }}-node-
+      - name: Install Node dependencies
+        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/
+          npm run lint
+      - name: Tests
+        run: |
+          cd kafka-ui-react-app/
+          npm run test:CI
+      - name: SonarCloud Scan
+        uses: workshur/sonarcloud-github-action@improved_basedir
+        with:
+          projectBaseDir: ./kafka-ui-react-app
+          args: -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.base=${{ github.base_ref }}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}

+ 3 - 3
.github/workflows/pr-checks.yaml

@@ -1,7 +1,7 @@
-name: 'PR Checklist checked'
+name: "PR Checklist checked"
 on:
   pull_request_target:
-    types: [opened, edited, synchronized, reopened]
+    types: [opened, edited, synchronize, reopened]
 
 jobs:
   task-check:
@@ -12,4 +12,4 @@ jobs:
           repo-token: "${{ secrets.GITHUB_TOKEN }}"
       - uses: dekinderfiets/pr-description-enforcer@0.0.1
         with:
-          repo-token: '${{ secrets.GITHUB_TOKEN }}'
+          repo-token: "${{ secrets.GITHUB_TOKEN }}"

+ 1 - 1
kafka-ui-react-app/sonar-project.properties

@@ -1,4 +1,4 @@
-sonar.projectKey=provectus_kafka-ui_frontend
+sonar.projectKey=com.provectus:kafka-ui_frontend
 sonar.organization=provectus
 
 sonar.sources=.