Skip to content

Commit

Permalink
feat: add artifacts and metadata outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Feb 27, 2022
1 parent 39419c3 commit 5469a55
Show file tree
Hide file tree
Showing 8 changed files with 9,783 additions and 1,747 deletions.
31 changes: 31 additions & 0 deletions __tests__/context.test.ts
@@ -0,0 +1,31 @@
import * as os from 'os';
import * as context from '../src/context';

describe('setOutput', () => {
beforeEach(() => {
process.stdout.write = jest.fn();
});

it('setOutput produces the correct command', () => {
context.setOutput('some output', 'some value');
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
});

it('setOutput handles bools', () => {
context.setOutput('some output', false);
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
});

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]);
}
}
6 changes: 6 additions & 0 deletions action.yml
Expand Up @@ -27,6 +27,12 @@ inputs:
default: 'false'
required: false

outputs:
artifacts:
description: 'Build result artifacts'
metadata:
description: 'Build result metadata'

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

0 comments on commit 5469a55

Please sign in to comment.