mirror of
https://github.com/docker/build-push-action
synced 2024-11-10 05:21:40 +00:00
Remove workaround for setOutput
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
f97d6e2850
commit
75aaa63262
5 changed files with 8 additions and 49 deletions
|
@ -1,6 +1,5 @@
|
||||||
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
|
@ -690,30 +689,6 @@ describe('asyncForEach', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setOutput', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
process.stdout.write = jest.fn() as typeof process.stdout.write;
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput produces the correct command', () => {
|
|
||||||
context.setOutput('some output', 'some value');
|
|
||||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput handles bools', () => {
|
|
||||||
context.setOutput('some output', false);
|
|
||||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput handles numbers', () => {
|
|
||||||
context.setOutput('some output', 1.01);
|
|
||||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
@ -722,11 +697,3 @@ function getInputName(name: string): string {
|
||||||
function setInput(name: string, value: string): void {
|
function setInput(name: string, value: string): void {
|
||||||
process.env[getInputName(name)] = value;
|
process.env[getInputName(name)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
|
||||||
function assertWriteCalls(calls: string[]): void {
|
|
||||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
|
||||||
for (let i = 0; i < calls.length; i++) {
|
|
||||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -1,14 +1,11 @@
|
||||||
import {parse} from 'csv-parse/sync';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import {issueCommand} from '@actions/core/lib/command';
|
|
||||||
import * as github from '@actions/github';
|
|
||||||
|
|
||||||
import * as buildx from './buildx';
|
import * as buildx from './buildx';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as github from '@actions/github';
|
||||||
|
import {parse} from 'csv-parse/sync';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
let _defaultContext, _tmpDir: string;
|
let _defaultContext, _tmpDir: string;
|
||||||
|
@ -248,8 +245,3 @@ export const asyncForEach = async (array, callback) => {
|
||||||
await callback(array[index], index, array);
|
await callback(array[index], index, array);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
|
||||||
export function setOutput(name: string, value: unknown): void {
|
|
||||||
issueCommand('set-output', {name}, value);
|
|
||||||
}
|
|
||||||
|
|
|
@ -60,19 +60,19 @@ async function run(): Promise<void> {
|
||||||
if (imageID) {
|
if (imageID) {
|
||||||
await core.group(`ImageID`, async () => {
|
await core.group(`ImageID`, async () => {
|
||||||
core.info(imageID);
|
core.info(imageID);
|
||||||
context.setOutput('imageid', imageID);
|
core.setOutput('imageid', imageID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (digest) {
|
if (digest) {
|
||||||
await core.group(`Digest`, async () => {
|
await core.group(`Digest`, async () => {
|
||||||
core.info(digest);
|
core.info(digest);
|
||||||
context.setOutput('digest', digest);
|
core.setOutput('digest', digest);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
await core.group(`Metadata`, async () => {
|
await core.group(`Metadata`, async () => {
|
||||||
core.info(metadata);
|
core.info(metadata);
|
||||||
context.setOutput('metadata', metadata);
|
core.setOutput('metadata', metadata);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in a new issue