Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gratuitous gardening #306

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/ci.cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ jobs:
- uses: pkgxdev/setup@v2

- name: precache # makes it easier to read the real output
run: | # we have to make symlinks because deno cache doesn’t take a --ext=ts flag
ln -s bin/cmd/build build.ts
ln -s bin/cmd/test test.ts
pkgx deno cache *.ts
rm *.ts
run: pkgx deno cache test/test.ts build/build.ts

- run: bin/bk build ${{matrix.pkg}}
- run: bin/bk test ${{matrix.pkg}}
Expand All @@ -65,8 +61,9 @@ jobs:
PKGX_PANTRY_PATH: null
steps:
- uses: actions/checkout@v4
- uses: pkgxdev/dev@main
- uses: pkgxdev/dev@v0
- run: deno test --allow-env --allow-net --ignore=.data
working-directory: lib

unavailable:
runs-on: ubuntu-latest
Expand Down
7 changes: 3 additions & 4 deletions audit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ runs:
shell: bash
run: |
echo "::group::fetch deno deps"
tmpdir=$(mktemp -d)
ln -s ${GITHUB_ACTION_PATH}/../bin/cmd/audit $tmpdir/audit.ts
pkgx deno cache $tmpdir/audit.ts --config=${GITHUB_ACTION_PATH}/../deno.jsonc
cd $GITHUB_ACTION_PATH
pkgx deno cache ./audit.ts
echo "::endgroup::"

- run: ${GITHUB_ACTION_PATH}/../bin/cmd/audit '${{ inputs.pkg }}'
- run: ${GITHUB_ACTION_PATH}/audit.ts '${{ inputs.pkg }}'
shell: bash
env:
GITHUB_TOKEN: ${{inputs.token}}
File renamed without changes.
12 changes: 7 additions & 5 deletions bin/bk
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ if test "$arg" = "-v" || test "$arg" = "--version"; then
exit 0
fi

if test -x "$d/cmd/$arg"; then
exec "$d/cmd/$arg" "$@"
elif test "$(find "$d/cmd" -name "$arg*" | wc -l)" -eq 1; then
exec "$d"/cmd/"$arg"* "$@"
if test -x "$d/bk-$arg"; then
exec "$d/bk-$arg" "$@"
elif test "$(find "$d" -name "bk-$arg*" | wc -l)" -eq 1; then
exec "$d/bk-$arg"* "$@"
else
echo "error: unknown or ambiguous command \`$arg\`, available commands:" >&2
echo >&2
echo " "$(ls "$d"/cmd) >&2
for x in $(cd "$d" && ls | grep '^bk-'); do
echo $x | sed 's/^bk-//' >&2
done
exit 64
fi
1 change: 1 addition & 0 deletions bin/bk-audit
1 change: 1 addition & 0 deletions bin/bk-build
40 changes: 29 additions & 11 deletions bin/cmd/docker → bin/bk-docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$1" == --help ]; then
echo >&2
echo 'bk docker interactive tty of your pantry checkout' >&2
echo 'bk docker build same as `bk build` but in linux' >&2
echo 'bk docker --x86-64 build builds for intel' >&2
echo 'bk docker --x86-64 build builds for PLATFORM' >&2
exit 0
fi

Expand All @@ -30,37 +30,55 @@ if [ "$1" = --pull ]; then
shift
fi

if [ "$1" = --x86-64 ]; then
INTEL="--platform linux/amd64"
shift
fi
case "$1" in
--x86-64|--amd64)
PLATFORM=linux/amd64
shift;;
--aarch64|--arm64)
PLATFORM=linux/arm64
shift;;
*)
case "$(uname -m)" in
x86_64)
PLATFORM=linux/amd64;;
aarch64|arm64)
PLATFORM=linux/arm64;;
esac;;
esac

if [ -z "$1" ]; then
INTERACTIVE="-it"
CMD="/bin/bash"
else
CMD="/brewkit/bin/cmd/$1"
CMD="/brewkit/bin/bk $1"
shift
fi

VOLUME_NAME="brewkit.pkgx.dev"
SPECIFIER="${PLATFORM//\//-}"
VOLUME_NAME="brewkit.pkgx.dev.${SPECIFIER:-unknown}"

PLATFORM="${PLATFORM:+--platform $PLATFORM}"

# Create volume if it doesn't exist
if [ -z "$(docker volume ls -q -f name=^${VOLUME_NAME}$)" ]; then
docker volume create ${VOLUME_NAME}
set -x
docker volume create ${VOLUME_NAME} >/dev/null
else
set -x
fi

