use brewkit/id to reduce github API lookups (#4426)

This commit is contained in:
Max Howell 2023-12-15 13:32:55 -05:00 committed by GitHub
parent 6d2a114307
commit e78a2c65ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 27 deletions

View file

@ -24,8 +24,8 @@ jobs:
- id: diff
run: |
for x in ${{ steps.get-diff.outputs.diff }}; do
y=$(echo $x | sed 's#projects/\(.*\)/package.yml#\1#')
RESULT="$RESULT $y"
y=$(echo $x | sed 's#projects/\(.*\)/[^/]*#\1#')
RESULT="$RESULT ${y//$'\n'/}"
done
echo "diff=$RESULT" >> $GITHUB_OUTPUT

View file

@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true
jobs:
diff:
plan:
runs-on: ubuntu-latest
outputs:
pkgs: ${{ steps.diff.outputs.pkgs }}
@ -36,12 +36,13 @@ jobs:
echo "pkgs=$RESULT" >> $GITHUB_OUTPUT
build:
needs: diff
if: needs.plan.outputs.pkgs
needs: plan
name: ci ${{ matrix.platform.name }} ${{matrix.pkg}}
strategy:
fail-fast: false
matrix:
pkg: ${{ fromJSON(needs.diff.outputs.pkgs) }}
pkg: ${{ fromJSON(needs.plan.outputs.pkgs) }}
platform:
- os: ["self-hosted", "macOS", "X64"]
name: x64
@ -54,6 +55,8 @@ jobs:
name: Lnx·x64
runs-on: ${{ matrix.platform.os }}
container: ${{ matrix.platform.container }}
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
@ -71,15 +74,9 @@ jobs:
id: build
with:
pkg: ${{ matrix.pkg }}
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}
- uses: pkgxdev/brewkit/audit@v1
if: steps.build.outputs.pkgspec
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}
- uses: pkgxdev/brewkit/test@v1
if: steps.build.outputs.pkgspec
env:
PKGX_PANTRY_PATH: ${{ github.workspace }}

View file

@ -1,5 +1,5 @@
name: pkg for platform
run-name: pkging ${{ inputs.project }} (${{ inputs.name }})
run-name: pkging ${{ fromJSON(inputs.pkg).project }} (${{ inputs.name }})
on:
workflow_call:
@ -45,13 +45,15 @@ on:
AWS_SECRET_ACCESS_KEY: { required: true }
AWS_CF_DISTRIBUTION_ID: { required: true }
env:
BREWKIT_PKGJSON: ${{ inputs.pkg }}
jobs:
build:
name: build ${{inputs.tinyname}}
runs-on: ${{ fromJSON(inputs.os) }}
container: ${{ inputs.container }}
outputs:
pkg: ${{ steps.build.outputs.pkgspec }}
project: ${{ steps.build.outputs.project }}
version: ${{ steps.build.outputs.version }}
platform: ${{ steps.build.outputs.platform }}
@ -73,8 +75,6 @@ jobs:
- uses: pkgxdev/brewkit/build@v1
id: build
with:
pkg: ${{ inputs.pkg }}
- uses: styfle/cancel-workflow-action@0.12.0
if: steps.build.outputs.noop
@ -99,8 +99,6 @@ jobs:
- uses: actions/checkout@v4
- uses: pkgxdev/brewkit/download-build-artifact@v1
- uses: pkgxdev/brewkit/test@v1
with:
pkg: ${{ needs.build.outputs.pkg }}
bottle:
name: bottle (${{inputs.tinyname}}.${{matrix.compression}})

View file

@ -16,11 +16,16 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
pkg: ${{ steps.id.outputs.pkg-json }}
steps:
- uses: pkgxdev/setup@v2
- uses: actions/checkout@v4
- run: .github/scripts/get-matrix.ts ${{ inputs.pkg }}
id: matrix
- uses: pkgxdev/brewkit/id@v1
id: id
with:
pkg: ${{ inputs.pkg }}
pkg:
needs: plan
@ -33,7 +38,7 @@ jobs:
permissions:
issues: write
with:
pkg: ${{ inputs.pkg }}
pkg: ${{ needs.plan.outputs.pkg }}
name: ${{ matrix.platform.name }}
os: ${{ toJSON(matrix.platform.os) }}
container: ${{ matrix.platform.container }}

View file

@ -12,7 +12,7 @@ $ git clone https://github.com/pkgxdev/pantry
$ cd pantry
$ dev # https://docs.pkgx.sh/dev
# ^^ adds brewkit to your devenv
# ^^ adds brewkit (ie. the `bk` command) to your devenv
# ^^ IMPORTANT! Otherwise the `bk` command will not be found
$ bk init
@ -50,10 +50,9 @@ $ gh pr create
> * `bk build` and `bk test` can be invoked eg. `bk docker build` to run
> inside a Docker container for Linux builds and testing
> * All commands take an optional pkg-spec eg. `bk build node@19`
> [!TIP]
> While inside the pantry `dev` environment you can run commands from any built
> packages provided you specified their `provides:` key in the `package.yml`.
> * While inside the pantry `dev` environment you can run commands from any
> built packages provided you specified their `provides:` key in the
> `package.yml`.
> [!NOTE]
> We use a special package called [`brewkit`] to build packages both here and
@ -90,9 +89,10 @@ automatically sync the pantry to your local machine if you ask for something
it doesnt know about, but in the case where that fails do a `pkgx --sync`
first.
> The pantry automatically builds new releases of packages *as soon as they are
> released* (usually starting the builds within seconds). There is no need to
> submit PRs for updates.
> [!NOTE]
> The pantry automatically builds new releases of packages *as soon as they
> are released* (usually starting the builds within seconds). There is no need
> to submit PRs for updates.
Note that while in the pantry `dev` environment you can use your new package
if you built it. However this will not work outside the pantry `dev` unless
@ -106,7 +106,7 @@ you either:
Packaging can be fiddly so we all pitch in. If you want to help someone else
with their pull request then you can use GitHubs CLI:
```
```sh
$ gh pr checkout 123
# or you can copy paste the URL: