From 43013c67958c38b3a0065758be0b923398068836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 27 Oct 2019 19:40:00 +0100 Subject: [PATCH] Use toolchain install instead of multiple commands --- lib/main.js | 11 ++++------- lib/rustup.js | 5 +++++ src/main.ts | 20 +++++++++++--------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/main.js b/lib/main.js index b7cf884..a169eeb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -32,14 +32,11 @@ function run() { .filter((target) => target.length > 0); if (version) { yield rustup.install(); + yield exec.exec('rustup', ['toolchain', 'install', version, + ...(components.length > 0 ? ['-c', ...components] : []), + ...(targets.length > 0 ? ['-t', ...targets] : []), + ]); yield exec.exec('rustup', ['default', version]); - yield exec.exec('rustup', ['update', version]); - for (let component of components) { - yield exec.exec('rustup', ['component', 'add', component]); - } - for (let target of targets) { - yield exec.exec('rustup', ['target', 'add', target]); - } } } catch (error) { diff --git a/lib/rustup.js b/lib/rustup.js index 70172fb..6ff1704 100644 --- a/lib/rustup.js +++ b/lib/rustup.js @@ -30,6 +30,11 @@ function install() { core.debug('rustup is located under: ' + toolPath); core.addPath(path.join(toolPath, 'bin')); } + else { + // update the GitHub managed VM version of rustup + // to leverage newer features like "latest latest compatible nightly" + yield exec.exec('rustup', ['self', 'update']); + } }); } exports.install = install; diff --git a/src/main.ts b/src/main.ts index 0d4db90..1709d96 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,10 +6,12 @@ import * as os from 'os'; async function run() { try { const version = core.getInput('rust-version'); + const components = core.getInput('components') .split(',') .map((component) => component.trim()) .filter((component) => component.length > 0); + const targets = core.getInput('targets') .split(',') .map((target) => target.trim()) @@ -17,16 +19,16 @@ async function run() { if(version) { await rustup.install(); + + await exec.exec( + 'rustup', + ['toolchain', 'install', version, + ...(components.length > 0 ? ['-c', ...components] : []), + ...(targets.length > 0 ? ['-t', ...targets] : []), + ] + ); + await exec.exec('rustup', ['default', version]); - await exec.exec('rustup', ['update', version]); - - for(let component of components) { - await exec.exec('rustup', ['component', 'add', component]); - } - - for(let target of targets) { - await exec.exec('rustup', ['target', 'add', target]); - } } } catch (error) { core.setFailed(error.message);