Skip to content

Commit a437a45

Browse files
committed
Use built-in getExecOutput
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent a7071c9 commit a437a45

File tree

6 files changed

+540
-598
lines changed

6 files changed

+540
-598
lines changed

__tests__/buildx.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33
import * as semver from 'semver';
4+
import * as exec from '@actions/exec';
45

56
import * as buildx from '../src/buildx';
67
import * as context from '../src/context';
7-
import * as docker from '../src/docker';
88

99
const tmpNameSync = path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
1010
const digest = 'sha256:bfb45ab72e46908183546477a08f8867fc40cebadd00af54b071b097aed127a9';
@@ -92,9 +92,26 @@ describe('isLocalOrTarExporter', () => {
9292
);
9393
});
9494

95+
describe('isAvailable', () => {
96+
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
97+
buildx.isAvailable();
98+
99+
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
100+
silent: true,
101+
ignoreReturnCode: true
102+
});
103+
});
104+
95105
describe('getVersion', () => {
96106
async function isDaemonRunning() {
97-
return await docker.isDaemonRunning();
107+
return await exec
108+
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
109+
ignoreReturnCode: true,
110+
silent: true
111+
})
112+
.then(res => {
113+
return !res.stdout.includes(' ') && res.exitCode == 0;
114+
});
98115
}
99116
(isDaemonRunning() ? it : it.skip)(
100117
'valid',

0 commit comments

Comments
 (0)