Skip to content

Commit c36e028

Browse files
authored
sonarlint-ls: update 3.14.1 -> 3.17.0 and fix test (#390097)
2 parents 74a97c5 + ac8dacb commit c36e028

File tree

2 files changed

+44
-73
lines changed

2 files changed

+44
-73
lines changed

pkgs/by-name/so/sonarlint-ls/package.nix

Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,27 @@
66
jdk17,
77
makeWrapper,
88
writeShellApplication,
9-
runCommand,
10-
sonarlint-ls,
119
curl,
1210
pcre,
1311
common-updater-scripts,
1412
jq,
1513
gnused,
14+
versionCheckHook,
1615
}:
1716

1817
maven.buildMavenPackage rec {
1918
pname = "sonarlint-ls";
20-
version = "3.14.1.75775";
19+
version = "3.17.0.75948";
2120

2221
src = fetchFromGitHub {
2322
owner = "SonarSource";
2423
repo = "sonarlint-language-server";
2524
rev = version;
26-
hash = "sha256-QXBSdXpkhqcvfjihcWwy4oCjTMmbAJRZG1T66sa8T4U=";
25+
hash = "sha256-9ZZPAkfYnHYaPFGo/WfOhUIZ+Aq7SNsVmyXgDwe68gk=";
2726
};
2827

29-
# Replaces unavailable versions with available ones in maven central. Can be
30-
# removed again if
31-
# https://github.com/SonarSource/sonarlint-language-server/pull/427 is
32-
# merged.
33-
patches = [ ./sonar-analyzers-versions.patch ];
34-
3528
mvnJdk = jdk17;
36-
mvnHash = "sha256-SKkOf3f9Ze3Rm6i2uYbFkvSnnEySARvaoiAS1e2kFi0=";
29+
mvnHash = "sha256-tsYkp6Zr9gCgb0l6vQViSB7zcbf6JX+JwO4ZYqeG52c=";
3730

3831
# Disables failing tests which either need network access or are flaky.
3932
mvnParameters = lib.escapeShellArgs [
@@ -56,59 +49,54 @@ maven.buildMavenPackage rec {
5649
5750
makeWrapper ${jre_headless}/bin/java $out/bin/sonarlint-ls \
5851
--add-flags "-jar $out/share/sonarlint-ls.jar" \
59-
--add-flags "-stdio" \
6052
--add-flags "-analyzers $(ls -1 $out/share/plugins | tr '\n' ' ')"
6153
6254
runHook postInstall
6355
'';
6456

6557
nativeBuildInputs = [ makeWrapper ];
6658

67-
passthru = {
68-
tests = {
69-
sonarlint-ls-starts-successfully = runCommand "${pname}-test" { } ''
70-
${sonarlint-ls}/bin/sonarlint-ls > $out
71-
cat $out | grep "SonarLint backend started"
59+
nativeInstallCheckInputs = [ versionCheckHook ];
60+
doInstallCheck = true;
61+
preVersionCheck = "export version=${lib.versions.majorMinor version}";
62+
versionCheckProgramArg = "-V";
63+
64+
passthru.updateScript =
65+
let
66+
pkgFile = builtins.toString ./package.nix;
67+
in
68+
lib.getExe (writeShellApplication {
69+
name = "update-${pname}";
70+
runtimeInputs = [
71+
curl
72+
pcre
73+
common-updater-scripts
74+
jq
75+
gnused
76+
];
77+
text = ''
78+
if [ -z "''${GITHUB_TOKEN:-}" ]; then
79+
echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2
80+
fi
81+
82+
LATEST_TAG=$(curl -H "Accept: application/vnd.github+json" \
83+
''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \
84+
-Lsf https://api.github.com/repos/${src.owner}/${src.repo}/tags | \
85+
jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") |
86+
map(tonumber)) | reverse | .[0].name')
87+
update-source-version ${pname} "$LATEST_TAG"
88+
sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile}
89+
90+
echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..."
91+
nix-build -A ${pname}.fetchedMavenDeps 2> ${pname}-stderr.log || true
92+
93+
NEW_MVN_HASH=$(grep "got:" ${pname}-stderr.log | awk '{print ''$2}')
94+
rm ${pname}-stderr.log
95+
# escaping double quotes looks ugly but is needed for variable substitution
96+
# use # instead of / as separator because the sha256 might contain the / character
97+
sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile}
7298
'';
73-
};
74-
75-
updateScript =
76-
let
77-
pkgFile = builtins.toString ./package.nix;
78-
in
79-
lib.getExe (writeShellApplication {
80-
name = "update-${pname}";
81-
runtimeInputs = [
82-
curl
83-
pcre
84-
common-updater-scripts
85-
jq
86-
gnused
87-
];
88-
text = ''
89-
if [ -z "''${GITHUB_TOKEN:-}" ]; then
90-
echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2
91-
fi
92-
93-
LATEST_TAG=$(curl -H "Accept: application/vnd.github+json" \
94-
''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \
95-
-Lsf https://api.github.com/repos/${src.owner}/${src.repo}/tags | \
96-
jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") |
97-
map(tonumber)) | reverse | .[0].name')
98-
update-source-version ${pname} "$LATEST_TAG"
99-
sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile}
100-
101-
echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..."
102-
nix-build -A ${pname}.fetchedMavenDeps 2> ${pname}-stderr.log || true
103-
104-
NEW_MVN_HASH=$(grep "got:" ${pname}-stderr.log | awk '{print ''$2}')
105-
rm ${pname}-stderr.log
106-
# escaping double quotes looks ugly but is needed for variable substitution
107-
# use # instead of / as separator because the sha256 might contain the / character
108-
sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile}
109-
'';
110-
});
111-
};
99+
});
112100

113101
meta = {
114102
description = "Sonarlint language server";

pkgs/by-name/so/sonarlint-ls/sonar-analyzers-versions.patch

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)