test on more linuxes (#164)

This commit is contained in:
Max Howell 2022-09-29 12:07:07 -04:00 committed by GitHub
parent 56467c884b
commit 4f62062548
4 changed files with 89 additions and 79 deletions

View file

@ -31,9 +31,6 @@ jobs:
image: ghcr.io/teaxyz/infuser:main
options: --memory=16g
container: ${{ matrix.container }}
defaults:
run:
working-directory: pantry
outputs:
built: ${{ steps.build.outputs.pkgs }}
pkgs: ${{ steps.sorted.outputs.pkgs }} ${{ steps.sorted.outputs.pre-install }}
@ -50,22 +47,16 @@ jobs:
repository: teaxyz/cli
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- run: #FIXME **we provide curl** but it fails due to certificate errors
apt --yes install curl
if: ${{ matrix.os == 'ubuntu-latest' }}
- uses: teaxyz/setup@v0
id: tea
with:
srcroot: pantry
prefix: /opt
- name: HACKS
run: |
case ${{ matrix.os }} in
ubuntu-latest)
# no git in our image, needed for tea finding SRCROOT
mkdir .git ../cli/.git
#FIXME needed for gdk-pixbuf
apt --yes install shared-mime-info
;;
@ -84,14 +75,12 @@ jobs:
rm -rf /opt/tea.xyz/var
ln -s $GITHUB_WORKSPACE /opt/tea.xyz/var
touch /opt/.hack
- run: scripts/sort.ts ${{ inputs.projects }}
- run: pantry/scripts/sort.ts ${{ inputs.projects }}
id: sorted
- run: ../cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
- run: scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
- run: pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
id: build
env:
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
@ -99,14 +88,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
# /ref https://github.com/actions/upload-artifact/issues/38
- run: tar czf $GITHUB_WORKSPACE/artifacts.tgz ${{ steps.build.outputs.relative-paths }}
working-directory: ${{ steps.tea.outputs.prefix }}
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: |
${{ steps.build.outputs.paths }}
${{ steps.tea.outputs.prefix }}/.hack
# ^^ so the uploaded artifacts keep eg. foo.com/v1.2.3 as prefixes
path: artifacts.tgz
if-no-files-found: error
test:
@ -114,12 +105,17 @@ jobs:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: tea.xyz/var/pantry
working-directory: tea.xyz/var/pantry/scripts
strategy:
matrix:
os:
- macos-11
- ubuntu-latest
include:
- os: macos-11
- os: ubuntu-latest
- os: ubuntu-latest
container: ghcr.io/teaxyz/infuser:main
- os: ubuntu-latest
container: debian:buster-slim
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
with:
@ -135,18 +131,21 @@ jobs:
id: tea
with:
prefix: ${{ github.workspace }}
srcroot: tea.xyz/var/pantry
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.os }}
path: ${{ steps.tea.outputs.prefix }}
- run: echo ${{ inputs.projects }} | xargs -tn1 scripts/test.ts
- run: tar xzf artifacts.tgz
working-directory: ${{ steps.tea.outputs.prefix }}
- run: ./test.ts ${{ inputs.projects }}
bottle:
defaults:
run:
working-directory: tea.xyz/var/pantry
working-directory: tea.xyz/var/pantry/scripts
needs: [test, build]
runs-on: ${{ matrix.platform }}
strategy:
@ -172,20 +171,24 @@ jobs:
id: tea
with:
prefix: ${{ github.workspace }}
srcroot: tea.xyz/var/pantry
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.platform }}
path: ${{ steps.tea.outputs.prefix }}
- run: scripts/bottle.ts ${{ needs.build.outputs.built }}
- run: tar xzf artifacts.tgz
working-directory: ${{ steps.tea.outputs.prefix }}
- run: ./bottle.ts ${{ needs.build.outputs.built }}
id: bottle
env:
COMPRESSION: ${{ matrix.compression }}
- name: upload bottles
id: upload
run: scripts/upload.ts
run: ./upload.ts
--pkgs ${{ needs.build.outputs.built }}
--bottles ${{ steps.bottle.outputs.bottles }}
--checksums ${{ steps.bottle.outputs.checksums }}

