Skip to content

Commit

Permalink
ci: don't hardcode packages
Browse files Browse the repository at this point in the history
Instead, we'll have an 'init' job that lists all packages,
a matrix job based in init's output, and an 'all succeeded'
job doing nothing but depend on the matrix, so that we can
have our branch protection rules list that job -- not the
matrix elements.

Signed-off-by: Stephan Renatus <[email protected]>
  • Loading branch information
srenatus committed Jul 4, 2024
1 parent be7bcb5 commit 6d4d7c1
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,32 @@ concurrency:
cancel-in-progress: true

jobs:
init:
runs-on: ubuntu-22.04
outputs:
packages: ${{ steps.workspaces.outputs.packages }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "21.x"
- id: workspaces
run: |
npm ci
echo packages=$(npm query .workspace | jq -c '[.[].location]') >> $GITHUB_OUTPUT
packages:
name: test packages
runs-on: ubuntu-22.04
needs:
- init
strategy:
fail-fast: false
matrix:
pkg: [opa, opa-react]
pkg: ${{ fromJSON(needs.init.outputs.packages) }}
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -32,19 +51,26 @@ jobs:
- name: setup and build
run: |
npm ci
npm run -w packages/${{ matrix.pkg }} build
npm run -w ${{ matrix.pkg }} build
- name: test
run: npx -w packages/${{ matrix.pkg }} tsx --test ./tests/**/*.ts
run: npx -w ${{ matrix.pkg }} tsx --test ./tests/**/*.ts
env:
EOPA_LICENSE_KEY: ${{ secrets.EOPA_LICENSE_KEY }} # @styra/opa needs this
if: matrix.pkg == 'opa'
if: matrix.pkg == 'packages/opa'
- name: test
run: npm run -w packages/${{ matrix.pkg }} test
if: matrix.pkg != 'opa'
run: npm run -w ${{ matrix.pkg }} --if-present test
- name: docs
run: npx -w packages/${{ matrix.pkg }} typedoc
run: npx -w ${{ matrix.pkg }} --if-present typedoc
- name: are the types wrong?
run: npx -w packages/${{ matrix.pkg }} attw --pack
run: npx -w ${{ matrix.pkg }} attw --pack
- name: jsr publish dry-run
run: npx -w packages/${{ matrix.pkg }} jsr publish --dry-run
if: matrix.pkg == 'opa'
run: npx -w ${{ matrix.pkg }} jsr publish --dry-run
if: matrix.pkg == 'packages/opa'

success:
name: tests succeed
runs-on: ubuntu-22.04
needs:
- packages
steps:
- run: echo yay

0 comments on commit 6d4d7c1

Please sign in to comment.