Skip to content

Commit

Permalink
some debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Feb 18, 2023
1 parent d998421 commit 847887b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/buildx/buildx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -123,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> {
Expand Down
10 changes: 5 additions & 5 deletions src/buildx/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}`);
Expand Down
10 changes: 8 additions & 2 deletions src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,31 +33,36 @@ 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'], {
failOnStdErr: false
});
}

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'], {
Expand Down

0 comments on commit 847887b

Please sign in to comment.