Don’t use sort.ts in CI to pre-install

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.
This commit is contained in:
Max Howell 2022-11-09 11:22:10 -05:00
parent 2bb2229be6
commit 8a59338e83
Failed to extract signature
3 changed files with 32 additions and 30 deletions

View file

@ -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.

View file

@ -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 })))

View file

@ -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 dont 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 {