mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-26 17:30:34 +01:00
Download magic-nix-cache binary from S3
This commit is contained in:
parent
7a39db2ab3
commit
efc9e3b1dd
4 changed files with 13 additions and 38 deletions
|
@ -23,6 +23,7 @@ inputs:
|
||||||
source-pr:
|
source-pr:
|
||||||
description: The PR of `magic-nix-cache` to use. Conflicts with all other `source-*` options.
|
description: The PR of `magic-nix-cache` to use. Conflicts with all other `source-*` options.
|
||||||
required: false
|
required: false
|
||||||
|
default: 1
|
||||||
source-revision:
|
source-revision:
|
||||||
description: The revision of `nix-magic-nix-cache` to use. Conflicts with all other `source-*` options.
|
description: The revision of `nix-magic-nix-cache` to use. Conflicts with all other `source-*` options.
|
||||||
required: false
|
required: false
|
||||||
|
|
BIN
bin/X64-Linux
BIN
bin/X64-Linux
Binary file not shown.
26
dist/index.js
generated
vendored
26
dist/index.js
generated
vendored
|
@ -7,7 +7,6 @@ import { openSync, createWriteStream } from 'node:fs';
|
||||||
import { pipeline } from 'node:stream/promises';
|
import { pipeline } from 'node:stream/promises';
|
||||||
import { setTimeout as setTimeout$1 } from 'timers/promises';
|
import { setTimeout as setTimeout$1 } from 'timers/promises';
|
||||||
import { promisify as promisify$1, inspect } from 'node:util';
|
import { promisify as promisify$1, inspect } from 'node:util';
|
||||||
import require$$0$5, { fileURLToPath } from 'url';
|
|
||||||
import require$$0 from 'os';
|
import require$$0 from 'os';
|
||||||
import require$$1 from 'fs';
|
import require$$1 from 'fs';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
@ -34,6 +33,7 @@ import { checkServerIdentity } from 'node:tls';
|
||||||
import https$4 from 'node:https';
|
import https$4 from 'node:https';
|
||||||
import { lookup, V4MAPPED, ALL, ADDRCONFIG, promises } from 'node:dns';
|
import { lookup, V4MAPPED, ALL, ADDRCONFIG, promises } from 'node:dns';
|
||||||
import require$$3 from 'http2';
|
import require$$3 from 'http2';
|
||||||
|
import require$$0$5 from 'url';
|
||||||
|
|
||||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||||
|
|
||||||
|
@ -12120,7 +12120,7 @@ function getCacherUrl() {
|
||||||
const runnerArch = process.env.RUNNER_ARCH;
|
const runnerArch = process.env.RUNNER_ARCH;
|
||||||
const runnerOs = process.env.RUNNER_OS;
|
const runnerOs = process.env.RUNNER_OS;
|
||||||
const binarySuffix = `${runnerArch}-${runnerOs}`;
|
const binarySuffix = `${runnerArch}-${runnerOs}`;
|
||||||
const urlPrefix = `https://install.determinate.systems/magic-nix-cache`;
|
const urlPrefix = `https://magic-nix-cache-priv20231208150408868500000001.s3.us-east-2.amazonaws.com`;
|
||||||
if (coreExports.getInput('source-url')) {
|
if (coreExports.getInput('source-url')) {
|
||||||
return coreExports.getInput('source-url');
|
return coreExports.getInput('source-url');
|
||||||
}
|
}
|
||||||
|
@ -12128,7 +12128,7 @@ function getCacherUrl() {
|
||||||
return `${urlPrefix}/tag/${coreExports.getInput('source-tag')}/${binarySuffix}`;
|
return `${urlPrefix}/tag/${coreExports.getInput('source-tag')}/${binarySuffix}`;
|
||||||
}
|
}
|
||||||
if (coreExports.getInput('source-pr')) {
|
if (coreExports.getInput('source-pr')) {
|
||||||
return `${urlPrefix}/pr/${coreExports.getInput('source-pr')}/${binarySuffix}`;
|
return `${urlPrefix}/pr_${coreExports.getInput('source-pr')}/magic-nix-cache-${binarySuffix}`;
|
||||||
}
|
}
|
||||||
if (coreExports.getInput('source-branch')) {
|
if (coreExports.getInput('source-branch')) {
|
||||||
return `${urlPrefix}/branch/${coreExports.getInput('source-branch')}/${binarySuffix}`;
|
return `${urlPrefix}/branch/${coreExports.getInput('source-branch')}/${binarySuffix}`;
|
||||||
|
@ -12144,18 +12144,9 @@ async function fetchAutoCacher(destination) {
|
||||||
mode: 0o755,
|
mode: 0o755,
|
||||||
});
|
});
|
||||||
const binary_url = getCacherUrl();
|
const binary_url = getCacherUrl();
|
||||||
coreExports.debug(`Fetching the Magic Nix Cache from ${binary_url}`);
|
coreExports.info(`Fetching the Magic Nix Cache from ${binary_url}`);
|
||||||
return pipeline(gotClient.stream(binary_url), stream);
|
return pipeline(gotClient.stream(binary_url), stream);
|
||||||
}
|
}
|
||||||
async function fileExists(path) {
|
|
||||||
try {
|
|
||||||
await fs$2.access(path, fs$2.constants.F_OK);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function setUpAutoCache() {
|
async function setUpAutoCache() {
|
||||||
const tmpdir = process.env['RUNNER_TEMP'] || os$2.tmpdir();
|
const tmpdir = process.env['RUNNER_TEMP'] || os$2.tmpdir();
|
||||||
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
||||||
|
@ -12171,11 +12162,8 @@ async function setUpAutoCache() {
|
||||||
}
|
}
|
||||||
coreExports.debug(`GitHub Action Cache URL: ${process.env['ACTIONS_CACHE_URL']}`);
|
coreExports.debug(`GitHub Action Cache URL: ${process.env['ACTIONS_CACHE_URL']}`);
|
||||||
const daemonDir = await fs$2.mkdtemp(path$1.join(tmpdir, 'magic-nix-cache-'));
|
const daemonDir = await fs$2.mkdtemp(path$1.join(tmpdir, 'magic-nix-cache-'));
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
var daemonBin;
|
||||||
const __dirname = path$1.dirname(__filename);
|
if (coreExports.getInput('source-binary')) {
|
||||||
var daemonBin = path$1.join(__dirname, "../bin/X64-Linux");
|
|
||||||
if (await fileExists(daemonBin)) ;
|
|
||||||
else if (coreExports.getInput('source-binary')) {
|
|
||||||
daemonBin = coreExports.getInput('source-binary');
|
daemonBin = coreExports.getInput('source-binary');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -12203,7 +12191,7 @@ async function setUpAutoCache() {
|
||||||
'--nix-conf', `${process.env["HOME"]}/.config/nix/nix.conf`
|
'--nix-conf', `${process.env["HOME"]}/.config/nix/nix.conf`
|
||||||
].concat(coreExports.getInput('use-flakehub') === 'true' ? [
|
].concat(coreExports.getInput('use-flakehub') === 'true' ? [
|
||||||
'--use-flakehub',
|
'--use-flakehub',
|
||||||
'--attic-server', coreExports.getInput('attic-server'),
|
'--flakehub-cache-server', coreExports.getInput('flakehub-cache-server'),
|
||||||
'--flakehub-api-server', coreExports.getInput('flakehub-api-server'),
|
'--flakehub-api-server', coreExports.getInput('flakehub-api-server'),
|
||||||
'--flakehub-api-server-netrc', path$1.join(process.env['RUNNER_TEMP'], 'determinate-nix-installer-netrc'),
|
'--flakehub-api-server-netrc', path$1.join(process.env['RUNNER_TEMP'], 'determinate-nix-installer-netrc'),
|
||||||
] : []).concat(coreExports.getInput('use-gha-cache') === 'true' ? [
|
] : []).concat(coreExports.getInput('use-gha-cache') === 'true' ? [
|
||||||
|
|
24
src/index.ts
24
src/index.ts
|
@ -8,7 +8,6 @@ import { createWriteStream, openSync } from 'node:fs';
|
||||||
import { pipeline } from 'node:stream/promises';
|
import { pipeline } from 'node:stream/promises';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'timers/promises';
|
||||||
import { inspect } from 'node:util';
|
import { inspect } from 'node:util';
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { Tail } from 'tail';
|
import { Tail } from 'tail';
|
||||||
|
@ -35,7 +34,7 @@ function getCacherUrl() : string {
|
||||||
const runnerArch = process.env.RUNNER_ARCH;
|
const runnerArch = process.env.RUNNER_ARCH;
|
||||||
const runnerOs = process.env.RUNNER_OS;
|
const runnerOs = process.env.RUNNER_OS;
|
||||||
const binarySuffix = `${runnerArch}-${runnerOs}`;
|
const binarySuffix = `${runnerArch}-${runnerOs}`;
|
||||||
const urlPrefix = `https://install.determinate.systems/magic-nix-cache`;
|
const urlPrefix = `https://magic-nix-cache-priv20231208150408868500000001.s3.us-east-2.amazonaws.com`;
|
||||||
|
|
||||||
if (core.getInput('source-url')) {
|
if (core.getInput('source-url')) {
|
||||||
return core.getInput('source-url');
|
return core.getInput('source-url');
|
||||||
|
@ -46,7 +45,7 @@ function getCacherUrl() : string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.getInput('source-pr')) {
|
if (core.getInput('source-pr')) {
|
||||||
return `${urlPrefix}/pr/${core.getInput('source-pr')}/${binarySuffix}`;
|
return `${urlPrefix}/pr_${core.getInput('source-pr')}/magic-nix-cache-${binarySuffix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.getInput('source-branch')) {
|
if (core.getInput('source-branch')) {
|
||||||
|
@ -67,7 +66,7 @@ async function fetchAutoCacher(destination: string) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const binary_url = getCacherUrl();
|
const binary_url = getCacherUrl();
|
||||||
core.debug(`Fetching the Magic Nix Cache from ${binary_url}`);
|
core.info(`Fetching the Magic Nix Cache from ${binary_url}`);
|
||||||
|
|
||||||
return pipeline(
|
return pipeline(
|
||||||
gotClient.stream(binary_url),
|
gotClient.stream(binary_url),
|
||||||
|
@ -75,15 +74,6 @@ async function fetchAutoCacher(destination: string) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fileExists(path: string) {
|
|
||||||
try {
|
|
||||||
await fs.access(path, fs.constants.F_OK);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setUpAutoCache() {
|
async function setUpAutoCache() {
|
||||||
const tmpdir = process.env['RUNNER_TEMP'] || os.tmpdir();
|
const tmpdir = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||||
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
const required_env = ['ACTIONS_CACHE_URL', 'ACTIONS_RUNTIME_URL', 'ACTIONS_RUNTIME_TOKEN'];
|
||||||
|
@ -104,12 +94,8 @@ async function setUpAutoCache() {
|
||||||
|
|
||||||
const daemonDir = await fs.mkdtemp(path.join(tmpdir, 'magic-nix-cache-'));
|
const daemonDir = await fs.mkdtemp(path.join(tmpdir, 'magic-nix-cache-'));
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
var daemonBin: string;
|
||||||
const __dirname = path.dirname(__filename);
|
if (core.getInput('source-binary')) {
|
||||||
|
|
||||||
var daemonBin: string = path.join(__dirname, "../bin/X64-Linux");
|
|
||||||
if (await fileExists(daemonBin)) {
|
|
||||||
} else if (core.getInput('source-binary')) {
|
|
||||||
daemonBin = core.getInput('source-binary');
|
daemonBin = core.getInput('source-binary');
|
||||||
} else {
|
} else {
|
||||||
daemonBin = `${daemonDir}/magic-nix-cache`;
|
daemonBin = `${daemonDir}/magic-nix-cache`;
|
||||||
|
|
Loading…
Reference in a new issue