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

Don't set up nsc-remote if in-runner-builder is present #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const nscRemoteBuilderName = "nsc-remote";
export const nscInRunnerBuilderName = "in-runner-builder"
export const nscDebugFolder = "/home/runner/nsc";
export const nscVmIdKey = 'NSC_VM_ID';
21 changes: 15 additions & 6 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 "node:fs";
import { nscRemoteBuilderName, nscDebugFolder, nscVmIdKey } from "./common";
import { nscRemoteBuilderName, nscDebugFolder, nscVmIdKey, nscInRunnerBuilderName } from "./common";

async function run(): Promise<void> {
const commandExists = require("command-exists");
Expand All @@ -22,13 +22,22 @@ async function prepareBuildx(): Promise<void> {
const exists = await core.group(
"Check if Namespace Builder proxy is already configured",
async (): Promise<boolean> => {
const builderExists = await remoteNscBuilderExists();
if (builderExists) {
const remoteBuilderExists = await nscBuilderExists(nscRemoteBuilderName);
if (remoteBuilderExists) {
core.info(
"GitHub runner is already configured to use Namespace Cloud build cluster."
);
return true;
}

const inRunnerBuilderExists = await nscBuilderExists(nscInRunnerBuilderName);
if (inRunnerBuilderExists) {
core.info(
"GitHub runner is already configured to use Namespace Locally cached builder."
);
return true;
}

core.info("Namespace Builder is not yet configured.");
return false;
}
Expand Down Expand Up @@ -90,13 +99,13 @@ async function ensureNscloudToken() {
await exec.exec("nsc auth exchange-github-token --ensure=5m");
}

async function remoteNscBuilderExists(): Promise<boolean> {
async function nscBuilderExists(builderName: string): Promise<boolean> {
const { stdout, stderr } = await exec.getExecOutput(
`docker buildx inspect ${nscRemoteBuilderName}`,
`docker buildx inspect ${builderName}`,
null,
{ ignoreReturnCode: true, silent: true }
);
const builderNotFoundStr = `no builder "${nscRemoteBuilderName}" found`;
const builderNotFoundStr = `no builder "$builderName}" found`;
return !(
stdout.includes(builderNotFoundStr) || stderr.includes(builderNotFoundStr)
);
Expand Down
Loading