Skip to content

Commit

Permalink
update to node 16
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 28, 2022
1 parent fe02965 commit 9faab75
Show file tree
Hide file tree
Showing 11 changed files with 1,402 additions and 2,212 deletions.
29 changes: 16 additions & 13 deletions __tests__/buildx.test.ts
@@ -1,8 +1,8 @@
import {describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
import * as exec from '@actions/exec';

import * as buildx from '../src/buildx';
import * as context from '../src/context';

Expand All @@ -25,6 +25,19 @@ jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
return tmpNameSync;
});

export const skipItIf = (conditional: boolean) => (conditional ? it.skip : it);

async function isDaemonRunning() {
return await exec
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
ignoreReturnCode: true,
silent: true
})
.then(res => {
return !res.stdout.includes(' ') && res.exitCode == 0;
});
}

describe('getImageID', () => {
it('matches', async () => {
const imageIDFile = await buildx.getImageIDFile();
Expand Down Expand Up @@ -104,7 +117,7 @@ describe('isLocalOrTarExporter', () => {
});

describe('isAvailable', () => {
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
const execSpy = jest.spyOn(exec, 'getExecOutput');
buildx.isAvailable();

expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
Expand All @@ -114,17 +127,7 @@ describe('isAvailable', () => {
});

describe('getVersion', () => {
async function isDaemonRunning() {
return await exec
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
ignoreReturnCode: true,
silent: true
})
.then(res => {
return !res.stdout.includes(' ') && res.exitCode == 0;
});
}
(isDaemonRunning() ? it : it.skip)(
skipItIf(!isDaemonRunning())(
'valid',
async () => {
const version = await buildx.getVersion();
Expand Down
4 changes: 4 additions & 0 deletions __tests__/context.test.ts
@@ -1,3 +1,4 @@
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
Expand Down Expand Up @@ -688,6 +689,7 @@ describe('asyncForEach', () => {

describe('setOutput', () => {
beforeEach(() => {
// @ts-ignore
process.stdout.write = jest.fn();
});

Expand Down Expand Up @@ -718,8 +720,10 @@ function setInput(name: string, value: string): void {

// Assert that process.stdout.write calls called only with the given arguments.
function assertWriteCalls(calls: string[]): void {
// @ts-ignore
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
for (let i = 0; i < calls.length; i++) {
// @ts-ignore
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
}
}
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -95,6 +95,6 @@ outputs:
description: 'Build result metadata'

runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
post: 'dist/index.js'

0 comments on commit 9faab75

Please sign in to comment.