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:
svartalf 2019-09-14 23:55:34 +03:00
parent 363c0a8f33
commit b08fe239f7
2 changed files with 20 additions and 1 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,6 @@
const os = require('os');
const process = require('process');
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as io from '@actions/io'; import * as io from '@actions/io';
@ -13,6 +16,19 @@ async function getCross(): Promise<string> {
core.debug('Unable to find cross, installing it now'); 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 { try {
core.startGroup('Install cross'); core.startGroup('Install cross');
core.warning('Git version of cross will be installed, \ 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); core.setFailed(error.message);
throw new Error(error); throw new Error(error);
} finally { } finally {
// It is important to chdir back!
process.chdir(cwd);
core.endGroup(); core.endGroup();
} }
@ -56,6 +74,7 @@ async function run() {
await exec.exec(program, args); await exec.exec(program, args);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
throw error;
} }
} }