mirror of
https://github.com/actions-rs/cargo.git
synced 2024-11-13 04:56:32 +02:00
Using system Rust to install cross.
As the cross requires recent enough Rust and cwd might be overriden to use old one toolchain, switching cwd temporary to install cross.
This commit is contained in:
parent
363c0a8f33
commit
b08fe239f7
2 changed files with 20 additions and 1 deletions
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
19
src/main.ts
19
src/main.ts
|
@ -1,3 +1,6 @@
|
|||
const os = require('os');
|
||||
const process = require('process');
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
|
@ -13,6 +16,19 @@ async function getCross(): Promise<string> {
|
|||
core.debug('Unable to find cross, installing it now');
|
||||
}
|
||||
|
||||
// Somewhat new Rust is required to compile `cross`
|
||||
// (TODO: Not sure what version exactly, should clarify)
|
||||
// but if some action will set an override toolchain before this action called
|
||||
// (ex. `@actions-rs/toolchain` with `toolchain: 1.31.0`)
|
||||
// `cross` compilation will fail.
|
||||
//
|
||||
// In order to skip this problem and install `cross` globally
|
||||
// using the pre-installed system Rust,
|
||||
// we are going to jump to the tmpdir (skipping directory override that way)
|
||||
// install `cross` from there and then jump back.
|
||||
|
||||
const cwd = process.cwd();
|
||||
process.chdir(os.tmpdir());
|
||||
try {
|
||||
core.startGroup('Install cross');
|
||||
core.warning('Git version of cross will be installed, \
|
||||
|
@ -28,6 +44,8 @@ see https://github.com/actions-rs/cargo/issues/1');
|
|||
core.setFailed(error.message);
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
// It is important to chdir back!
|
||||
process.chdir(cwd);
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
|
@ -56,6 +74,7 @@ async function run() {
|
|||
await exec.exec(program, args);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue