Skip to content

Commit

Permalink
main: enable debug file if namespace runner
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichelo committed Aug 8, 2023
1 parent ffd8cb6 commit bab4f78
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
2 changes: 2 additions & 0 deletions common.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const nscRemoteBuilderName = "nsc-remote";
export const nscDebugFilePath = "/home/runner/nsc/buildkit_proxy.log";
export const nscVmIdKey = 'NSC_VM_ID';
18 changes: 17 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4319,6 +4319,8 @@ var exec = __nccwpck_require__(514);
var external_fs_ = __nccwpck_require__(147);
;// CONCATENATED MODULE: ./common.ts
const nscRemoteBuilderName = "nsc-remote";
const nscDebugFilePath = "/home/runner/nsc/buildkit_proxy.log";
const nscVmIdKey = 'NSC_VM_ID';

;// CONCATENATED MODULE: ./main.ts
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
Expand Down Expand Up @@ -4363,7 +4365,15 @@ function prepareBuildx() {
if (!exists) {
yield core.group(`Proxy Buildkit from Namespace Cloud`, () => __awaiter(this, void 0, void 0, function* () {
yield ensureNscloudToken();
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`);
const nscRunner = yield isNscRunner();
if (nscRunner) {
core.debug(`Environment is Namespace Runner`);
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --debug_to_file=${nscDebugFilePath}`);
}
else {
core.debug(`Environment is not Namespace Runner`);
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`);
}
}));
}
yield core.group(`Builder`, () => __awaiter(this, void 0, void 0, function* () {
Expand Down Expand Up @@ -4396,6 +4406,12 @@ function remoteNscBuilderExists() {
return !(stdout.includes(builderNotFoundStr) || stderr.includes(builderNotFoundStr));
});
}
function isNscRunner() {
return __awaiter(this, void 0, void 0, function* () {
const vmID = process.env[`${nscVmIdKey}`] || "";
return vmID !== "";
});
}
run();

})();
Expand Down
22 changes: 18 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as fs from "fs";
import { nscRemoteBuilderName } from "./common";
import { nscRemoteBuilderName, nscDebugFilePath, nscVmIdKey } from "./common";

async function run(): Promise<void> {
var commandExists = require("command-exists");
Expand Down Expand Up @@ -38,9 +38,18 @@ async function prepareBuildx(): Promise<void> {
await core.group(`Proxy Buildkit from Namespace Cloud`, async () => {
await ensureNscloudToken();

await exec.exec(
`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`
);
const nscRunner = await isNscRunner();
if (nscRunner) {
core.debug(`Environment is Namespace Runner`);
await exec.exec(
`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --debug_to_file=${nscDebugFilePath}`
);
} else {
core.debug(`Environment is not Namespace Runner`);
await exec.exec(
`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`
);
}
});
}

Expand Down Expand Up @@ -79,4 +88,9 @@ async function remoteNscBuilderExists(): Promise<boolean> {
);
}

async function isNscRunner(): Promise<boolean> {
const vmID: string = process.env[`${nscVmIdKey}`] || "";
return vmID !== "";
}

run();

0 comments on commit bab4f78

Please sign in to comment.