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 - id: diff
run: | run: |
for x in ${{ steps.get-diff.outputs.diff }}; do for x in ${{ steps.get-diff.outputs.diff }}; do
y=$(echo $x | sed 's#projects/\(.*\)/package.yml#\1#') y=$(echo $x | sed 's#projects/\(.*\)/[^/]*#\1#')
RESULT="$RESULT $y" RESULT="$RESULT ${y//$'\n'/}"
done done
echo "diff=$RESULT" >> $GITHUB_OUTPUT echo "diff=$RESULT" >> $GITHUB_OUTPUT

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@ $ git clone https://github.com/pkgxdev/pantry
$ cd pantry $ cd pantry
$ dev # https://docs.pkgx.sh/dev $ 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 # ^^ IMPORTANT! Otherwise the `bk` command will not be found
$ bk init $ bk init
@ -50,10 +50,9 @@ $ gh pr create
> * `bk build` and `bk test` can be invoked eg. `bk docker build` to run > * `bk build` and `bk test` can be invoked eg. `bk docker build` to run
> inside a Docker container for Linux builds and testing > inside a Docker container for Linux builds and testing
> * All commands take an optional pkg-spec eg. `bk build node@19` > * All commands take an optional pkg-spec eg. `bk build node@19`
> * While inside the pantry `dev` environment you can run commands from any
> [!TIP] > built packages provided you specified their `provides:` key in the
> While inside the pantry `dev` environment you can run commands from any built > `package.yml`.
> packages provided you specified their `provides:` key in the `package.yml`.
> [!NOTE] > [!NOTE]
> We use a special package called [`brewkit`] to build packages both here and > 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` it doesnt know about, but in the case where that fails do a `pkgx --sync`
first. first.
> The pantry automatically builds new releases of packages *as soon as they are > [!NOTE]
> released* (usually starting the builds within seconds). There is no need to > The pantry automatically builds new releases of packages *as soon as they
> submit PRs for updates. > 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 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 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 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: with their pull request then you can use GitHubs CLI:
``` ```sh
$ gh pr checkout 123 $ gh pr checkout 123
# or you can copy paste the URL: # or you can copy paste the URL: