mirror of
https://github.com/actions-rs/cargo.git
synced 2024-12-22 15:45:49 +02:00
Installing specific cross revision from git (see #1)
This commit is contained in:
parent
4630dea632
commit
de5e75cc84
3 changed files with 17 additions and 90 deletions
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
84
src/input.ts
84
src/input.ts
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as exec_tr from '@actions/exec/lib/toolrunner';
|
|
||||||
|
|
||||||
// Workaround for a GH bug: https://github.com/actions/toolkit/issues/127
|
// Workaround for a GH bug: https://github.com/actions/toolkit/issues/127
|
||||||
//
|
//
|
||||||
|
@ -42,7 +41,8 @@ export interface Input {
|
||||||
|
|
||||||
export function parse(): Input {
|
export function parse(): Input {
|
||||||
const command = getInput('command');
|
const command = getInput('command');
|
||||||
const args = exec_tr.argStringToArray(getInput('args'));
|
// TODO: This probably will strike back later
|
||||||
|
const args = getInput('args').split(' ');
|
||||||
let toolchain = getInput('toolchain');
|
let toolchain = getInput('toolchain');
|
||||||
if (toolchain.startsWith('+')) {
|
if (toolchain.startsWith('+')) {
|
||||||
toolchain = toolchain.slice(1);
|
toolchain = toolchain.slice(1);
|
||||||
|
@ -56,83 +56,3 @@ export function parse(): Input {
|
||||||
toolchain: toolchain || undefined
|
toolchain: toolchain || undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// import * as core from '@actions/core';
|
|
||||||
//
|
|
||||||
// // 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 inputFlag(name: string): string | null {
|
|
||||||
// const value = getInput(name);
|
|
||||||
// if (value == 'true' || value == '1') {
|
|
||||||
// return `--${name}`;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// function inputString(name: string): string | null {
|
|
||||||
// const value = getInput(name);
|
|
||||||
// if (value.length > 0) {
|
|
||||||
// return `--${name}=${value}`;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return null
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// const INPUT_GENERATOR: Array<() => string | null> = [
|
|
||||||
// () => inputFlag('quiet'),
|
|
||||||
// () => inputString('package'),
|
|
||||||
// () => inputFlag('all'),
|
|
||||||
// () => inputString('exclude'),
|
|
||||||
// () => inputFlag('lib'),
|
|
||||||
// () => inputString('bin'),
|
|
||||||
// () => inputFlag('bins'),
|
|
||||||
// () => inputString('example'),
|
|
||||||
// () => inputFlag('examples'),
|
|
||||||
// () => inputString('test'),
|
|
||||||
// () => inputFlag('tests'),
|
|
||||||
// () => inputString('bench'),
|
|
||||||
// () => inputFlag('benches'),
|
|
||||||
// () => inputFlag('all-targets'),
|
|
||||||
// () => inputFlag('release'),
|
|
||||||
// () => inputString('profile'),
|
|
||||||
// () => inputString('features'),
|
|
||||||
// () => inputFlag('all-features'),
|
|
||||||
// () => inputFlag('no-default-features'),
|
|
||||||
// () => inputString('target'),
|
|
||||||
// () => inputString('target-dir'),
|
|
||||||
// () => inputString('manifest-path'),
|
|
||||||
// () => inputFlag('frozen'),
|
|
||||||
// () => inputFlag('locked')
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// // All `cargo check` args are optional,
|
|
||||||
// // but we need to do some validation at least
|
|
||||||
// export function check_args(): string[] {
|
|
||||||
// let args: string[] = ['check'];
|
|
||||||
// for (const caller of INPUT_GENERATOR) {
|
|
||||||
// const arg = caller();
|
|
||||||
// if (arg == null) {
|
|
||||||
// continue
|
|
||||||
// } else {
|
|
||||||
// args.push(arg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return args
|
|
||||||
// }
|
|
||||||
|
|
21
src/main.ts
21
src/main.ts
|
@ -4,6 +4,8 @@ import * as io from '@actions/io';
|
||||||
|
|
||||||
import * as input from './input';
|
import * as input from './input';
|
||||||
|
|
||||||
|
const CROSS_REV: string = '69b8da7da287055127812c9e4b071756c2b98545';
|
||||||
|
|
||||||
async function getCross(): Promise<string> {
|
async function getCross(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
return await io.which('cross', true);
|
return await io.which('cross', true);
|
||||||
|
@ -12,14 +14,20 @@ async function getCross(): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Latest `cross` (0.1.15) is kinda broken right now,
|
core.warning('Git version of cross will be installed, \
|
||||||
// using hardcoded version till the fix lands
|
see https://github.com/actions-rs/cargo/issues/1');
|
||||||
// https://github.com/rust-embedded/cross/issues/306
|
await exec.exec('cargo', [
|
||||||
await exec.exec('cargo', ['install', '--version', '0.1.14', 'cross']);
|
'install',
|
||||||
|
'--rev',
|
||||||
|
CROSS_REV,
|
||||||
|
'--git',
|
||||||
|
'https://github.com/rust-embedded/cross.git'
|
||||||
|
]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expecting it to be in PATH already
|
||||||
return 'cross';
|
return 'cross';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,13 +41,12 @@ async function run() {
|
||||||
program = 'cargo';
|
program = 'cargo';
|
||||||
}
|
}
|
||||||
|
|
||||||
let args: string[] = [actionInput.command];
|
let args: string[] = [];
|
||||||
if (actionInput.toolchain) {
|
if (actionInput.toolchain) {
|
||||||
args.push(`+${actionInput.toolchain}`);
|
args.push(`+${actionInput.toolchain}`);
|
||||||
}
|
}
|
||||||
|
args.push(actionInput.command);
|
||||||
args = args.concat(actionInput.args);
|
args = args.concat(actionInput.args);
|
||||||
console.log(program, args);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await exec.exec(program, args);
|
await exec.exec(program, args);
|
||||||
|
|
Loading…
Reference in a new issue