Merge pull request #152 from crazy-max/setOutput

Remove setOutput workaround
This commit is contained in:
CrazyMax 2022-10-18 23:42:20 +02:00 committed by GitHub
commit 111c56156b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 47 deletions

View file

@ -1,35 +0,0 @@
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
import * as os from 'os';
import * as context from '../src/context';
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}`]);
});
});
// 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

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,4 @@
import * as core from '@actions/core';
import {issueCommand} from '@actions/core/lib/command';
export interface Inputs {
gpgPrivateKey: string;
@ -30,8 +29,3 @@ export async function getInputs(): Promise<Inputs> {
fingerprint: core.getInput('fingerprint')
};
}
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
export function setOutput(name: string, value: any): void {
issueCommand('set-output', {name}, value);
}

View file

@ -83,13 +83,13 @@ async function run(): Promise<void> {
await core.group(`Setting outputs`, async () => {
core.info(`fingerprint=${fingerprint}`);
context.setOutput('fingerprint', fingerprint);
core.setOutput('fingerprint', fingerprint);
core.info(`keyid=${privateKey.keyID}`);
context.setOutput('keyid', privateKey.keyID);
core.setOutput('keyid', privateKey.keyID);
core.info(`name=${privateKey.name}`);
context.setOutput('name', privateKey.name);
core.setOutput('name', privateKey.name);
core.info(`email=${privateKey.email}`);
context.setOutput('email', privateKey.email);
core.setOutput('email', privateKey.email);
});
if (inputs.gitUserSigningkey) {