Browse Source

Fix sonar cannot work (#16307)

dev
Wenjun Ruan 4 months ago committed by GitHub
parent
commit
af83c14298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 30
      .github/workflows/unit-test.yml
  2. 31
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/TaskTypeUtilsTest.java
  3. 20
      dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/lineage/MigrateLineageService.java
  4. 3
      pom.xml

30
.github/workflows/unit-test.yml

@ -26,6 +26,7 @@ on:
branches: branches:
- '[0-9]+.[0-9]+.[0-9]+-prepare' - '[0-9]+.[0-9]+.[0-9]+-prepare'
- '[0-9]+.[0-9]+.[0-9]+-release' - '[0-9]+.[0-9]+.[0-9]+-release'
- 'dev'
env: env:
LOG_DIR: /tmp/dolphinscheduler LOG_DIR: /tmp/dolphinscheduler
@ -79,26 +80,14 @@ jobs:
run: ./mvnw clean verify -B -Dmaven.test.skip=false -Dspotless.skip=true -DskipUT=false run: ./mvnw clean verify -B -Dmaven.test.skip=false -Dspotless.skip=true -DskipUT=false
- name: Upload coverage report to codecov - name: Upload coverage report to codecov
run: CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash) 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. # Set up JDK 17 for SonarCloud.
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
java-version: 17 java-version: 17
distribution: 'adopt' distribution: 'adopt'
# Sonar check need to run after jacoco report generated.
- name: Run SonarCloud Analysis - name: Run SonarCloud Analysis
run: > run: >
./mvnw --batch-mode verify sonar:sonar ./mvnw --batch-mode verify sonar:sonar
@ -109,18 +98,21 @@ jobs:
-Dsonar.organization=apache -Dsonar.organization=apache
-Dsonar.core.codeCoveragePlugin=jacoco -Dsonar.core.codeCoveragePlugin=jacoco
-Dsonar.projectKey=apache-dolphinscheduler -Dsonar.projectKey=apache-dolphinscheduler
-Dsonar.exclusions=,dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/* -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682
-Dsonar.token=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 -Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
-DskipUT=true -DskipUT=true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
result: result:
name: Unit Test name: Unit Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30 timeout-minutes: 30
needs: [ unit-test, paths-filter, sonarcloud-analysis ] needs: [ unit-test, paths-filter ]
if: always() if: always()
steps: steps:
- name: Status - name: Status
@ -129,7 +121,7 @@ jobs:
echo "Skip Unit Test!" echo "Skip Unit Test!"
exit 0 exit 0
fi fi
if [[ ${{ needs.unit-test.result }} != 'success' || ${{ needs.sonarcloud-analysis.result }} != 'success' ]]; then if [[ ${{ needs.unit-test.result }} != 'success' ]]; then
echo "Unit Test Failed!" echo "Unit Test Failed!"
exit -1 exit -1
fi fi

31
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();
}
}

20
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.ProcessTaskLineage;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; 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.ProcessTaskRelationMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.dao.repository.ProcessTaskLineageDao; 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 org.apache.commons.collections.CollectionUtils;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -54,9 +52,6 @@ public class MigrateLineageService {
@Autowired @Autowired
private ProcessTaskRelationMapper processTaskRelationMapper; private ProcessTaskRelationMapper processTaskRelationMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
public void migrateLineageOnce() { public void migrateLineageOnce() {
try { try {
List<ProcessTaskLineage> processTaskLineageList = getAllProcessLineages(); List<ProcessTaskLineage> processTaskLineageList = getAllProcessLineages();
@ -71,7 +66,7 @@ public class MigrateLineageService {
} }
} }
private List<ProcessTaskLineage> getAllProcessLineages() throws SQLException { private List<ProcessTaskLineage> getAllProcessLineages() {
List<TaskDefinition> taskDefinitionList = List<TaskDefinition> taskDefinitionList =
taskDefinitionMapper.queryDefinitionsByTaskType(DependentLogicTaskChannelFactory.NAME); taskDefinitionMapper.queryDefinitionsByTaskType(DependentLogicTaskChannelFactory.NAME);
List<ProcessTaskRelation> processTaskRelationList = List<ProcessTaskRelation> processTaskRelationList =
@ -83,14 +78,15 @@ public class MigrateLineageService {
parseDependentTaskParams(taskDefinition, processTaskLineageList); parseDependentTaskParams(taskDefinition, processTaskLineageList);
for (ProcessTaskLineage processTaskLineage : processTaskLineageList) { for (ProcessTaskLineage processTaskLineage : processTaskLineageList) {
processTaskLineage.setProcessDefinitionCode(processTaskRelationList.stream() processTaskRelationList.stream()
.filter(processTaskRelation -> processTaskRelation.getPreTaskCode() == taskDefinition.getCode()
|| processTaskRelation.getPostTaskCode() == taskDefinition.getCode())
.findFirst().get().getProcessDefinitionCode());
processTaskLineage.setProcessDefinitionVersion(processTaskRelationList.stream()
.filter(processTaskRelation -> processTaskRelation.getPreTaskCode() == taskDefinition.getCode() .filter(processTaskRelation -> processTaskRelation.getPreTaskCode() == taskDefinition.getCode()
|| processTaskRelation.getPostTaskCode() == taskDefinition.getCode()) || processTaskRelation.getPostTaskCode() == taskDefinition.getCode())
.findFirst().get().getProcessDefinitionVersion()); .findFirst()
.ifPresent(processTaskRelation -> {
processTaskLineage.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode());
processTaskLineage
.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion());
});
} }
} }
return processTaskLineageList; return processTaskLineageList;

3
pom.xml

@ -643,6 +643,9 @@
<goals> <goals>
<goal>restore-instrumented-classes</goal> <goal>restore-instrumented-classes</goal>
</goals> </goals>
<configuration>
<excludes>com/github/dreamhead/moco/*</excludes>
</configuration>
</execution> </execution>
<execution> <execution>
<id>default-report</id> <id>default-report</id>

Loading…
Cancel
Save