Use @actions-rs/core for cargo/cross execution.

Add problem matcher for cargo output
This commit is contained in:
svartalf 2019-09-25 10:08:33 +03:00
parent 5c0786fa0f
commit e35786a472
12 changed files with 109 additions and 116 deletions

View file

@ -2,37 +2,10 @@
* Parse action input into a some proper thing.
*/
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {input} from '@actions-rs/core';
import stringArgv from 'string-argv';
// Workaround for a GH bug: https://github.com/actions/toolkit/issues/127
//
// For input `all-features: true` it will generate the `INPUT_ALL-FEATURES: true`
// env variable, which looks too weird.
// Here we are trying to get proper name `INPUT_NO_DEFAULT_FEATURES` first,
// and if it does not exist, trying the `INPUT_NO-DEFAULT-FEATURES`
function getInput(name: string): string {
const inputFullName = name.replace(/-/g, '_');
let value = core.getInput(inputFullName);
if (value.length > 0) {
return value
}
return core.getInput(name)
}
function getInputBool(name: string): boolean {
const value = getInput(name);
if (value && (value == 'true' || value == '1')) {
return true;
} else {
return false;
}
}
// Parsed action input
export interface Input {
command: string,
@ -41,14 +14,14 @@ export interface Input {
useCross: boolean,
}
export function parse(): Input {
const command = getInput('command');
const args = stringArgv(getInput('args'));
let toolchain = getInput('toolchain');
export function get(): Input {
const command = input.getInput('command', {required: true});
const args = stringArgv(input.getInput('args'));
let toolchain = input.getInput('toolchain');
if (toolchain.startsWith('+')) {
toolchain = toolchain.slice(1);
}
const useCross = getInputBool('use-cross');
const useCross = input.getInputBool('use-cross');
return {
command: command,