From 5185c16d0626b51593fa9ce170c3316c23ee327c Mon Sep 17 00:00:00 2001 From: Yusuke Sasaki Date: Tue, 15 Oct 2019 17:16:19 +0900 Subject: [PATCH] add profile support --- README.md | 1 + action.yml | 3 +++ src/args.ts | 6 ++++-- src/main.ts | 11 +++++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1151ff..6f65691 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ See [additional recipes here](https://github.com/actions-rs/meta). | `target` | | Additionally install specified target for this toolchain, ex. `x86_64-apple-darwin` | string | | | `default` | | Set installed toolchain as a default toolchain | bool | false | | `override` | | Set installed toolchain as an override for the current directory | bool | false | +| `profile` | | Profile to specify components to install, ex. `minimal`, `default`, `complete` | string | | ## Components diff --git a/action.yml b/action.yml index 6c43026..68c5dc1 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,9 @@ inputs: override: description: Set installed toolchain as an override for a directory default: false + profile: + description: Profile to install for this toolchain + required: false runs: using: 'node12' diff --git a/src/args.ts b/src/args.ts index e3fe0b9..1c92d53 100644 --- a/src/args.ts +++ b/src/args.ts @@ -30,7 +30,8 @@ export interface ToolchainOptions { name: string, target?: string, default: boolean, - override: boolean + override: boolean, + profile?: string, } export function toolchain_args(): ToolchainOptions { @@ -38,6 +39,7 @@ export function toolchain_args(): ToolchainOptions { name: getInput('toolchain', {required: true}), target: getInput('target') || undefined, default: inputBoolean('default'), - override: inputBoolean('override') + override: inputBoolean('override'), + profile: getInput('profile') || undefined, }; } diff --git a/src/main.ts b/src/main.ts index c6129eb..7ecdb5d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,7 +32,7 @@ function downloadRustInit(url: string, name: string): Promise { }); } -async function get_rustup(toolchain: string): Promise { +async function get_rustup(toolchain: string, profile: string): Promise { try { const foundPath = await io.which('rustup', true); core.debug(`Found rustup at ${foundPath}`); @@ -45,6 +45,8 @@ async function get_rustup(toolchain: string): Promise { '-y', '--default-toolchain', toolchain, + '--profile', + profile, ]; // Note: `target` input can't be used here for `--default-host` argument, see #8 @@ -72,7 +74,12 @@ async function get_rustup(toolchain: string): Promise { async function run() { const opts = args.toolchain_args(); - const rustup = await get_rustup(opts.name); + const profile = opts.profile ? opts.profile : 'default'; + const rustup = await get_rustup(opts.name, profile); + + if (opts.profile) { + await exec.exec(rustup, ['set', 'profile', opts.profile]); + } await exec.exec(rustup, ['toolchain', 'install', opts.name]);