From 8a59338e83729aa69efa72c0f6a8e332041517fe Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 9 Nov 2022 11:22:10 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20`sort.ts`=20in=20CI=20to?= =?UTF-8?q?=20pre-install?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `dry` packages end up being constraints for the whole graph which in cyclic situations prevents bootstrapping. Eg. llvm^12 cannot be built because sort insists that it depends on llvm^12 which is not yet bottled. --- .github/workflows/build.yml | 4 +--- scripts/build.ts | 43 ++++++++++++++++++++++++------------- scripts/sort.ts | 15 +++---------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0f07fc8..83820463 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,10 +73,8 @@ jobs: - run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }} id: sorted - - run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }} - # running out of /opt because only pantry.core has these scripts - - run: /opt/tea.xyz/var/pantry/scripts/build.plumbing.ts ${{ steps.sorted.outputs.pkgs }} + - run: /opt/tea.xyz/var/pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }} id: build env: # GITHUB_TOKEN doesn't have private access to teaxyz/cli. diff --git a/scripts/build.ts b/scripts/build.ts index bb2e7d64..232c4f6c 100755 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,6 +1,10 @@ #!/usr/bin/env -S tea -E /*--- +dependencies: + gnu.org/tar: 1 + tukaani.org/xz: 5 + sourceware.org/bzip2: 1 args: - deno - run @@ -13,34 +17,43 @@ args: - --import-map={{ srcroot }}/import-map.json ---*/ -import { usePantry, useFlags, useCellar, useInventory } from "hooks" +import { usePantry, useFlags, useCellar, useInventory, usePrefix } from "hooks" import { hydrate, install, link } from "prefab" import { str as pkgstr } from "utils/pkg.ts" import * as ARGV from "./utils/args.ts" import { panic } from "utils/error.ts" -import build from "./build/build.ts" +import build, { BuildResult } from "./build/build.ts" +import { set_output } from "./utils/gha.ts"; useFlags() const pantry = usePantry() const cellar = useCellar() const inventory = useInventory() -const dry = await ARGV.toArray(ARGV.pkgs()) -const wet = await hydrate(dry, async (pkg, dry) => { - const deps = await pantry.getDeps(pkg) - return dry ? [...deps.build, ...deps.runtime] : deps.runtime -}) +const raw = await ARGV.toArray(ARGV.pkgs()) -for (const pkg of wet.wet) { - if (!await cellar.has(pkg)) { - const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`) - const installation = await install({ project: pkg.project, version }) - await link(installation) +const rv: BuildResult[] = [] + +for (const rq of raw) { + const dry = await pantry.getDeps(rq) + const wet = await hydrate([...dry.runtime, ...dry.build]) + + for (const pkg of wet.pkgs) { + if (!await cellar.has(pkg)) { + const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`) + const installation = await install({ project: pkg.project, version }) + await link(installation) + } } -} -for (const rq of dry) { const pkg = await pantry.resolve(rq) - await build(pkg) + rv.push(await build(pkg)) await link(pkg) } + +const to = usePrefix() +await set_output("pkgs", rv.map(x => pkgstr(x.installation.pkg))) +await set_output("paths", rv.map(x => x.installation.path), '%0A') +await set_output("relative-paths", rv.map(x => x.installation.path.relative({ to }))) +await set_output("srcs", rv.map(x => x.src?.relative({ to }) ?? "~")) +await set_output("srcs-relative-paths", rv.compact(x => x.src?.relative({ to }))) diff --git a/scripts/sort.ts b/scripts/sort.ts index bec06617..56c41422 100755 --- a/scripts/sort.ts +++ b/scripts/sort.ts @@ -16,8 +16,8 @@ args: import { pkg } from "utils" import { usePantry, useFlags } from "hooks" import { hydrate } from "prefab" -import { PackageRequirement } from "types" import * as ARGV from "./utils/args.ts" +import { set_output } from "./utils/gha.ts"; const flags = useFlags() const pantry = usePantry() @@ -30,18 +30,9 @@ const wet = await hydrate(dry, async (pkg, dry) => { }) if (Deno.env.get("GITHUB_ACTIONS")) { - const massage = (input: PackageRequirement[]) => - input.map(p => { - let out = pkg.str(p) - // shell quoting via GHA is weird and we don’t fully understand it - if (/[<>]/.test(out)) out = `"${out}"` - return out - }).join(" ") - - console.log(`::set-output name=pkgs::${massage(wet.dry)}`) - console.log(`::set-output name=pre-install::${massage(wet.wet)}`) + await set_output('pkgs', wet.dry.map(pkg.str)) } else { - const gas = wet.dry.map(x => pkg.str(x)) + const gas = wet.dry.map(pkg.str) if (flags.json) { console.log(gas) } else {