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/),
|
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).
|
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
|
### Added
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,16 @@ describe('actions-rs/toolchain', () => {
|
||||||
'INPUT_TOOLCHAIN': 'nightly',
|
'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")
|
expect(args.name).toBe("1.39.0")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,9 +58,7 @@ describe('actions-rs/toolchain', () => {
|
||||||
|
|
||||||
let args = morph(() => {
|
let args = morph(() => {
|
||||||
return toolchain_args(rustToolchainFile);
|
return toolchain_args(rustToolchainFile);
|
||||||
}, {
|
}, {});
|
||||||
'INPUT_TOOLCHAIN': 'nightly',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(args.name).toBe("1.39.0")
|
expect(args.name).toBe("1.39.0")
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,9 @@ inputs:
|
||||||
Rust toolchain name.
|
Rust toolchain name.
|
||||||
|
|
||||||
See https://github.com/rust-lang/rustup.rs#toolchain-specification
|
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:
|
target:
|
||||||
description: Target triple to install for this toolchain
|
description: Target triple to install for this toolchain
|
||||||
required: false
|
required: false
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
29
src/args.ts
29
src/args.ts
|
@ -28,15 +28,24 @@ export function toolchain_args(overrideFile: string): ToolchainOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineToolchain(overrideFile: string): string {
|
function determineToolchain(overrideFile: string): string {
|
||||||
if (existsSync(overrideFile)) {
|
|
||||||
debug(`using toolchain override from ${overrideFile}`);
|
const toolchainInput = input.getInput('toolchain', {required: false});
|
||||||
const content = readFileSync(overrideFile, {
|
|
||||||
encoding: "utf-8",
|
if (toolchainInput) {
|
||||||
flag: "r"
|
debug(`using toolchain from input: ${toolchainInput}`);
|
||||||
});
|
return toolchainInput
|
||||||
return content.trim();
|
|
||||||
} else {
|
|
||||||
debug(`toolchain override file ${overrideFile} does not exist, falling back to input variable`);
|
|
||||||
return input.getInput('toolchain', {required: true})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}).trim();
|
||||||
|
|
||||||
|
debug(`using toolchain from rust-toolchain file: ${rustToolchainFile}`);
|
||||||
|
|
||||||
|
return rustToolchainFile;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue