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

VSTS-298 fix version comparison #247

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions commonv5/ts/__tests__/prepare-task-test.ts
Expand Up @@ -36,6 +36,31 @@ it("should display warning for dedicated extension for Sonarcloud", async () =>
);
});

describe("branchFeatureSupported", () => {
it.each([
[new Endpoint(EndpointType.SonarCloud, { url: "https://sonarcloud.io" }), "SC", "1.2.3", true],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "7.1.0", false],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "9.9.0", true],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "10.0.0", true],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "10.1.0", true],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "11.0.0", true],
[new Endpoint(EndpointType.SonarQube, { url: "https://localhost" }), "SQ", "12.0.0", true],
])(
"branch feature is supported for %p %p %p",
async (
endpoint: Endpoint,
product: string,
version: string,
expectedBranchSupported: Boolean
) => {
tl.debug(`${product} ${version}`);
jest.spyOn(request, "getServerVersion").mockResolvedValue(new SemVer(version));
const actual = await prept.branchFeatureSupported(endpoint);
expect(actual).toBe(expectedBranchSupported);
}
);
});

it("should build report task path from variables", () => {
const reportDirectory = path.join("C:", "temp", "dir");
const sonarSubDirectory = "sonar";
Expand Down
4 changes: 2 additions & 2 deletions commonv5/ts/prepare-task.ts
Expand Up @@ -57,12 +57,12 @@ export default async function prepareTask(endpoint: Endpoint, rootPath: string)
await scanner.runPrepare();
}

async function branchFeatureSupported(endpoint) {
export async function branchFeatureSupported(endpoint) {
if (endpoint.type === EndpointType.SonarCloud) {
return true;
}
const serverVersion = await getServerVersion(endpoint);
return serverVersion >= semver.parse("7.2.0");
return semver.satisfies(serverVersion, ">=7.2.0");
}

export async function populateBranchAndPrProps(props: { [key: string]: string }) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/sonarqube/tasks/prepare/v5/task.json
Expand Up @@ -12,7 +12,7 @@
"version": {
"Major": 5,
"Minor": 11,
"Patch": 0
"Patch": 1
},
"releaseNotes": "* __Support non MSBuild projects:__ This task can be used to configure analysis also for non MSBuild projects.",
"minimumAgentVersion": "2.144.0",
Expand Down
2 changes: 1 addition & 1 deletion extensions/sonarqube/vss-extension.json
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "sonarqube",
"name": "SonarQube",
"version": "5.11.0",
"version": "5.11.1",
"branding": {
"color": "rgb(67, 157, 210)",
"theme": "dark"
Expand Down