mirror of
https://github.com/actions-rs/toolchain.git
synced 2024-12-22 15:45:49 +02:00
Dont prioritze rust-toolchain file over input variable (#45)
This commit is contained in:
parent
6a1db6369e
commit
d8323be6bd
5 changed files with 41 additions and 15 deletions
|
@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
### [1.0.3] - 2019-10-19
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Support for the `rust-toolchain` file: If the toolchain input is not given, we will try and install the version specified in the `rust-toolchain` file.
|
||||
|
||||
## [1.0.3] - 2019-10-19
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -40,6 +40,16 @@ describe('actions-rs/toolchain', () => {
|
|||
'INPUT_TOOLCHAIN': 'nightly',
|
||||
});
|
||||
|
||||
expect(args.name).toBe("nightly")
|
||||
});
|
||||
|
||||
it('uses rust-toolchain file if input does not exist', function () {
|
||||
let rustToolchainFile = tempWriteSync("1.39.0");
|
||||
|
||||
let args = morph(() => {
|
||||
return toolchain_args(rustToolchainFile);
|
||||
}, {});
|
||||
|
||||
expect(args.name).toBe("1.39.0")
|
||||
});
|
||||
|
||||
|
@ -48,9 +58,7 @@ describe('actions-rs/toolchain', () => {
|
|||
|
||||
let args = morph(() => {
|
||||
return toolchain_args(rustToolchainFile);
|
||||
}, {
|
||||
'INPUT_TOOLCHAIN': 'nightly',
|
||||
});
|
||||
}, {});
|
||||
|
||||
expect(args.name).toBe("1.39.0")
|
||||
});
|
||||
|
|
|
@ -10,6 +10,9 @@ inputs:
|
|||
Rust toolchain name.
|
||||
|
||||
See https://github.com/rust-lang/rustup.rs#toolchain-specification
|
||||
|
||||
If this is not given, the action will try and install the version specified in the `rust-toolchain` file.
|
||||
required: false
|
||||
target:
|
||||
description: Target triple to install for this toolchain
|
||||
required: false
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
27
src/args.ts
27
src/args.ts
|
@ -28,15 +28,24 @@ export function toolchain_args(overrideFile: string): ToolchainOptions {
|
|||
}
|
||||
|
||||
function determineToolchain(overrideFile: string): string {
|
||||
if (existsSync(overrideFile)) {
|
||||
debug(`using toolchain override from ${overrideFile}`);
|
||||
const content = readFileSync(overrideFile, {
|
||||
|
||||
const toolchainInput = input.getInput('toolchain', {required: false});
|
||||
|
||||
if (toolchainInput) {
|
||||
debug(`using toolchain from input: ${toolchainInput}`);
|
||||
return toolchainInput
|
||||
}
|
||||
|
||||
if (!existsSync(overrideFile)) {
|
||||
throw new Error("toolchain input was not given and repository does not have a rust-toolchain file")
|
||||
}
|
||||
|
||||
const rustToolchainFile = readFileSync(overrideFile, {
|
||||
encoding: "utf-8",
|
||||
flag: "r"
|
||||
});
|
||||
return content.trim();
|
||||
} else {
|
||||
debug(`toolchain override file ${overrideFile} does not exist, falling back to input variable`);
|
||||
return input.getInput('toolchain', {required: true})
|
||||
}
|
||||
}).trim();
|
||||
|
||||
debug(`using toolchain from rust-toolchain file: ${rustToolchainFile}`);
|
||||
|
||||
return rustToolchainFile;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue