Skip to content

Commit d6e7ecf

Browse files
author
Dennis Labordus
authored
Merge pull request #105 from com-pas/develop
New release
2 parents f15abbb + 4cc27f7 commit d6e7ecf

File tree

13 files changed

+219
-83
lines changed

13 files changed

+219
-83
lines changed

.github/workflows/automate-projects.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,17 @@ jobs:
1212

1313
if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
1414
steps:
15-
- name: add-new-issues-to-repository-based-project-column
16-
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
17-
if: github.event_name == 'issues' && github.event.action == 'opened'
18-
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20-
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-validator/projects/1
21-
GITHUB_PROJECT_COLUMN_NAME: To do
22-
- name: add-new-pull-request-to-repository-based-project-column
23-
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
24-
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
25-
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-validator/projects/1
28-
GITHUB_PROJECT_COLUMN_NAME: To do
2915
- name: add-new-issues-to-organization-based-project-column
30-
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
3116
if: github.event_name == 'issues' && github.event.action == 'opened'
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
34-
GITHUB_PROJECT_URL: https://github.com/orgs/com-pas/projects/1
35-
GITHUB_PROJECT_COLUMN_NAME: To do
17+
uses: alex-page/[email protected]
18+
with:
19+
project: CoMPAS Issues Overview Board
20+
column: To do
21+
repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
3622
- name: add-new-pull-request-to-organization-based-project-column
37-
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
3823
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
41-
GITHUB_PROJECT_URL: https://github.com/orgs/com-pas/projects/2
42-
GITHUB_PROJECT_COLUMN_NAME: To do
24+
uses: alex-page/[email protected]
25+
with:
26+
project: CoMPAS Pull Request Overview Board
27+
column: To do
28+
repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}

.github/workflows/build-project.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ jobs:
2424
uses: actions/checkout@v3
2525
with:
2626
submodules: 'true'
27-
- name: Set up Docker Buildx
28-
id: buildx
29-
uses: docker/setup-buildx-action@v2
27+
3028
- name: Cache Docker Register
3129
uses: actions/cache@v3
3230
with:
@@ -39,6 +37,9 @@ jobs:
3937
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
4038
restore-keys: ${{ runner.os }}-m2
4139

40+
- name: Set up Docker Buildx
41+
id: buildx
42+
uses: docker/setup-buildx-action@v2
4243
- name: Set up JDK 17
4344
uses: actions/setup-java@v3
4445
with:

.github/workflows/release-project.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ jobs:
1919
uses: actions/checkout@v3
2020
with:
2121
submodules: 'true'
22-
- name: Set up Docker Buildx
23-
id: buildx
24-
uses: docker/setup-buildx-action@v2
25-
- name: Login to Docker Hub
26-
uses: docker/login-action@v2
27-
with:
28-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
29-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
22+
3023
- name: Cache Docker Register
3124
uses: actions/cache@v3
3225
with:
@@ -42,13 +35,22 @@ jobs:
4235
- name: Extract tag name
4336
id: extract_tagname
4437
shell: bash
45-
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
38+
# Extract the tag name from the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
4639
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
40+
4741
- name: Set up JDK 17
4842
uses: actions/setup-java@v3
4943
with:
5044
distribution: 'zulu'
5145
java-version: '17'
46+
- name: Set up Docker Buildx
47+
id: buildx
48+
uses: docker/setup-buildx-action@v2
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v2
51+
with:
52+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
53+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
5254

5355
- name: Create custom Maven Settings.xml
5456
uses: whelk-io/maven-settings-xml-action@v20

.github/workflows/sonarcloud-analysis.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
fetch-depth: 0
3232
submodules: 'true'
3333

34-
- name: Set up JDK 17
35-
uses: actions/setup-java@v3
36-
with:
37-
distribution: 'zulu'
38-
java-version: '17'
3934
- name: Cache SonarCloud packages
4035
uses: actions/cache@v3
4136
with:
@@ -49,20 +44,43 @@ jobs:
4944
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
5045
restore-keys: ${{ runner.os }}-m2
5146

