Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 11, 2023
1 parent d9aebf2 commit 82152eb
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/scripts/get-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { hooks, utils } from "pkgx"
import { isString, isArray } from "is-what"

const pkg = utils.pkg.parse(Deno.args[0])
const config = await get_config(pkg)

const rv = {} as Record<string, any>
for (const platform of await get_platforms(pkg)) {
for (const platform of config.platforms) {
const key = platform.replace('/', '+')
rv[key] = get_matrix(platform)
}
Expand All @@ -23,18 +24,27 @@ if (ghout) {
///////////////////////////////////////////////////////////////////////

//TODO should be in libpkgx!
async function get_platforms(pkg: {project: string}) {
let { platforms } = await hooks.usePantry().project(pkg).yaml()
if (!platforms) return ["linux/x86-64", "linux/aarch64", "darwin/x86-64", "darwin/aarch64"]
if (isString(platforms)) platforms = [platforms]
if (!isArray(platforms)) throw new Error(`invalid platform node: ${platforms}`)
const rv = []
for (const platform of platforms) {
if (platform.match(/^(linux|darwin)\/(aarch64|x86-64)$/)) rv.push(platform)
else if (platform.match(/^(linux|darwin)$/)) rv.push(`${platform}/x86-64`, `${platform}/aarch64`)
else throw new Error(`invalid platform: ${platform}`)
async function get_config(pkg: {project: string}) {
let { platforms, test } = await hooks.usePantry().project(pkg).yaml()
const get_platforms = (() => {
if (!platforms) return ["linux/x86-64", "linux/aarch64", "darwin/x86-64", "darwin/aarch64"]
if (isString(platforms)) platforms = [platforms]
if (!isArray(platforms)) throw new Error(`invalid platform node: ${platforms}`)
const rv = []
for (const platform of platforms) {
if (platform.match(/^(linux|darwin)\/(aarch64|x86-64)$/)) rv.push(platform)
else if (platform.match(/^(linux|darwin)$/)) rv.push(`${platform}/x86-64`, `${platform}/aarch64`)
else throw new Error(`invalid platform: ${platform}`)
}
return rv
})

const qaRequired = test?.["qa-required"] === true

return {
platforms: get_platforms(),
qaRequired
}
return rv
}

function get_matrix(platform: string) {
Expand Down

0 comments on commit 82152eb

Please sign in to comment.