Skip to content

Commit

Permalink
Use nvme storage for windows jobs (#4303)
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck authored Oct 24, 2023
1 parent cf4713b commit 0370ba5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
50 changes: 43 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-.*")

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions its/plugin/sonarlint-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>sonar-javascript-plugin</artifactId>
<type>sonar-plugin</type>
<overWrite>true</overWrite>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>sonar-javascript-plugin</artifactId>
<classifier>win-x64</classifier>
<type>sonar-plugin</type>
<overWrite>true</overWrite>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>sonar-javascript-plugin</artifactId>
<classifier>linux-x64</classifier>
<type>sonar-plugin</type>
<overWrite>true</overWrite>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>sonar-javascript-plugin</artifactId>
Expand Down
16 changes: 13 additions & 3 deletions its/plugin/sonarlint-tests/src/test/java/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 0370ba5

Please sign in to comment.