exec docker run \
--name $VOLUME_NAME \
--name brewkit.pkgx.dev \
--rm \
$INTERACTIVE $INTEL \
$INTERACTIVE $PLATFORM \
--volume "$d:/brewkit" \
--volume "$PKGX_PANTRY_PATH:/work" \
--volume "${XDG_CACHE_HOME:-$HOME/Library/Caches/pkgx}:/root/.cache/pkgx" \
--volume "$VOLUME_NAME:/root/.pkgx" \
--env DENO_DIR=/root/.pkgx/.cache/deno \
--env PKGX_PANTRY_PATH=/work \
--env GITHUB_TOKEN=$GITHUB_TOKEN \
--env CLICOLOR_FORCE=1 \
--workdir /work \
pkgxdev/pkgx \
"$CMD" "$@"
$CMD "$@"
2 changes: 1 addition & 1 deletion bin/cmd/edit → bin/bk-edit
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -z "$1" ]; then
for x in $(echo "$PKGX_PANTRY_PATH" | tr ':' '\n'); do
if [ -z "$PKGS" -a -d "$x"/.git ]; then
#^^^^^^^^^^^^^^^ stop at first match
PKGS=($(GIT_WORK_TREE="$x" bash "$d/bin/cmd/status" --print-paths))
PKGS=($(GIT_WORK_TREE="$x" bash "$d/bin/bk-status" --print-paths))
fi
done
elif [ -f "$d"/projects/$1/package.yml ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/cmd/init → bin/bk-init
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ we typically name packages after their homepage.
if you aren’t sure about the name you can submit and we’ll assist.
EOF

exec bash "$d/bin/cmd/edit" $BLEND
exec bash "$d/bin/bk-edit" $BLEND
File renamed without changes.
1 change: 1 addition & 0 deletions bin/bk-test
7 changes: 3 additions & 4 deletions build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ runs:
shell: bash
run: |
echo "::group::fetch deno deps"
tmpdir=$(mktemp -d)
ln -s ${GITHUB_ACTION_PATH}/../bin/cmd/build $tmpdir/build.ts
pkgx deno cache $tmpdir/build.ts --config=${GITHUB_ACTION_PATH}/../deno.jsonc
cd $GITHUB_ACTION_PATH
pkgx deno cache ./build.ts
echo "::endgroup::"

- name: build
Expand All @@ -60,7 +59,7 @@ runs:
fi

set +e
${GITHUB_ACTION_PATH}/../bin/cmd/build '${{ inputs.pkg }}'
${GITHUB_ACTION_PATH}/build.ts '${{ inputs.pkg }}'
status=$?
if [ $status -eq 2 ]; then
echo noop=true >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion bin/cmd/build → build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ function make_toolchain() {
symlink(["strip"], {to: "llvm-strip"})
}

return new Path(new URL(import.meta.url).pathname).join("../../../share/toolchain/bin")
return new Path(new URL(import.meta.url).pathname).join("../../share/toolchain/bin")
}
3 changes: 2 additions & 1 deletion id/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ runs:
- name: fetch deno deps
run: |
echo "::group::fetch deno deps"
pkgx deno cache ${GITHUB_ACTION_PATH}/id.ts --config=${GITHUB_ACTION_PATH}/../deno.jsonc
cd ${GITHUB_ACTION_PATH}
pkgx deno cache ./id.ts
echo "::endgroup::"
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion lib/resolve-pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function(arg?: string) {

async function get_pantry_status() {
const bkroot = new Path(new URL(import.meta.url).pathname).parent().parent()
const proc = new Deno.Command("bash", {args: [bkroot.join('bin/cmd/status').string], stdout: 'piped'}).spawn()
const proc = new Deno.Command("bash", {args: [bkroot.join('bin/bk-status').string], stdout: 'piped'}).spawn()
const [out, { success }] = await Promise.all([proc.output(), proc.status])
if (success) {
return new TextDecoder().decode(out.stdout).split(/\s+/).filter(x => x)
Expand Down
7 changes: 3 additions & 4 deletions test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ runs:
shell: bash
run: |
echo "::group::fetch deno deps"
tmpdir=$(mktemp -d)
ln -s ${GITHUB_ACTION_PATH}/../bin/cmd/test $tmpdir/test.ts
pkgx deno cache $tmpdir/test.ts --config=${GITHUB_ACTION_PATH}/../deno.jsonc
cd ${GITHUB_ACTION_PATH}
pkgx deno cache ./test.ts
echo "::endgroup::"

- name: test
run: ${GITHUB_ACTION_PATH}/../bin/cmd/test '${{ inputs.pkg }}'
run: ${GITHUB_ACTION_PATH}/test.ts '${{ inputs.pkg }}'
shell: bash
env:
GITHUB_TOKEN: ${{inputs.token}}
File renamed without changes.
Loading