View file

@ -1,5 +1,5 @@
distributable:
url: https://curl.se/download/curl-{{ version }}.tar.bz2
url: https://curl.se/download/curl-{{version}}.tar.bz2
strip-components: 1
versions:

View file

@ -51,3 +51,4 @@ for (const rq of dry) {
await set_output("pkgs", rv.map(x => pkgutils.str(x.pkg)))
await set_output("paths", rv.map(x => x.path), '%0A')
await set_output("relative-paths", rv.map(x => x.path.relative({ to: usePrefix() })))

View file

@ -12,7 +12,7 @@ args:
- --import-map={{ srcroot }}/import-map.json
---*/
import { Package, PackageRequirement } from "types"
import { Installation, Package, PackageRequirement } from "types"
import { usePantry, useCellar, useFlags } from "hooks"
import useShellEnv, { expand } from "hooks/useShellEnv.ts"
import { run, undent, pkg as pkgutils } from "utils"
@ -23,58 +23,64 @@ const { debug } = useFlags()
const cellar = useCellar()
const pantry = usePantry()
const self = await (async () => {
const project = Deno.args[0]
const match = project.match(/projects\/(.+)\/package.yml/)
const parsable = match ? match[1] : project
const pkg = pkgutils.parse(parsable)
return await cellar.resolve(pkg)
})()
for (const project of Deno.args) {
const pkg = await (async () => {
const match = project.match(/projects\/(.+)\/package.yml/)
const parsable = match ? match[1] : project
const pkg = pkgutils.parse(parsable)
return await cellar.resolve(pkg)
})()
const yml = await pantry.getYAML(self.pkg).parse()
const deps = await deps4(self.pkg)
const installations = await prepare(deps)
const env = useShellEnv([self, ...installations])
let text = undent`
#!/bin/bash
set -e
set -o pipefail
set -x
${expand(env.vars)}
`
const tmp = Path.mktmp({ prefix: pkgutils.str(self.pkg) })
try {
if (yml.test.fixture) {
const fixture = tmp.join("fixture.tea").write({ text: yml.test.fixture.toString() })
text += `export FIXTURE="${fixture}"\n\n`
}
const cwd = tmp.join("wd").mkdir()
text += `cd "${cwd}"\n\n`
text += await pantry.getScript(self.pkg, 'test', installations)
text += "\n"
for await (const [path, {name, isFile}] of pantry.getYAML(self.pkg).path.parent().ls()) {
if (isFile && name != 'package.yml') path.cp({ into: cwd })
}
const cmd = tmp
.join("test.sh")
.write({ text, force: true })
.chmod(0o500)
await run({ cmd, cwd })
} finally {
if (!debug) tmp.rm({ recursive: true })
await test(pkg)
}
async function test(self: Installation) {
const yml = await pantry.getYAML(self.pkg).parse()
const deps = await deps4(self.pkg)
const installations = await prepare(deps)
const env = useShellEnv([self, ...installations])
let text = undent`
#!/bin/bash
set -e
set -o pipefail
set -x
${expand(env.vars)}
`
const tmp = Path.mktmp({ prefix: pkgutils.str(self.pkg) })
try {
if (yml.test.fixture) {
const fixture = tmp.join("fixture.tea").write({ text: yml.test.fixture.toString() })
text += `export FIXTURE="${fixture}"\n\n`
}
const cwd = tmp.join("wd").mkdir()
text += `cd "${cwd}"\n\n`
text += await pantry.getScript(self.pkg, 'test', installations)
text += "\n"
for await (const [path, {name, isFile}] of pantry.getYAML(self.pkg).path.parent().ls()) {
if (isFile && name != 'package.yml') path.cp({ into: cwd })
}
const cmd = tmp
.join("test.sh")
.write({ text, force: true })
.chmod(0o500)
await run({ cmd, cwd })
} finally {
if (!debug) tmp.rm({ recursive: true })
}
}
//TODO install step in CI should do this for test requirements also
async function prepare(reqs: (Package | PackageRequirement)[]) {
const { pending, installed } = await resolve(reqs)