Fix sonar cannot work (#16307)

This commit is contained in:
Wenjun Ruan 2024-07-14 22:52:46 +08:00 committed by GitHub
parent d13abe6b26
commit af83c14298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 53 additions and 31 deletions

View File

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

View File

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

View File

@ -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()
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()
|| processTaskRelation.getPostTaskCode() == taskDefinition.getCode())
.findFirst().get().getProcessDefinitionVersion());
.findFirst()
.ifPresent(processTaskRelation -> {
processTaskLineage.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode());
processTaskLineage
.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion());
});
}
}
return processTaskLineageList;

View File

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