This is an automated email from the ASF dual-hosted git repository.

caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new af83c14298 Fix sonar cannot work (#16307)
af83c14298 is described below

commit af83c142988d872b6c0756352205bd827ca8ee85
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sun Jul 14 22:52:46 2024 +0800

    Fix sonar cannot work (#16307)
---
 .github/workflows/unit-test.yml                    | 30 ++++++++-------------
 .../plugin/task/api/utils/TaskTypeUtilsTest.java   | 31 ++++++++++++++++++++++
 .../tools/lineage/MigrateLineageService.java       | 20 ++++++--------
 pom.xml                                            |  3 +++
 4 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 24bfdabe02..175fbdd83a 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -26,6 +26,7 @@ on:
     branches:
       - '[0-9]+.[0-9]+.[0-9]+-prepare'
       - '[0-9]+.[0-9]+.[0-9]+-release'
+      - 'dev'
 
 env:
   LOG_DIR: /tmp/dolphinscheduler
@@ -79,26 +80,14 @@ jobs:
         run: ./mvnw clean verify -B -Dmaven.test.skip=false 
-Dspotless.skip=true -DskipUT=false
       - name: Upload coverage report to codecov
         run: CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl 
-s https://codecov.io/bash)
-  sonarcloud-analysis:
-    name: SonarCloud-Analysis
-    needs: paths-filter
-    runs-on: ubuntu-latest
-    timeout-minutes: 30
-    steps:
-      - uses: actions/checkout@v4
-        with:
-          submodules: true
-      - uses: actions/cache@v4
-        with:
-          path: ~/.m2/repository
-          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-unit-test
-          restore-keys: ${{ runner.os }}-maven-
+
       # Set up JDK 17 for SonarCloud.
       - name: Set up JDK 17
         uses: actions/setup-java@v4
         with:
           java-version: 17
           distribution: 'adopt'
+      # Sonar check need to run after jacoco report generated.
       - name: Run SonarCloud Analysis
         run: >
           ./mvnw --batch-mode verify sonar:sonar
@@ -109,18 +98,21 @@ jobs:
           -Dsonar.organization=apache
           -Dsonar.core.codeCoveragePlugin=jacoco
           -Dsonar.projectKey=apache-dolphinscheduler
-          
-Dsonar.exclusions=,dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/*
-          -Dsonar.token=e4058004bc6be89decf558ac819aa1ecbee57682
-          -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false 
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
+          -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682
+          
-Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/*
+          -Dhttp.keepAlive=false 
+          -Dmaven.wagon.http.pool=false 
+          -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
           -DskipUT=true
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+
   result:
     name: Unit Test
     runs-on: ubuntu-latest
     timeout-minutes: 30
-    needs: [ unit-test, paths-filter, sonarcloud-analysis ]
+    needs: [ unit-test, paths-filter ]
     if: always()
     steps:
       - name: Status
@@ -129,7 +121,7 @@ jobs:
             echo "Skip Unit Test!"
             exit 0
           fi
-          if [[ ${{ needs.unit-test.result }} != 'success' || ${{ 
needs.sonarcloud-analysis.result }} != 'success' ]]; then
+          if [[ ${{ needs.unit-test.result }} != 'success' ]]; then
             echo "Unit Test Failed!"
             exit -1
           fi
diff --git 
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/TaskTypeUtilsTest.java
 
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/TaskTypeUtilsTest.java
new file mode 100644
index 0000000000..a566c081a5
--- /dev/null
+++ 
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/TaskTypeUtilsTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.api.utils;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class TaskTypeUtilsTest {
+
+    @Test
+    void isSwitchTask() {
+        assertThat(TaskTypeUtils.isSwitchTask("SWITCH")).isTrue();
+    }
+
+}
diff --git 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/lineage/MigrateLineageService.java
 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/lineage/MigrateLineageService.java
index 8fdad845f4..1a2b2bf518 100644
--- 
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/lineage/MigrateLineageService.java
+++ 
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/lineage/MigrateLineageService.java
@@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.dao.entity.ProcessTaskLineage;
 import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
 import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
-import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
 import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
 import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
 import org.apache.dolphinscheduler.dao.repository.ProcessTaskLineageDao;
@@ -32,7 +31,6 @@ import 
org.apache.dolphinscheduler.plugin.task.api.task.DependentLogicTaskChanne
 
 import org.apache.commons.collections.CollectionUtils;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -54,9 +52,6 @@ public class MigrateLineageService {
     @Autowired
     private ProcessTaskRelationMapper processTaskRelationMapper;
 
-    @Autowired
-    private ProcessDefinitionMapper processDefinitionMapper;
-
     public void migrateLineageOnce() {
         try {
             List<ProcessTaskLineage> processTaskLineageList = 
getAllProcessLineages();
@@ -71,7 +66,7 @@ public class MigrateLineageService {
         }
     }
 
-    private List<ProcessTaskLineage> getAllProcessLineages() throws 
SQLException {
+    private List<ProcessTaskLineage> getAllProcessLineages() {
         List<TaskDefinition> taskDefinitionList =
                 
taskDefinitionMapper.queryDefinitionsByTaskType(DependentLogicTaskChannelFactory.NAME);
         List<ProcessTaskRelation> processTaskRelationList =
@@ -83,14 +78,15 @@ public class MigrateLineageService {
             parseDependentTaskParams(taskDefinition, processTaskLineageList);
 
             for (ProcessTaskLineage processTaskLineage : 
processTaskLineageList) {
-                
processTaskLineage.setProcessDefinitionCode(processTaskRelationList.stream()
-                        .filter(processTaskRelation -> 
processTaskRelation.getPreTaskCode() == taskDefinition.getCode()
-                                || processTaskRelation.getPostTaskCode() == 
taskDefinition.getCode())
-                        .findFirst().get().getProcessDefinitionCode());
-                
processTaskLineage.setProcessDefinitionVersion(processTaskRelationList.stream()
+                processTaskRelationList.stream()
                         .filter(processTaskRelation -> 
processTaskRelation.getPreTaskCode() == taskDefinition.getCode()
                                 || processTaskRelation.getPostTaskCode() == 
taskDefinition.getCode())
-                        .findFirst().get().getProcessDefinitionVersion());
+                        .findFirst()
+                        .ifPresent(processTaskRelation -> {
+                            
processTaskLineage.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode());
+                            processTaskLineage
+                                    
.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion());
+                        });
             }
         }
         return processTaskLineageList;
diff --git a/pom.xml b/pom.xml
index 7f7bfdda76..9c31972d1b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -643,6 +643,9 @@
                         <goals>
                             <goal>restore-instrumented-classes</goal>
                         </goals>
+                        <configuration>
+                            <excludes>com/github/dreamhead/moco/*</excludes>
+                        </configuration>
                     </execution>
                     <execution>
                         <id>default-report</id>

Reply via email to