Compare commits

..

4 Commits

Author SHA1 Message Date
CrazyMax
2c60cad840 Merge pull request #40 from crazy-max/debug
Some checks failed
publish / publish (push) Has been cancelled
some debug logs
2023-02-18 06:00:54 +01:00
CrazyMax
847887b312 some debug logs
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-02-18 04:36:32 +01:00
CrazyMax
d9984214c9 Merge pull request #39 from crazy-max/buildkit-ctn-prefix
buildx: make containerNamePrefix static and public
2023-02-18 02:20:37 +01:00
CrazyMax
33b4390bc2 buildx: make containerNamePrefix static and public
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-02-18 02:12:09 +01:00
4 changed files with 20 additions and 10 deletions

View File

@@ -33,7 +33,6 @@ export interface BuildKitOpts {
export class BuildKit {
private readonly context: Context;
private readonly buildx: Buildx;
private containerNamePrefix = 'buildx_buildkit_';
public readonly config: Config;
@@ -67,7 +66,7 @@ export class BuildKit {
private async getVersionWithinImage(nodeName: string): Promise<string> {
return exec
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${this.containerNamePrefix}${nodeName}`], {
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${Buildx.containerNamePrefix}${nodeName}`], {
ignoreReturnCode: true,
silent: true
})

View File

@@ -16,6 +16,7 @@
import fs from 'fs';
import path from 'path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as semver from 'semver';
@@ -36,6 +37,7 @@ export class Buildx {
public readonly inputs: Inputs;
public readonly standalone: boolean;
public static readonly containerNamePrefix = 'buildx_buildkit_';
constructor(opts: BuildxOpts) {
this.context = opts.context;
@@ -122,9 +124,12 @@ export class Buildx {
public async versionSatisfies(range: string, version?: string): Promise<boolean> {
const ver = version ?? (await this.version);
if (!ver) {
core.debug(`Buildx.versionSatisfies false: undefined version`);
return false;
}
return semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
const res = semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
core.debug(`Buildx.versionSatisfies ${ver} statisfies ${range}: ${res}`);
return res;
}
public static resolveCertsDriverOpts(driver: string, endpoint: string, cert: Cert): Array<string> {

View File

@@ -80,7 +80,7 @@ export class Install {
} else {
vspec = await Git.getRemoteSha(repo, ref);
}
core.debug(`Tool version spec ${vspec}`);
core.debug(`Install.build: tool version spec ${vspec}`);
let toolPath: string;
toolPath = tc.find('buildx', vspec);
@@ -112,16 +112,16 @@ export class Install {
let buildStandalone = false;
if (this.standalone && buildxStandaloneFound) {
core.debug(`Buildx standalone found, build with it`);
core.debug(`Install.buildCommand: Buildx standalone found, build with it`);
buildStandalone = true;
} else if (!this.standalone && buildxPluginFound) {
core.debug(`Buildx plugin found, build with it`);
core.debug(`Install.buildCommand: Buildx plugin found, build with it`);
buildStandalone = false;
} else if (buildxStandaloneFound) {
core.debug(`Buildx plugin not found, but standalone found so trying to build with it`);
core.debug(`Install.buildCommand: Buildx plugin not found, but standalone found so trying to build with it`);
buildStandalone = true;
} else if (buildxPluginFound) {
core.debug(`Buildx standalone not found, but plugin found so trying to build with it`);
core.debug(`Install.buildCommand: Buildx standalone not found, but plugin found so trying to build with it`);
buildStandalone = false;
} else {
throw new Error(`Neither buildx standalone or plugin have been found to build from ref ${gitContext}`);

View File

@@ -16,6 +16,7 @@
import os from 'os';
import path from 'path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
export class Docker {
@@ -32,21 +33,25 @@ export class Docker {
})
.then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
core.debug(`Docker.isAvailable error: ${res.stderr}`);
dockerAvailable = false;
} else {
core.debug(`Docker.isAvailable ok`);
dockerAvailable = res.exitCode == 0;
}
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.catch(error => {
core.debug(`Docker.isAvailable failed: ${error}`);
dockerAvailable = false;
});
return dockerAvailable;
}
public static async printVersion(standalone?: boolean) {
public static async printVersion(standalone?: boolean): Promise<void> {
const noDocker = standalone ?? !Docker.isAvailable;
if (noDocker) {
core.debug('Docker.printVersion: Docker is not available, skipping.');
return;
}
await exec.exec('docker', ['version'], {
@@ -54,9 +59,10 @@ export class Docker {
});
}
public static async printInfo(standalone?: boolean) {
public static async printInfo(standalone?: boolean): Promise<void> {
const noDocker = standalone ?? !Docker.isAvailable;
if (noDocker) {
core.debug('Docker.printInfo: Docker is not available, skipping.');
return;
}
await exec.exec('docker', ['info'], {