Add restore cache.

This commit is contained in:
Miles Johnson 2023-04-17 13:55:27 -07:00
parent f6bb205e1d
commit 7b19c2c567
7 changed files with 355 additions and 21 deletions

View file

@ -1,10 +1,10 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import TOML from '@ltd/j-toml';
import { CARGO_HOME } from './helpers';
interface Toolchain {
channel: string;
@ -24,14 +24,6 @@ const DEFAULT_TOOLCHAIN: Toolchain = {
targets: [],
};
function getCargoHome(): string {
if (process.env.CARGO_HOME) {
return process.env.CARGO_HOME;
}
return path.join(os.homedir(), '.cargo');
}
function parseConfig(configPath: string): Partial<Toolchain> {
const contents = fs.readFileSync(configPath, 'utf8').trim();
@ -184,7 +176,7 @@ async function installBins() {
core.info('Installing additional binaries');
const binDir = path.join(getCargoHome(), 'bin');
const binDir = path.join(CARGO_HOME, 'bin');
if (!fs.existsSync(path.join(binDir, 'cargo-binstall'))) {
await downloadAndInstallBinstall(binDir);
@ -213,7 +205,7 @@ async function run() {
core.info('Adding ~/.cargo/bin to PATH');
core.addPath(path.join(getCargoHome(), 'bin'));
core.addPath(path.join(CARGO_HOME, 'bin'));
}
void run();