47+
- name: Set up JDK 17
48+
uses: actions/setup-java@v3
49+
with:
50+
distribution: 'zulu'
51+
java-version: '17'
52+
53+
- name: Set Common Sonar Variables
54+
id: sonar_env
55+
run: |
56+
echo "##[set-output name=sonar_opts;]$(echo -Dsonar.host.url=https://sonarcloud.io \
57+
-Dsonar.projectKey=com-pas_compas-scl-validator \
58+
-Dsonar.organization=com-pas )"
5259
- name: Create custom Maven Settings.xml
5360
uses: whelk-io/maven-settings-xml-action@v20
5461
with:
5562
output_file: custom_maven_settings.xml
5663
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
57-
- name: Build and analyze
64+
- name: Build and analyze (Pull Request)
65+
if: ${{ github.event_name == 'pull_request' || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
69+
run: |
70+
./mvnw -B -s custom_maven_settings.xml -Psonar \
71+
${{ steps.sonar_env.outputs.sonar_opts }} \
72+
-Dsonar.pullrequest.branch=${{ github.ref_name }} \
73+
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
74+
-Dsonar.pullrequest.base=${{ github.base_ref }} \
75+
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} \
76+
clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
77+
- name: Build and analyze (Push)
78+
if: ${{ github.event_name == 'push' }}
5879
env:
59-
GITHUB_USERNAME: "OWNER"
6080
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6181
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6282
run: |
63-
./mvnw -s custom_maven_settings.xml -B -Psonar \
64-
-Dsonar.projectKey=com-pas_compas-scl-validator \
65-
-Dsonar.organization=com-pas \
66-
-Dsonar.host.url=https://sonarcloud.io \
67-
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
68-
clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
83+
./mvnw -B -s custom_maven_settings.xml -Psonar \
84+
${{ steps.sonar_env.outputs.sonar_opts }} \
85+
-Dsonar.branch.name=${{ github.ref_name }} \
86+
clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/websocket/SclValidateResponseEncoderTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,26 @@ void init() {
2828
@Test
2929
void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
3030
var validationMessage = "Some Validation Message";
31+
var ruleName = "Rule Name 1";
32+
var linenumber = 15;
33+
3134
var request = new SclValidateResponse();
3235
request.setValidationErrorList(new ArrayList<>());
3336
var validationError = new ValidationError();
3437
validationError.setMessage(validationMessage);
38+
validationError.setRuleName(ruleName);
39+
validationError.setLinenumber(linenumber);
3540
request.getValidationErrorList().add(validationError);
3641

3742
var result = encoder.encode(request);
3843

3944
var expectedResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
4045
"<svs:SclValidateResponse xmlns:svs=\"" + SCL_VALIDATOR_SERVICE_V1_NS_URI + "\">" +
41-
"<svs:ValidationErrors><svs:Message>" + validationMessage + "</svs:Message></svs:ValidationErrors>" +
46+
"<svs:ValidationErrors>" +
47+
"<svs:Message>" + validationMessage + "</svs:Message>" +
48+
"<svs:RuleName>" + ruleName + "</svs:RuleName>" +
49+
"<svs:Linenumber>" + linenumber + "</svs:Linenumber>" +
50+
"</svs:ValidationErrors>" +
4251
"</svs:SclValidateResponse>";
4352
assertNotNull(result);
4453
assertEquals(expectedResult, result);

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SPDX-License-Identifier: Apache-2.0
2727
<compas.core.version>0.9.1</compas.core.version>
2828

2929
<quarkus.platform.version>2.10.3.Final</quarkus.platform.version>
30-
<slf4j.version>1.7.36</slf4j.version>
30+
<slf4j.version>2.0.0</slf4j.version>
3131
<openpojo.version>0.9.1</openpojo.version>
3232
</properties>
3333

@@ -265,7 +265,7 @@ SPDX-License-Identifier: Apache-2.0
265265
<plugin>
266266
<groupId>org.apache.maven.plugins</groupId>
267267
<artifactId>maven-javadoc-plugin</artifactId>
268-
<version>3.4.0</version>
268+
<version>3.4.1</version>
269269
<executions>
270270
<execution>
271271
<id>attach-javadocs</id>

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/collector/AbstractFileCollector.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.Collections;
1616
import java.util.List;
1717
import java.util.function.Predicate;
18-
import java.util.stream.Collectors;
1918

2019
import static org.lfenergy.compas.scl.validator.exception.SclValidatorErrorCode.LOADING_CUSTOM_OCL_FILES_FAILED;
2120
import static org.lfenergy.compas.scl.validator.exception.SclValidatorErrorCode.LOADING_OCL_FILES_FAILED;
@@ -54,7 +53,7 @@ protected List<URI> getDefaultOclFilesFromClasspath() {
5453
try (var walk = Files.walk(oclDirectoryPath)) {
5554
return walk.filter(filter)
5655
.map(path -> URI.createURI(path.toUri().toString()))
57-
.collect(Collectors.toList());
56+
.toList();
5857
}
5958
}
6059
} else {
@@ -64,7 +63,7 @@ protected List<URI> getDefaultOclFilesFromClasspath() {
6463
.map(Path::toFile)
6564
.filter(File::isFile)
6665
.map(file -> URI.createFileURI(file.getAbsolutePath()))
67-
.collect(Collectors.toList());
66+
.toList();
6867
}
6968
}
7069
} else {
@@ -93,7 +92,7 @@ protected List<URI> getFilesFromDirectory(String directoryName, Predicate<Path>
9392
.map(Path::toFile)
9493
.filter(File::isFile)
9594
.map(file -> URI.createFileURI(file.getAbsolutePath()))
96-
.collect(Collectors.toList());
95+
.toList();
9796
}
9897
}
9998
return Collections.emptyList();

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/SclRiseClipseValidator.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.ArrayList;
2626
import java.util.List;
2727

