Browse Source

Fix sonar cannot work (#16307)

dev
Wenjun Ruan 6 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:
- '[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

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.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;

3
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>

Loading…
Cancel
Save