Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONARGO-58 Clean up integration tests to only include Go #30

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
ORG_GRADLE_PROJECT_signingPassword: VAULT[development/kv/data/sign data.passphrase]
ORG_GRADLE_PROJECT_signingKeyId: VAULT[development/kv/data/sign data.key_id]

GIT_SUB_MODULE: ""
GRADLE_USER_HOME: ${CIRRUS_WORKING_DIR}/.gradle

linux_image_template: &LINUX_IMAGE
Expand Down Expand Up @@ -92,10 +91,7 @@
gradle_its_template: &GRADLE_ITS_TEMPLATE
<<: *SETUP_GRADLE_CACHE
run_its_script:
- |
if [ -n "${GIT_SUB_MODULE}" ]; then
git submodule update --init --depth 1 "${GIT_SUB_MODULE}"
fi
- git submodule update --init --depth 1
- source cirrus-env QA
- ./gradlew "${GRADLE_TASK}" "-P${ITS_PROJECT}"
"-Dsonar.runtimeVersion=${SQ_VERSION}"
Expand All @@ -105,7 +101,7 @@
-Pqa --info --stacktrace --console plain --no-daemon --build-cache
<<: *CLEANUP_GRADLE_CACHE_SCRIPT

qa_plugin_task:

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different

Check warning on line 104 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L104

task "qa_plugin" depends on task "build", but their only_if conditions are different
<<: *QA_TASK_FILTER
env:
ITS_PROJECT: "plugin"
Expand All @@ -116,13 +112,12 @@
<<: *LINUX_4_CPU_6G_JAVA_17
<<: *GRADLE_ITS_TEMPLATE

qa_ruling_task:

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different

Check warning on line 115 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L115

task "qa_ruling" depends on task "build", but their only_if conditions are different
<<: *QA_TASK_FILTER
env:
SQ_VERSION: "LATEST_RELEASE"
GRADLE_TASK: ":its:ruling:test"
ITS_PROJECT: "ruling"
GIT_SUB_MODULE: "its/sources"
<<: *LINUX_4_CPU_6G_JAVA_17
<<: *GRADLE_ITS_TEMPLATE

Expand Down Expand Up @@ -155,7 +150,7 @@

### Promote tasks

promote_task:

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 153 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L153

task "promote" depends on task "build", but their only_if conditions are different
depends_on:
- build
- qa_plugin
Expand Down
15 changes: 12 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "its/sources"]
path = its/sources
url = https://github.com/SonarSource/slang-test-sources.git
[submodule "its/sources/traefik"]
path = its/sources/traefik
url = https://github.com/traefik/traefik
[submodule "its/sources/minio"]
path = its/sources/minio
url = https://github.com/minio/minio
[submodule "its/sources/prometheus"]
path = its/sources/prometheus
url = https://github.com/prometheus/prometheus
[submodule "its/sources/kubernetes-client-go"]
path = its/sources/kubernetes-client-go
url = https://github.com/kubernetes/client-go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -39,7 +40,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class SlangRulingTest {
public class GoRulingTest {

private static final String SQ_VERSION_PROPERTY = "sonar.runtimeVersion";
private static final String DEFAULT_SQ_VERSION = "LATEST_RELEASE";
Expand All @@ -64,7 +65,7 @@ public static void setUp() {
goRulesConfiguration.add("S1451", "headerFormat", "^(?i).*copyright");
goRulesConfiguration.add("S1451", "isRegularExpression", "true");

File goProfile = ProfileGenerator.generateProfile(SlangRulingTest.orchestrator.getServer().getUrl(), "go", "go", goRulesConfiguration, Collections.emptySet());
File goProfile = ProfileGenerator.generateProfile(GoRulingTest.orchestrator.getServer().getUrl(), "go", "go", goRulesConfiguration, Collections.emptySet());

orchestrator.getServer().restoreProfile(FileLocation.of(goProfile));
}
Expand All @@ -86,18 +87,16 @@ static void addGoPlugin(OrchestratorBuilder builder) {
}

@Test
// @Ignore because it should only be run manually
@Ignore
@Ignore("This test should only be run manually")
public void go_manual_keep_sonarqube_server_up() throws IOException {
keepSonarqubeRunning = true;
test_go();
}


@Test
public void test_go() throws IOException {
Map<String, String> properties = new HashMap<>();
properties.put("sonar.inclusions", "sources/go/**/*.go, ruling/src/test/resources/sources/go/**/*.go");
properties.put("sonar.inclusions", "sources/**/*.go, ruling/src/test/resources/sources/**/*.go");
properties.put("sonar.exclusions", "**/*generated*.go, **/*.pb.go");
properties.put("sonar.tests", ".");
properties.put("sonar.test.inclusions", "**/*_test.go");
Expand All @@ -109,22 +108,22 @@ private void run_ruling_test(Map<String, String> projectProperties) throws IOExc
properties.put("sonar.slang.converter.validation", "log");
properties.put("sonar.slang.duration.statistics", "true");

String projectKey = "go".replace("/", "-") + "-project";
var projectKey = "go-project";
orchestrator.getServer().provisionProject(projectKey, projectKey);
orchestrator.getServer().associateProjectToQualityProfile(projectKey, "go", "rules");

File actualDirectory = FileLocation.of("build/tmp/actual/" + "go").getFile();
var actualDirectory = new File("build/reports/lits");
actualDirectory.mkdirs();

File litsDifferencesFile = FileLocation.of("build/" + projectKey + "-differences").getFile();
var litsDifferencesFile = new File("build/" + projectKey + "-differences");
SonarScanner build = SonarScanner.create(FileLocation.of("../").getFile())
.setProjectKey(projectKey)
.setProjectName(projectKey)
.setProjectVersion("1")
.setSourceDirs("./")
.setSourceEncoding("utf-8")
.setProperties(properties)
.setProperty("sonar.lits.dump.old", FileLocation.of("src/test/resources/expected/" + "go").getFile().getAbsolutePath())
.setProperty("sonar.lits.dump.old", Path.of("src/test/resources/expected").toAbsolutePath().toString())
.setProperty("sonar.lits.dump.new", actualDirectory.getAbsolutePath())
.setProperty("sonar.lits.differences", litsDifferencesFile.getAbsolutePath())
.setProperty("sonar.cpd.exclusions", "**/*")
Expand Down
5 changes: 5 additions & 0 deletions its/ruling/src/test/resources/expected/go-ParsingError.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
'go-project:ruling/src/test/resources/sources/ParsingError.go':[
0,
],
}
40 changes: 40 additions & 0 deletions its/ruling/src/test/resources/expected/go-S100.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
'go-project:sources/kubernetes-client-go/scale/scheme/appsv1beta1/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/scale/scheme/appsv1beta2/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/scale/scheme/autoscalingv1/conversion.go':[
28,
42,
],
'go-project:sources/kubernetes-client-go/scale/scheme/extensionsv1beta1/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/tools/cache/delta_fifo.go':[
303,
],
'go-project:sources/kubernetes-client-go/tools/cache/fifo.go':[
158,
],
'go-project:sources/kubernetes-client-go/tools/clientcmd/api/v1/conversion.go':[
28,
46,
65,
83,
102,
120,
139,
157,
],
'go-project:sources/kubernetes-client-go/tools/clientcmd/api/v1/defaults.go':[
27,
],
'go-project:sources/prometheus/promql/query_logger.go':[
176,
],
}
Loading
Loading