28-
import static org.lfenergy.compas.scl.validator.util.MessageUtil.cleanupMessage;
28+
import static org.lfenergy.compas.scl.validator.util.MessageUtil.createValidationError;
2929

3030
public class SclRiseClipseValidator implements SclValidator {
3131
private static final Logger LOGGER = LoggerFactory.getLogger(SclRiseClipseValidator.class);
@@ -77,12 +77,16 @@ public List<ValidationError> validate(SclFileType type, String sclData) {
7777
private void processDiagnostic(Diagnostic diagnostic, List<ValidationError> validationErrors) {
7878
// If there are children in the diagnostic there are validation errors to be processed.
7979
for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
80-
var validationError = new ValidationError();
81-
validationErrors.add(validationError);
82-
83-
String message = cleanupMessage(childDiagnostic.getMessage());
84-
validationError.setMessage(message);
85-
LOGGER.debug("SCL Validation Error '{}'", message);
80+
var validationError = createValidationError(childDiagnostic.getMessage());
81+
if (validationError.isPresent()) {
82+
validationErrors.add(validationError.get());
83+
if (LOGGER.isDebugEnabled()) {
84+
LOGGER.debug("SCL Validation Error '{}' from Rule '{}' (Linenumber {})",
85+
validationError.get().getMessage(),
86+
validationError.get().getRuleName(),
87+
validationError.get().getLinenumber());
88+
}
89+
}
8690

8791
// Also process the children of the children.
8892
processDiagnostic(childDiagnostic, validationErrors);

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/util/MessageUtil.java

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,46 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.validator.util;
55

6+
import org.lfenergy.compas.scl.validator.model.ValidationError;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
import java.util.Optional;
11+
612
public class MessageUtil {
13+
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
14+
715
MessageUtil() {
816
throw new UnsupportedOperationException("MessageUtil class");
917
}
1018

11-
public static String cleanupMessage(String message) {
12-
String cleanedMessage = message;
13-
if (cleanedMessage != null
14-
&& cleanedMessage.toUpperCase().startsWith("ERROR;")) {
15-
cleanedMessage = cleanedMessage.substring(6);
19+
public static Optional<ValidationError> createValidationError(String message) {
20+
if (message == null || message.isBlank()) {
21+
return Optional.empty();
1622
}
17-
return cleanedMessage;
23+
24+
var validationError = new ValidationError();
25+
var messageParts = message.split(";");
26+
if (messageParts.length == 5) {
27+
// The expected number of parts is found, the message and rule are set as-is, the linenumber is converted
28+
// to a Long value,
29+
validationError.setRuleName(messageParts[1]);
30+
validationError.setMessage(messageParts[4]);
31+
32+
try {
33+
validationError.setLinenumber(Long.parseLong(messageParts[3]));
34+
} catch (NumberFormatException exp) {
35+
validationError.setLinenumber(-1);
36+
LOGGER.debug("Invalid linenumber '{}' found", messageParts[3], exp);
37+
}
38+
} else if (messageParts.length == 2) {
39+
// It seems like an old message that starts with 'ERROR;', so only set the second part as Message
40+
validationError.setMessage(messageParts[1]);
41+
} else {
42+
// If we can split it correctly, just put the message as-is to the response.
43+
validationError.setMessage(message);
44+
}
45+
46+
return Optional.of(validationError);
1847
}
1948
}

riseclipse/validator-riseclipse/src/test/java/org/lfenergy/compas/scl/validator/impl/SclRiseClipseValidatorTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ void validate_WhenCalled_ThenExpectedValidationErrorsReturned() throws IOExcepti
3232

3333
assertNotNull(result);
3434
assertEquals(15, result.size());
35+
36+
// Check if parsing of the message is still working.
37+
var firstMessage = result.get(0);
38+
assertNotNull(firstMessage.getRuleName());
39+
assertNotNull(firstMessage.getMessage());
40+
assertTrue(firstMessage.getLinenumber() > 0);
3541
}
3642
}

0 commit comments

Comments
 (0)