Skip to content

Commit 40fefd8

Browse files
committed
Remove workaround for setOutput
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 90a1e46 commit 40fefd8

5 files changed

Lines changed: 9 additions & 47 deletions

File tree

__tests__/context.test.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,6 @@ describe('asyncForEach', () => {
172172
});
173173
});
174174

175-
describe('setOutput', () => {
176-
beforeEach(() => {
177-
process.stdout.write = jest.fn() as typeof process.stdout.write;
178-
});
179-
180-
// eslint-disable-next-line jest/expect-expect
181-
it('setOutput produces the correct command', () => {
182-
context.setOutput('some output', 'some value');
183-
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
184-
});
185-
186-
// eslint-disable-next-line jest/expect-expect
187-
it('setOutput handles bools', () => {
188-
context.setOutput('some output', false);
189-
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
190-
});
191-
192-
// eslint-disable-next-line jest/expect-expect
193-
it('setOutput handles numbers', () => {
194-
context.setOutput('some output', 1.01);
195-
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
196-
});
197-
});
198-
199175
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
200176
function getInputName(name: string): string {
201177
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
@@ -204,11 +180,3 @@ function getInputName(name: string): string {
204180
function setInput(name: string, value: string): void {
205181
process.env[getInputName(name)] = value;
206182
}
207-
208-
// Assert that process.stdout.write calls called only with the given arguments.
209-
function assertWriteCalls(calls: string[]): void {
210-
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
211-
for (let i = 0; i < calls.length; i++) {
212-
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
213-
}
214-
}

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as tmp from 'tmp';
55
import * as uuid from 'uuid';
66
import * as buildx from './buildx';
77
import * as core from '@actions/core';
8-
import {issueCommand} from '@actions/core/lib/command';
98

109
let _tmpDir: string;
1110
export const osPlat: string = os.platform();
@@ -104,8 +103,3 @@ export const asyncForEach = async (array, callback) => {
104103
await callback(array[index], index, array);
105104
}
106105
};
107-
108-
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
109-
export function setOutput(name: string, value: unknown): void {
110-
issueCommand('set-output', {name}, value);
111-
}

src/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function run(): Promise<void> {
5353
});
5454
});
5555

56-
context.setOutput('name', inputs.name);
56+
core.setOutput('name', inputs.name);
5757
stateHelper.setBuilderName(inputs.name);
5858

5959
const credsdir = path.join(dockerConfigHome, 'buildx', 'creds', inputs.name);
@@ -89,12 +89,12 @@ async function run(): Promise<void> {
8989
const builder = await buildx.inspect(inputs.name, standalone);
9090
const firstNode = builder.nodes[0];
9191
core.info(JSON.stringify(builder, undefined, 2));
92-
context.setOutput('driver', builder.driver);
93-
context.setOutput('platforms', firstNode.platforms);
94-
context.setOutput('nodes', JSON.stringify(builder.nodes, undefined, 2));
95-
context.setOutput('endpoint', firstNode.endpoint); // TODO: deprecated, to be removed in a later version
96-
context.setOutput('status', firstNode.status); // TODO: deprecated, to be removed in a later version
97-
context.setOutput('flags', firstNode['buildkitd-flags']); // TODO: deprecated, to be removed in a later version
92+
core.setOutput('driver', builder.driver);
93+
core.setOutput('platforms', firstNode.platforms);
94+
core.setOutput('nodes', JSON.stringify(builder.nodes, undefined, 2));
95+
core.setOutput('endpoint', firstNode.endpoint); // TODO: deprecated, to be removed in a later version
96+
core.setOutput('status', firstNode.status); // TODO: deprecated, to be removed in a later version
97+
core.setOutput('flags', firstNode['buildkitd-flags']); // TODO: deprecated, to be removed in a later version
9898
core.endGroup();
9999

100100
if (!standalone && builder.driver == 'docker-container') {

0 commit comments

Comments
 (0)