mirror of
https://github.com/actions-rs/cargo.git
synced 2024-12-22 15:45:49 +02:00
Smarter args parser and a few debug messages
This commit is contained in:
parent
de5e75cc84
commit
40cbaa365c
6 changed files with 27 additions and 15 deletions
|
@ -1,8 +1,9 @@
|
|||
import * as args from '../src/args'
|
||||
import * as input from '../src/input'
|
||||
|
||||
const testEnvVars = {
|
||||
INPUT_COMMAND: 'build',
|
||||
INPUT_ARGS: '--release --target x86_64-unknown-linux-gnu --no-default-features --features unstable',
|
||||
// There are few unnecessary spaces here to check that args parser works properly
|
||||
INPUT_ARGS: ' --release --target x86_64-unknown-linux-gnu --no-default-features --features unstable ',
|
||||
'INPUT_USE-CROSS': 'true',
|
||||
INPUT_TOOLCHAIN: '+nightly'
|
||||
}
|
||||
|
@ -14,7 +15,7 @@ describe('actions-rs/check', () => {
|
|||
})
|
||||
|
||||
it('Parses action input into cargo input', async () => {
|
||||
const result = args.parse();
|
||||
const result = input.parse();
|
||||
|
||||
expect(result.command).toBe('build');
|
||||
expect(result.args).toStrictEqual([
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "cargo",
|
||||
"version": "1.0.0",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz",
|
||||
"integrity": "sha512-aMIlkx96XH4E/2YZtEOeyrYQfhlas9jIRkfGPqMwXD095Rdkzo4lB6ZmbxPQSzD+e1M+Xsm98ZhuSMYGv/AlqA=="
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA=="
|
||||
},
|
||||
"@actions/exec": {
|
||||
"version": "1.0.1",
|
||||
|
@ -4413,6 +4413,11 @@
|
|||
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=",
|
||||
"dev": true
|
||||
},
|
||||
"string-argv": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz",
|
||||
"integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg=="
|
||||
},
|
||||
"string-length": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz",
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
"url": "https://github.com/actions-rs/cargo/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.0.0",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/io": "^1.0.0"
|
||||
"@actions/core": "^1.0.1",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"string-argv": "^0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.13",
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
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`
|
||||
|
@ -41,8 +43,7 @@ export interface Input {
|
|||
|
||||
export function parse(): Input {
|
||||
const command = getInput('command');
|
||||
// TODO: This probably will strike back later
|
||||
const args = getInput('args').split(' ');
|
||||
const args = stringArgv(getInput('args'));
|
||||
let toolchain = getInput('toolchain');
|
||||
if (toolchain.startsWith('+')) {
|
||||
toolchain = toolchain.slice(1);
|
||||
|
|
|
@ -10,12 +10,13 @@ async function getCross(): Promise<string> {
|
|||
try {
|
||||
return await io.which('cross', true);
|
||||
} catch (error) {
|
||||
core.warning('Unable to find cross, installing it now');
|
||||
core.debug('Unable to find cross, installing it now');
|
||||
}
|
||||
|
||||
try {
|
||||
core.startGroup('Install cross');
|
||||
core.warning('Git version of cross will be installed, \
|
||||
see https://github.com/actions-rs/cargo/issues/1');
|
||||
see https://github.com/actions-rs/cargo/issues/1');
|
||||
await exec.exec('cargo', [
|
||||
'install',
|
||||
'--rev',
|
||||
|
@ -25,6 +26,9 @@ async function getCross(): Promise<string> {
|
|||
]);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
// Expecting it to be in PATH already
|
||||
|
|
Loading…
Reference in a new issue