From 847887b312aada35f1b27772484e0dd2c78677c0 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 18 Feb 2023 04:36:14 +0100 Subject: [PATCH] some debug logs Signed-off-by: CrazyMax --- src/buildx/buildx.ts | 6 +++++- src/buildx/install.ts | 10 +++++----- src/docker.ts | 10 ++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/buildx/buildx.ts b/src/buildx/buildx.ts index 6e208980..ec8930a5 100644 --- a/src/buildx/buildx.ts +++ b/src/buildx/buildx.ts @@ -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'; @@ -123,9 +124,12 @@ export class Buildx { public async versionSatisfies(range: string, version?: string): Promise { 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 { diff --git a/src/buildx/install.ts b/src/buildx/install.ts index 4a441d9f..04f0bbf0 100644 --- a/src/buildx/install.ts +++ b/src/buildx/install.ts @@ -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}`); diff --git a/src/docker.ts b/src/docker.ts index 2b86de77..57acf2be 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -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 { 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 { const noDocker = standalone ?? !Docker.isAvailable; if (noDocker) { + core.debug('Docker.printInfo: Docker is not available, skipping.'); return; } await exec.exec('docker', ['info'], {