diff --git a/.cirrus.yml b/.cirrus.yml index 42f9a5aa995..ec7b34d310e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -45,11 +45,30 @@ win_vm_definition: &WINDOWS_VM_DEFINITION image: base-windows-jdk17-v* platform: windows region: eu-central-1 - type: c6i.4xlarge + type: c6id.4xlarge subnet_id: ${CIRRUS_AWS_SUBNET} preemptible: false use_ssd: true +win_ssd_and_clone: + &WIN_SSD_AND_CLONE # copy&paste from https://github.com/SonarSource/sonar-cpp/blob/a8c6f1e45a12393508682a013ac7ee35eb92bece/.cirrus.yml#L45 + prepare_disk_script: + - ps: | + Get-Disk -Number 2 | Initialize-Disk -PassThru | New-Partition -UseMaximumSize -DriveLetter Z + Format-Volume -DriveLetter Z -FileSystem NTFS -Confirm:$false + - echo "CIRRUS_WORKING_DIR=Z:/cirrus-ci-build" >> $CIRRUS_ENV + # we don't clone submodules because they are not needed for the tests + clone_script: | + git config --system core.longpaths true + if [ -z "$CIRRUS_PR" ]; then + git clone --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR + git reset --hard $CIRRUS_CHANGE_IN_REPO + else + git clone https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR + git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR + git reset --hard $CIRRUS_CHANGE_IN_REPO + fi + only_sonarsource_qa: &ONLY_SONARSOURCE_QA only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "dogfood-on-.*") @@ -188,7 +207,7 @@ plugin_qa_sq_dev_task: SONARJS_ARTIFACT: multi MVN_TEST: '-Dtest=!EslintCustomRulesTest,!SonarJsIntegrationTest --projects !org.sonarsource.javascript:eslint-custom-rules-plugin' -# Plugin QA for Windows is splint into 2 parts to make it faster +# Plugin QA for Windows is split into 3 parts to make it faster plugin_qa_win_task: depends_on: - build @@ -198,17 +217,33 @@ plugin_qa_win_task: SONARSOURCE_QA: true SQ_VERSION: LATEST_RELEASE matrix: - # tests must be balanced so that the maximum task runtime is minimized - # this fails if they don't both have tests from its/plugin/tests and its/plugin/sonarlint-tests - - TEST: '!CoverageTest,!TypeScriptAnalysisTest,!EslintBasedRulesTest,!SonarLintTestCodeAnalysisTest,!PRAnalysisTest,!TypeCheckerConfigTest,!VueAnalysisTest' - - TEST: 'CoverageTest,TypeScriptAnalysisTest,EslintBasedRulesTest,SonarLintTestCodeAnalysisTest,PRAnalysisTest,TypeCheckerConfigTest,VueAnalysisTest' + - TEST: '!CoverageTest,!TypeScriptAnalysisTest,!EslintBasedRulesTest,!PRAnalysisTest,!TypeCheckerConfigTest,!VueAnalysisTest' + - TEST: 'CoverageTest,TypeScriptAnalysisTest,EslintBasedRulesTest,PRAnalysisTest,TypeCheckerConfigTest,VueAnalysisTest' + <<: *WIN_SSD_AND_CLONE <<: *MAVEN_CACHE qa_script: - source /c/buildTools-docker/bin/cirrus-env QA - source /c/buildTools-docker/bin/set_maven_build_version $BUILD_NUMBER # building the custom plugin required for the further tests - mvn clean package -f its/plugin/plugins/pom.xml - - mvn -f its/plugin/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} "-Dtest=${TEST}" --projects !org.sonarsource.javascript:eslint-custom-rules-plugin -B -e -V verify surefire-report:report + - mvn -f its/plugin/tests/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} "-Dtest=${TEST}" -B -e -V verify surefire-report:report + cleanup_before_cache_script: cleanup_maven_repository + +# Plugin QA for Windows is split into 3 parts to make it faster +plugin_qa_win_sonarlint_task: + depends_on: + - build + <<: *WINDOWS_VM_DEFINITION + <<: *ONLY_SONARSOURCE_QA + env: + SONARSOURCE_QA: true + SQ_VERSION: LATEST_RELEASE + <<: *WIN_SSD_AND_CLONE + <<: *MAVEN_CACHE + qa_script: + - source /c/buildTools-docker/bin/cirrus-env QA + - source /c/buildTools-docker/bin/set_maven_build_version $BUILD_NUMBER + - mvn -f its/plugin/sonarlint-tests/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} -B -e -V verify surefire-report:report cleanup_before_cache_script: cleanup_maven_repository ruling_task: @@ -247,6 +282,7 @@ promote_task: - plugin_qa_no_node - plugin_qa_sq_dev - plugin_qa_win + - plugin_qa_win_sonarlint - ruling - analyze <<: *ONLY_SONARSOURCE_QA diff --git a/its/plugin/sonarlint-tests/pom.xml b/its/plugin/sonarlint-tests/pom.xml index eca80020e07..12bf4872938 100644 --- a/its/plugin/sonarlint-tests/pom.xml +++ b/its/plugin/sonarlint-tests/pom.xml @@ -85,6 +85,26 @@ + + ${project.groupId} + sonar-javascript-plugin + sonar-plugin + true + + + ${project.groupId} + sonar-javascript-plugin + win-x64 + sonar-plugin + true + + + ${project.groupId} + sonar-javascript-plugin + linux-x64 + sonar-plugin + true + ${project.groupId} sonar-javascript-plugin diff --git a/its/plugin/sonarlint-tests/src/test/java/TestUtils.java b/its/plugin/sonarlint-tests/src/test/java/TestUtils.java index 5a86e1ffae8..5e8d58f919a 100644 --- a/its/plugin/sonarlint-tests/src/test/java/TestUtils.java +++ b/its/plugin/sonarlint-tests/src/test/java/TestUtils.java @@ -18,15 +18,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import static java.util.Objects.requireNonNull; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; import java.net.URI; +import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import java.util.regex.Pattern; import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; @@ -39,12 +43,14 @@ public class TestUtils { * */ private static Path artifact() { - var target = homeDir().resolve("../sonar-plugin/sonar-javascript-plugin/target"); + var target = homeDir() + .resolve("../../../../../../sonar-plugin/sonar-javascript-plugin/target") + .normalize(); try (var stream = Files.walk(target, 1)) { return stream .filter(p -> pluginFilenameMatcher().matcher(p.getFileName().toString()).matches()) .findAny() - .orElseThrow(); + .orElseThrow(() -> new IllegalStateException("Cannot find plugin artifact in " + target)); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -57,7 +63,11 @@ private static Pattern pluginFilenameMatcher() { } public static Path homeDir() { - return Path.of("../../"); + try { + return Path.of(requireNonNull(TestUtils.class.getResource("TestUtils.txt")).toURI()); + } catch (URISyntaxException e) { + throw new IllegalStateException(e); + } } public static Path projectDir(String projectName) { diff --git a/its/plugin/sonarlint-tests/src/test/resources/TestUtils.txt b/its/plugin/sonarlint-tests/src/test/resources/TestUtils.txt new file mode 100644 index 00000000000..1a8c1482bb1 --- /dev/null +++ b/its/plugin/sonarlint-tests/src/test/resources/TestUtils.txt @@ -0,0 +1 @@ +This file is used to locate the directory of the project in tests, so we can find relative path to the plugin jar file.