Skip to content

Commit

Permalink
employ --default_load
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Aug 28, 2024
1 parent b7fd48c commit 534cf4d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
28 changes: 14 additions & 14 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4315,8 +4315,8 @@ __nccwpck_require__.r(__webpack_exports__);
var core = __nccwpck_require__(186);
// EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js
var exec = __nccwpck_require__(514);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(147);
;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = require("node:fs");
;// CONCATENATED MODULE: ./common.ts
const nscRemoteBuilderName = "nsc-remote";
const nscDebugFolder = "/home/runner/nsc";
Expand All @@ -4338,10 +4338,10 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume

function run() {
return __awaiter(this, void 0, void 0, function* () {
var commandExists = __nccwpck_require__(724);
const commandExists = __nccwpck_require__(724);
commandExists("nsc")
.then(prepareBuildx)
.catch(function () {
.catch(() => {
core.setFailed(`Namespace Cloud CLI not found.
Please add a step this step to your workflow's job definition:
Expand All @@ -4353,30 +4353,30 @@ Please add a step this step to your workflow's job definition:
function prepareBuildx() {
return __awaiter(this, void 0, void 0, function* () {
try {
const exists = yield core.group(`Ensure Namespace Builder proxy is already configured`, () => __awaiter(this, void 0, void 0, function* () {
const exists = yield core.group("Check if Namespace Builder proxy is already configured", () => __awaiter(this, void 0, void 0, function* () {
const builderExists = yield remoteNscBuilderExists();
if (builderExists) {
core.info(`GitHub runner is already configured to use Namespace Cloud build cluster.`);
core.info("GitHub runner is already configured to use Namespace Cloud build cluster.");
return true;
}
core.info(`Namespace Builder is not yet configured.`);
core.info("Namespace Builder is not yet configured.");
return false;
}));
if (!exists) {
yield core.group(`Proxy Buildkit from Namespace Cloud`, () => __awaiter(this, void 0, void 0, function* () {
yield core.group("Proxy Buildkit from Namespace Cloud", () => __awaiter(this, void 0, void 0, function* () {
yield ensureNscloudToken();
const nscRunner = yield isNscRunner();
if (nscRunner) {
core.debug(`Environment is Namespace Runner`);
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --background_debug_dir=${nscDebugFolder}`);
core.debug("Environment is Namespace Runner");
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --default_load --background_debug_dir=${nscDebugFolder}`);
}
else {
core.debug(`Environment is not Namespace Runner`);
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use`);
core.debug("Environment is not Namespace Runner");
yield exec.exec(`nsc docker buildx setup --name=${nscRemoteBuilderName} --background --use --default_load`);
}
}));
}
yield core.group(`Builder`, () => __awaiter(this, void 0, void 0, function* () {
yield core.group("Builder", () => __awaiter(this, void 0, void 0, function* () {
core.info(nscRemoteBuilderName);
}));
// New line to separate from groups.
Expand All @@ -4391,7 +4391,7 @@ Configured buildx to use remote Namespace Cloud build cluster.`);
function ensureNscloudToken() {
return __awaiter(this, void 0, void 0, function* () {
const tokenFile = "/var/run/nsc/token.json";
if (external_fs_.existsSync(tokenFile)) {
if (external_node_fs_namespaceObject.existsSync(tokenFile)) {
core.exportVariable("NSC_TOKEN_FILE", tokenFile);
return;
}
Expand Down
24 changes: 12 additions & 12 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as fs from "fs";
import * as fs from "node:fs";
import { nscRemoteBuilderName, nscDebugFolder, nscVmIdKey } from "./common";

async function run(): Promise<void> {
var commandExists = require("command-exists");
const commandExists = require("command-exists");

commandExists("nsc")
.then(prepareBuildx)
.catch(function () {
.catch(() => {
core.setFailed(`Namespace Cloud CLI not found.
Please add a step this step to your workflow's job definition:
Expand All @@ -20,40 +20,40 @@ Please add a step this step to your workflow's job definition:
async function prepareBuildx(): Promise<void> {
try {
const exists = await core.group(
`Ensure Namespace Builder proxy is already configured`,
"Check if Namespace Builder proxy is already configured",
async (): Promise<boolean> => {
const builderExists = await remoteNscBuilderExists();
if (builderExists) {
core.info(
`GitHub runner is already configured to use Namespace Cloud build cluster.`
"GitHub runner is already configured to use Namespace Cloud build cluster."
);
return true;
}
core.info(`Namespace Builder is not yet configured.`);
core.info("Namespace Builder is not yet configured.");
return false;
}
);

if (!exists) {
await core.group(`Proxy Buildkit from Namespace Cloud`, async () => {
await core.group("Proxy Buildkit from Namespace Cloud", async () => {
await ensureNscloudToken();

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

await core.group(`Builder`, async () => {
await core.group("Builder", async () => {
core.info(nscRemoteBuilderName);
});

Expand Down

0 comments on commit 534cf4d

Please sign in to comment.