diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5bf051..11d456f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,18 +48,35 @@ jobs: run: | .github/workflows/cache-test.sh - # run-x86_64-darwin: - # name: Run x86_64 Darwin - # runs-on: macos-12 - # steps: - # - uses: actions/checkout@v3 - # - name: Install Nix - # uses: DeterminateSystems/nix-installer-action@main - # with: - # extra-conf: | - # narinfo-cache-negative-ttl = 0 - # - name: Cache the store - # uses: ./ - # - name: Check the cache for liveness - # run: | - # .github/workflows/cache-test.sh + run-x86_64-darwin: + name: Run x86_64 Darwin + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + narinfo-cache-negative-ttl = 0 + - name: Cache the store + uses: ./ + - name: Check the cache for liveness + run: | + .github/workflows/cache-test.sh + + run-aarch64-darwin: + name: Run aarch64 Darwin + concurrency: build-ARM64-macOS + runs-on: macos-latest-xlarge + steps: + - uses: actions/checkout@v3 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + narinfo-cache-negative-ttl = 0 + - name: Cache the store + uses: ./ + - name: Check the cache for liveness + run: | + .github/workflows/cache-test.sh diff --git a/action.yml b/action.yml index 49bf257..c2a9647 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ inputs: source-pr: description: The PR of `magic-nix-cache` to use. Conflicts with all other `source-*` options. required: false - default: 3 + default: 8 source-revision: description: The revision of `nix-magic-nix-cache` to use. Conflicts with all other `source-*` options. required: false diff --git a/dist/index.js b/dist/index.js index 9fe91b1..798ea7a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2,9 +2,8 @@ import * as fs$2 from 'node:fs/promises'; import * as os$2 from 'node:os'; import os__default from 'node:os'; import * as path$1 from 'node:path'; -import { spawn } from 'node:child_process'; -import { openSync, createWriteStream } from 'node:fs'; -import { pipeline } from 'node:stream/promises'; +import { spawn, exec } from 'node:child_process'; +import { openSync } from 'node:fs'; import { setTimeout as setTimeout$1 } from 'timers/promises'; import { promisify as promisify$1, inspect } from 'node:util'; import require$$0 from 'os'; @@ -12138,14 +12137,14 @@ function getCacherUrl() { } return `${urlPrefix}/latest/${binarySuffix}`; } -async function fetchAutoCacher(destination) { - const stream = createWriteStream(destination, { - encoding: "binary", - mode: 0o755, - }); +async function fetchAutoCacher() { const binary_url = getCacherUrl(); coreExports.info(`Fetching the Magic Nix Cache from ${binary_url}`); - return pipeline(gotClient.stream(binary_url), stream); + const { stdout } = await promisify$1(exec)(`curl "${binary_url}" | xz -d | nix-store --import`); + const paths = stdout.split(os$2.EOL); + // Since the export is in reverse topologically sorted order, magic-nix-cache is always the penultimate entry in the list (the empty string left by split being the last). + const last_path = paths.at(-2); + return `${last_path}/bin/magic-nix-cache`; } async function setUpAutoCache() { const tmpdir = process.env['RUNNER_TEMP'] || os$2.tmpdir(); @@ -12167,8 +12166,7 @@ async function setUpAutoCache() { daemonBin = coreExports.getInput('source-binary'); } else { - daemonBin = `${daemonDir}/magic-nix-cache`; - await fetchAutoCacher(daemonBin); + daemonBin = await fetchAutoCacher(); } var runEnv; if (coreExports.isDebug()) { diff --git a/src/index.ts b/src/index.ts index 79ade61..4542dab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,11 +3,10 @@ import * as fs from 'node:fs/promises'; import * as os from 'node:os'; import * as path from 'node:path'; -import { spawn } from 'node:child_process'; -import { createWriteStream, openSync } from 'node:fs'; -import { pipeline } from 'node:stream/promises'; +import { spawn, exec } from 'node:child_process'; +import { openSync } from 'node:fs'; import { setTimeout } from 'timers/promises'; -import { inspect } from 'node:util'; +import { inspect, promisify } from 'node:util'; import * as core from '@actions/core'; import { Tail } from 'tail'; @@ -59,19 +58,18 @@ function getCacherUrl() : string { return `${urlPrefix}/latest/${binarySuffix}`; } -async function fetchAutoCacher(destination: string) { - const stream = createWriteStream(destination, { - encoding: "binary", - mode: 0o755, - }); - +async function fetchAutoCacher() { const binary_url = getCacherUrl(); core.info(`Fetching the Magic Nix Cache from ${binary_url}`); - return pipeline( - gotClient.stream(binary_url), - stream - ); + const { stdout } = await promisify(exec)(`curl "${binary_url}" | xz -d | nix-store --import`); + + const paths = stdout.split(os.EOL); + + // Since the export is in reverse topologically sorted order, magic-nix-cache is always the penultimate entry in the list (the empty string left by split being the last). + const last_path = paths.at(-2); + + return `${last_path}/bin/magic-nix-cache`; } async function setUpAutoCache() { @@ -98,8 +96,7 @@ async function setUpAutoCache() { if (core.getInput('source-binary')) { daemonBin = core.getInput('source-binary'); } else { - daemonBin = `${daemonDir}/magic-nix-cache`; - await fetchAutoCacher(daemonBin); + daemonBin = await fetchAutoCacher(); } var runEnv;