mirror of
https://github.com/ivabus/pantry
synced 2024-11-30 04:05:06 +03:00
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:
parent
2bb2229be6
commit
8a59338e83
3 changed files with 32 additions and 30 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -73,10 +73,8 @@ jobs:
|
||||||
- run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }}
|
- run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }}
|
||||||
id: sorted
|
id: sorted
|
||||||
|
|
||||||
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
|
|
||||||
|
|
||||||
# running out of /opt because only pantry.core has these scripts
|
# 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
|
id: build
|
||||||
env:
|
env:
|
||||||
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
|
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#!/usr/bin/env -S tea -E
|
#!/usr/bin/env -S tea -E
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
|
dependencies:
|
||||||
|
gnu.org/tar: 1
|
||||||
|
tukaani.org/xz: 5
|
||||||
|
sourceware.org/bzip2: 1
|
||||||
args:
|
args:
|
||||||
- deno
|
- deno
|
||||||
- run
|
- run
|
||||||
|
@ -13,34 +17,43 @@ args:
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --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 { hydrate, install, link } from "prefab"
|
||||||
import { str as pkgstr } from "utils/pkg.ts"
|
import { str as pkgstr } from "utils/pkg.ts"
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
import { panic } from "utils/error.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()
|
useFlags()
|
||||||
|
|
||||||
const pantry = usePantry()
|
const pantry = usePantry()
|
||||||
const cellar = useCellar()
|
const cellar = useCellar()
|
||||||
const inventory = useInventory()
|
const inventory = useInventory()
|
||||||
const dry = await ARGV.toArray(ARGV.pkgs())
|
const raw = 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
|
|
||||||
})
|
|
||||||
|
|
||||||
for (const pkg of wet.wet) {
|
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)) {
|
if (!await cellar.has(pkg)) {
|
||||||
const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`)
|
const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`)
|
||||||
const installation = await install({ project: pkg.project, version })
|
const installation = await install({ project: pkg.project, version })
|
||||||
await link(installation)
|
await link(installation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const rq of dry) {
|
|
||||||
const pkg = await pantry.resolve(rq)
|
const pkg = await pantry.resolve(rq)
|
||||||
await build(pkg)
|
rv.push(await build(pkg))
|
||||||
await link(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 })))
|
||||||
|
|
|
@ -16,8 +16,8 @@ args:
|
||||||
import { pkg } from "utils"
|
import { pkg } from "utils"
|
||||||
import { usePantry, useFlags } from "hooks"
|
import { usePantry, useFlags } from "hooks"
|
||||||
import { hydrate } from "prefab"
|
import { hydrate } from "prefab"
|
||||||
import { PackageRequirement } from "types"
|
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
|
import { set_output } from "./utils/gha.ts";
|
||||||
|
|
||||||
const flags = useFlags()
|
const flags = useFlags()
|
||||||
const pantry = usePantry()
|
const pantry = usePantry()
|
||||||
|
@ -30,18 +30,9 @@ const wet = await hydrate(dry, async (pkg, dry) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (Deno.env.get("GITHUB_ACTIONS")) {
|
if (Deno.env.get("GITHUB_ACTIONS")) {
|
||||||
const massage = (input: PackageRequirement[]) =>
|
await set_output('pkgs', wet.dry.map(pkg.str))
|
||||||
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)}`)
|
|
||||||
} else {
|
} else {
|
||||||
const gas = wet.dry.map(x => pkg.str(x))
|
const gas = wet.dry.map(pkg.str)
|
||||||
if (flags.json) {
|
if (flags.json) {
|
||||||
console.log(gas)
|
console.log(gas)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue