Skip to content

Commit

Permalink
Move sonar scan to JDK-17
Browse files Browse the repository at this point in the history
  • Loading branch information
marmyshev committed Mar 4, 2024
1 parent 1d3e0b5 commit f6e6ba5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-latest-
- name: Build with Maven
working-directory: ./
run: |
Xvfb :5 -screen 0 1280x1024x8 -fbdir /tmp &
export DISPLAY=:5
mvn clean verify -PSDK,find-bugs -Dtycho.localArtifacts=ignore -B -V
- name: Cache SonarCloud packages
uses: actions/cache@v2
if: inputs.analyze
Expand All @@ -59,19 +66,22 @@ jobs:
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build with Maven
- name: Set up JDK 17
if: inputs.analyze
uses: actions/setup-java@v1
with:
java-version: 17
java-package: jdk

- name: Sonar scan
# Do not start Sonar-scanning for forks without label, and pass fork PR number directly
if: inputs.analyze
env:
# Do not start Sonar-scanning for forks without label, and pass fork PR number directly
SONAR_PARAM: "${{ inputs.analyze && format('{0}{1}', 'org.sonarsource.scanner.maven:sonar-maven-plugin:sonar', env.PR_NUMBER) || '' }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.sonar_token }}
working-directory: ./
run: |
Xvfb :5 -screen 0 1280x1024x8 -fbdir /tmp &
export DISPLAY=:5
echo "Sonar param: \"${SONAR_PARAM}\""
mvn clean verify ${SONAR_PARAM} -PSDK,find-bugs -Dtycho.localArtifacts=ignore -B -V
run: mvn compile org.sonarsource.scanner.maven:sonar-maven-plugin:sonar ${{ env.PR_NUMBER }} -Dtycho.localArtifacts=ignore -B -V

- name: Publish Test Report
uses: scacap/action-surefire-report@v1
if: inputs.analyze
Expand All @@ -96,7 +106,6 @@ jobs:
with:
name: jacoco
path: |
./**/target/jacoco.exec
./**/target/site/jacoco*/
- name: Upload test logs on failure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Build
# This build will run on master,release/* push, local PR and PR from forks without label Analyze
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name || !contains(github.event.pull_request.labels.*.name, 'Analyze')
uses: 1C-company/v8-code-style/.github/workflows/build.yml@master
uses: 1C-company/v8-code-style/.github/workflows/build.yml@${{ github.ref_name }}
with:
analyze: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name }}
secrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,30 @@ public final class CommonModuleNameClient
private static final String NAME_SUFFIX_DEFAULT = "Клиент,Client"; //$NON-NLS-1$

@Override
public String getCheckId()
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
return CHECK_ID;
CommonModule common2Module = (CommonModule)object;
if (common2Module.getReturnValuesReuse() != ReturnValuesReuse.DONT_USE)
{
return;
}

Map<EStructuralFeature, Object> values = new HashMap<>();
for (EStructuralFeature feature : CommonModuleTypes.CLIENT.getFeatureValues(false).keySet())
{
values.put(feature, common2Module.eGet(feature));
}

if (values.equals(CommonModuleTypes.CLIENT.getFeatureValues(false)))
{
String message2 = MessageFormat.format(Messages.CommonModuleNameClient_message,
parameters.getString(MdObjectNameWithoutSuffix.NAME_SUFFIX_PARAMETER_NAME));
resultAceptor.addIssue(message2, MD_OBJECT__NAME);
}
}


@Override
protected void configureCheck(CheckConfigurer builder)
{
Expand Down Expand Up @@ -91,27 +110,11 @@ protected void configureCheck(CheckConfigurer builder)
//@formatter:on
}


@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
public String getCheckId()
{
CommonModule commonModule = (CommonModule)object;
if (commonModule.getReturnValuesReuse() != ReturnValuesReuse.DONT_USE)
{
return;
}

Map<EStructuralFeature, Object> values = new HashMap<>();
for (EStructuralFeature feature : CommonModuleTypes.CLIENT.getFeatureValues(false).keySet())
{
values.put(feature, commonModule.eGet(feature));
}

if (values.equals(CommonModuleTypes.CLIENT.getFeatureValues(false)))
{
String message = MessageFormat.format(Messages.CommonModuleNameClient_message,
parameters.getString(MdObjectNameWithoutSuffix.NAME_SUFFIX_PARAMETER_NAME));
resultAceptor.addIssue(message, MD_OBJECT__NAME);
}
return CHECK_ID;
}

}

0 comments on commit f6e6ba5

Please sign in to comment.