mirror of https://github.com/actions/toolkit
Match core to spec (still work to do)
parent
5f66339fde
commit
917c389219
|
@ -3,8 +3,28 @@
|
||||||
import * as core from '../src/lib'
|
import * as core from '../src/lib'
|
||||||
|
|
||||||
describe('@actions/core', () => {
|
describe('@actions/core', () => {
|
||||||
it('needs tests', () => {
|
it('tests exportVariable', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests getInput', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests setFailure', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests error', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests warning', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests debug', () => {
|
||||||
|
// TODO
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"actions"
|
"actions"
|
||||||
],
|
],
|
||||||
"author": "Bryan MacFarlane <bryanmac@microsoft.com>",
|
"author": "Bryan MacFarlane <bryanmac@microsoft.com>",
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/lib.js",
|
"main": "lib/lib.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import os = require('os');
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* ##[warning]This is the user warning message
|
* ##[warning]This is the user warning message
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
* ##[set-secret name=mypassword]definitelyNotAPassword!
|
||||||
*/
|
*/
|
||||||
export function _issueCommand(command: string, properties: {[key: string]: string}, message: string) {
|
export function _issueCommand(command: string, properties: {[key: string]: string}, message: string) {
|
||||||
var cmd = new _Command(command, properties, message);
|
var cmd = new _Command(command, properties, message);
|
||||||
|
@ -67,7 +67,6 @@ export class _Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _commandFromString(commandLine: string) {
|
export function _commandFromString(commandLine: string) {
|
||||||
var preLen = CMD_PREFIX.length;
|
|
||||||
var lbPos = commandLine.indexOf('[');
|
var lbPos = commandLine.indexOf('[');
|
||||||
var rbPos = commandLine.indexOf(']');
|
var rbPos = commandLine.indexOf(']');
|
||||||
if (lbPos == -1 || rbPos == -1 || rbPos - lbPos < 3) {
|
if (lbPos == -1 || rbPos == -1 || rbPos - lbPos < 3) {
|
||||||
|
|
|
@ -3,33 +3,53 @@ import intm = require('./internal');
|
||||||
import process = require('process');
|
import process = require('process');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets env variable for this action and future actions in the job
|
* Interface for exportVariable options
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable
|
|
||||||
*/
|
*/
|
||||||
export function setVariable(name: string, val: string) {
|
export interface ExportOptions {
|
||||||
|
/** Optional. Whether the variable should be marked as secret (will be masked from logs). Defaults to false */
|
||||||
|
isSecret?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets env variable for this action and future actions in the job
|
||||||
|
*
|
||||||
|
* @param name the name of the variable to set
|
||||||
|
* @param val the value of the variable
|
||||||
|
* @param options optional. See ExportOptions.
|
||||||
|
*/
|
||||||
|
export function exportVariable(name: string, val: string, options?: ExportOptions): void {
|
||||||
|
if (options && options.isSecret) {
|
||||||
|
intm._issueCommand('set-secret', {'name': name}, val);
|
||||||
|
}
|
||||||
process.env[name] = val;
|
process.env[name] = val;
|
||||||
intm._issueCommand('set-variable', {'name': name}, val);
|
intm._issueCommand('set-variable', {'name': name}, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets a variable which will get masked from logs
|
* Interface for getInput options
|
||||||
* @param name name of the secret variable
|
|
||||||
* @param val value of the secret variable
|
|
||||||
*/
|
*/
|
||||||
export function setSecret(name: string, val: string) {
|
export interface InputOptions {
|
||||||
intm._issueCommand('set-secret', {'name': name}, val);
|
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||||
setVariable(name, val);
|
required?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of an input. The value is also trimmed.
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export function getInput(name: string, options?: InputOptions): string | undefined {
|
||||||
|
// TODO - how are we passing in actions inputs?
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Results
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
/**
|
||||||
* fail the action
|
* fail the action
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
export function fail(message: string) {
|
export function setFailure(message: string): void {
|
||||||
process.exitCode = im.ExitCode.Failure;
|
process.exitCode = im.ExitCode.Failure;
|
||||||
error(message);
|
error(message);
|
||||||
}
|
}
|
||||||
|
@ -38,15 +58,8 @@ export function fail(message: string) {
|
||||||
// Logging Commands
|
// Logging Commands
|
||||||
// https://github.com/github/dreamlifter/blob/master/docs/actions-model.md#logging-commands
|
// https://github.com/github/dreamlifter/blob/master/docs/actions-model.md#logging-commands
|
||||||
//
|
//
|
||||||
// error and warning issues do not take FileDetails because while possible,
|
|
||||||
// that's typically reserved for the agent and the problem matchers.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
export function addPath(path: string) {
|
|
||||||
intm._issueCommand('add-path', {}, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function error(message: string) {
|
export function error(message: string) {
|
||||||
intm._issue('error', message);
|
intm._issue('error', message);
|
||||||
}
|
}
|
||||||
|
@ -54,3 +67,7 @@ export function error(message: string) {
|
||||||
export function warning(message: string) {
|
export function warning(message: string) {
|
||||||
intm._issue('warning', message);
|
intm._issue('warning', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function debug(message: string): void {
|
||||||
|
intm._issue('debug', message);
|
||||||
|
}
|
Loading…
Reference in New Issue