Skip to content

SONARKT-647 Transfer artifact between CI tasks without Repox #609

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
gradle_its_template: &GRADLE_ITS_TEMPLATE
<<: *SETUP_GRADLE_CACHE
<<: *ORCHESTRATOR_CACHE_DEFINITION
download_build_artifact_script:
- mkdir -p sonar-kotlin-plugin/build/libs
- curl --fail -X GET -o sonar-kotlin-plugin/build/libs/sonar-kotlin-plugin.jar http://${CIRRUS_HTTP_CACHE_HOST}/build/${CIRRUS_BUILD_ID}/sonar-kotlin-plugin.jar
run_its_script:
- |
if [ -n "${GIT_SUB_MODULE}" ]; then
Expand Down Expand Up @@ -136,6 +139,8 @@
build_script:
- source cirrus-env BUILD-PRIVATE
- regular_gradle_build_deploy_analyze -x test -x sonar
upload_build_artifact_script:
- curl -X POST --data-binary @sonar-kotlin-plugin/build/libs/sonar-kotlin-plugin.jar http://${CIRRUS_HTTP_CACHE_HOST}/build/${CIRRUS_BUILD_ID}/sonar-kotlin-plugin.jar
on_failure:
error_log_artifacts:
path: "hs_err_pid*.log"
Expand Down Expand Up @@ -225,6 +230,9 @@
<<: *LINUX_6_CPU_12G_JAVA_17
<<: *SETUP_GRADLE_CACHE
<<: *ORCHESTRATOR_CACHE_DEFINITION
download_build_artifact_script:
- mkdir -p sonar-kotlin-plugin/build/libs
- curl --fail -X GET -o sonar-kotlin-plugin/build/libs/sonar-kotlin-plugin.jar http://${CIRRUS_HTTP_CACHE_HOST}/build/${CIRRUS_BUILD_ID}/sonar-kotlin-plugin.jar
run_its_script:
- |
if [ -n "${GIT_SUB_MODULE}" ]; then
Expand All @@ -251,7 +259,7 @@
path: "*.hprof"
<<: *CLEANUP_GRADLE_CACHE_SCRIPT

promote_task:

Check warning on line 262 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L262

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

Check warning on line 262 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L262

task "promote" depends on task "ws_scan", but their only_if conditions are different
depends_on:
- build
- build_test_analyze
Expand Down
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,8 @@ subprojects {

systemProperties = System.getProperties().filterKeys {
it is String &&
(it.startsWith("orchestrator") || it.startsWith("sonar") || it == "buildNumber" || it == "slangVersion")
(it.startsWith("orchestrator") || it.startsWith("sonar") || it == "buildNumber")
}.mapKeys { it.key as String }

if (systemProperties.containsKey("buildNumber") && !systemProperties.containsKey("slangVersion")) {
systemProperties["slangVersion"] = version
}
}

val sourcesJar by tasks.creating(Jar::class) {
Expand Down
26 changes: 1 addition & 25 deletions its/plugin/src/test/java/org/sonarsource/slang/TestsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@
import com.sonar.orchestrator.junit5.OrchestratorExtension;
import com.sonar.orchestrator.junit5.OrchestratorExtensionBuilder;
import com.sonar.orchestrator.locator.FileLocation;
import com.sonar.orchestrator.locator.Location;
import com.sonar.orchestrator.locator.MavenLocation;

import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;


public class TestsHelper {

static final String SQ_VERSION_PROPERTY = "sonar.runtimeVersion";
static final String DEFAULT_SQ_VERSION = "LATEST_RELEASE";

private static final Set<String> LANGUAGES = new HashSet<>(Collections.singletonList("kotlin"));

public static final OrchestratorExtension ORCHESTRATOR;

static {
Expand All @@ -52,21 +42,7 @@ public class TestsHelper {
}

static void addLanguagePlugins(OrchestratorBuilder builder) {
String slangVersion = System.getProperty("slangVersion");

LANGUAGES.forEach(language -> {
Location pluginLocation;
String plugin = "sonar-" + language +"-plugin";
if (slangVersion == null || slangVersion.isEmpty()) {
// use the plugin that was built on local machine
pluginLocation = FileLocation.byWildcardMavenFilename(new File("../../" + plugin + "/build/libs"), plugin + ".jar");
} else {
// QA environment downloads the plugin built by the CI job
pluginLocation = MavenLocation.of("org.sonarsource.kotlin", plugin, slangVersion);
}

builder.addPlugin(pluginLocation);
});
builder.addPlugin(FileLocation.of("../../sonar-kotlin-plugin/build/libs/sonar-kotlin-plugin.jar"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
*/
package org.sonarsource.slang;

import com.sonar.orchestrator.OrchestratorBuilder;
import com.sonar.orchestrator.build.Build;
import com.sonar.orchestrator.build.GradleBuild;
import com.sonar.orchestrator.build.SonarScanner;

import com.sonar.orchestrator.junit5.OrchestratorExtension;
import com.sonar.orchestrator.junit5.OrchestratorExtensionBuilder;
import com.sonar.orchestrator.locator.FileLocation;
import com.sonar.orchestrator.locator.Location;
import com.sonar.orchestrator.locator.MavenLocation;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -66,10 +64,9 @@ public static void setUp() {
.useDefaultAdminCredentialsForBuilds(true)
.setSonarVersion(System.getProperty(SQ_VERSION_PROPERTY, DEFAULT_SQ_VERSION))
.addPlugin(MavenLocation.of("org.sonarsource.sonar-lits-plugin", "sonar-lits-plugin", "0.11.0.2659"))
.addPlugin(FileLocation.of("../../sonar-kotlin-plugin/build/libs/sonar-kotlin-plugin.jar"))
.setServerProperty("sonar.telemetry.enable", "false");

addLanguagePlugins(builder);

orchestrator = builder.build();
orchestrator.start();

Expand All @@ -82,24 +79,6 @@ public static void setUp() {
orchestrator.getServer().restoreProfile(FileLocation.of(kotlinProfile));
}

private static void addLanguagePlugins(OrchestratorBuilder builder) {
String slangVersion = System.getProperty("slangVersion");

LANGUAGES.forEach(language -> {
Location pluginLocation;
String plugin = "sonar-" + language +"-plugin";
if (slangVersion == null || slangVersion.isEmpty()) {
// use the plugin that was built on local machine
pluginLocation = FileLocation.byWildcardMavenFilename(new File("../../" + plugin + "/build/libs"), plugin + ".jar");
} else {
// QA environment downloads the plugin built by the CI job
pluginLocation = MavenLocation.of("org.sonarsource.kotlin", plugin, slangVersion);
}

builder.addPlugin(pluginLocation);
});
}

@Test
@EnabledIfEnvironmentVariable(named = "KOTLIN_COMPILER_IT_ENABLED", matches = "true")
void test_kotlin_compiler() throws IOException {
Expand Down