Skip to content

Commit

Permalink
🐛 Fix pulling Docker for native mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Aug 4, 2023
1 parent c561c8f commit e47179c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
4 changes: 4 additions & 0 deletions common/qodana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export function extractArg(
return arg
}

export function isNativeMode(args: string[]): boolean {
return args.includes('--ide')
}

/**
* Builds the `qodana pull` command arguments.
* @returns The `qodana scan` command arguments.
Expand Down
15 changes: 11 additions & 4 deletions scan/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8562,6 +8562,7 @@ __export(qodana_exports, {
getQodanaSha256MismatchMessage: () => getQodanaSha256MismatchMessage,
getQodanaUrl: () => getQodanaUrl,
isExecutionSuccessful: () => isExecutionSuccessful,
isNativeMode: () => isNativeMode,
sha256sum: () => sha256sum
});
function getQodanaSha256(arch, platform) {
Expand Down Expand Up @@ -8609,6 +8610,9 @@ function extractArg(argShort, argLong, args) {
}
return arg;
}
function isNativeMode(args) {
return args.includes("--ide");
}
function getQodanaPullArgs(args) {
const pullArgs = ["pull"];
const linter = extractArg("-l", "--linter", args);
Expand Down Expand Up @@ -8699,6 +8703,7 @@ var init_qodana = __esm({
})(QodanaExitCode || {});
__name(isExecutionSuccessful, "isExecutionSuccessful");
__name(extractArg, "extractArg");
__name(isNativeMode, "isNativeMode");
__name(getQodanaPullArgs, "getQodanaPullArgs");
__name(getQodanaScanArgs, "getQodanaScanArgs");
NONE = "none";
Expand Down Expand Up @@ -69250,10 +69255,12 @@ var require_utils8 = __commonJS({
extractRoot = yield tc.extractTar(temp);
}
core2.addPath(yield tc.cacheDir(extractRoot, qodana_12.EXECUTABLE, qodana_12.VERSION));
const exitCode = yield qodana(getInputs(), (0, qodana_12.getQodanaPullArgs)(args));
if (exitCode !== 0) {
core2.setFailed(`qodana pull failed with exit code ${exitCode}`);
return;
if (!(0, qodana_12.isNativeMode)(args)) {
const exitCode = yield qodana(getInputs(), (0, qodana_12.getQodanaPullArgs)(args));
if (exitCode !== 0) {
core2.setFailed(`qodana pull failed with exit code ${exitCode}`);
return;
}
}
});
}
Expand Down
13 changes: 8 additions & 5 deletions scan/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
PushFixesType,
NONE,
PULL_REQUEST,
BRANCH
BRANCH,
isNativeMode
} from '../../common/qodana'
import path from 'path'
import * as fs from 'fs'
Expand Down Expand Up @@ -157,10 +158,12 @@ export async function prepareAgent(args: string[]): Promise<void> {
extractRoot = await tc.extractTar(temp)
}
core.addPath(await tc.cacheDir(extractRoot, EXECUTABLE, VERSION))
const exitCode = await qodana(getInputs(), getQodanaPullArgs(args))
if (exitCode !== 0) {
core.setFailed(`qodana pull failed with exit code ${exitCode}`)
return
if (!isNativeMode(args)) {
const exitCode = await qodana(getInputs(), getQodanaPullArgs(args))
if (exitCode !== 0) {
core.setFailed(`qodana pull failed with exit code ${exitCode}`)
return
}
}
}

Expand Down
12 changes: 9 additions & 3 deletions vsts/QodanaScan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ __export(qodana_exports, {
getQodanaSha256MismatchMessage: () => getQodanaSha256MismatchMessage,
getQodanaUrl: () => getQodanaUrl,
isExecutionSuccessful: () => isExecutionSuccessful,
isNativeMode: () => isNativeMode,
sha256sum: () => sha256sum
});
function getQodanaSha256(arch, platform) {
Expand Down Expand Up @@ -125,6 +126,9 @@ function extractArg(argShort, argLong, args) {
}
return arg;
}
function isNativeMode(args) {
return args.includes("--ide");
}
function getQodanaPullArgs(args) {
const pullArgs = ["pull"];
const linter = extractArg("-l", "--linter", args);
Expand Down Expand Up @@ -4717,9 +4721,11 @@ var require_utils2 = __commonJS({
extractRoot = yield tool.extractTar(temp);
}
tool.prependPath(yield tool.cacheDir(extractRoot, qodana_12.EXECUTABLE, qodana_12.VERSION));
const pull = yield qodana((0, qodana_12.getQodanaPullArgs)(args));
if (pull !== 0) {
setFailed("Unable to run 'qodana pull'");
if (!(0, qodana_12.isNativeMode)(args)) {
const pull = yield qodana((0, qodana_12.getQodanaPullArgs)(args));
if (pull !== 0) {
setFailed("Unable to run 'qodana pull'");
}
}
});
}
Expand Down
11 changes: 7 additions & 4 deletions vsts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
getQodanaSha256,
getQodanaSha256MismatchMessage,
getQodanaUrl,
sha256sum
sha256sum,
isNativeMode
} from '../../common/qodana'

// eslint-disable-next-line @typescript-eslint/no-require-imports
Expand Down Expand Up @@ -89,9 +90,11 @@ export async function prepareAgent(args: string[]): Promise<void> {
extractRoot = await tool.extractTar(temp)
}
tool.prependPath(await tool.cacheDir(extractRoot, EXECUTABLE, VERSION))
const pull = await qodana(getQodanaPullArgs(args))
if (pull !== 0) {
setFailed("Unable to run 'qodana pull'")
if (!isNativeMode(args)) {
const pull = await qodana(getQodanaPullArgs(args))
if (pull !== 0) {
setFailed("Unable to run 'qodana pull'")
}
}
}

Expand Down

0 comments on commit e47179c

Please sign in to comment.