Skip to content
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
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"commit": false,
"fixed": [],
"linked": [],
"ignore": ["@open-iga/connector-sdk"],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch"
Expand Down
5 changes: 5 additions & 0 deletions .changeset/personio-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@open-iga/personio-source': minor
---

Add the Personio source connector, which lists employees as identities
2 changes: 2 additions & 0 deletions .changeset/sink-connectors-folder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
57 changes: 57 additions & 0 deletions .github/actions/compile/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Compile Extism JS plugin
description: >-
Install extism-js and Bun, install the project's dependencies, then run the compile command.
Linux x86_64 runners only. Check out your code first.

inputs:
command:
description: Shell command that compiles the plugin
required: false
default: bun run compile
bun-version:
description: Bun version to install
required: false
default: 1.4.5
working-directory:
description: Directory to install dependencies and compile in
required: false
default: .

runs:
using: composite
steps:
- name: Install extism-js - Linux x86_64
shell: bash
# The installer unpacks binaryen into the current directory, so keep it out of the checkout
working-directory: ${{ runner.temp }}
env:
# Single source of truth for the version. Must stay compatible with the catalog's @extism/extism
# runtime: js-pdk > 1.5.1 emits wasm that 2.0.0-rc13 cannot parse. Bump the checksums with it.
EXTISM_JS_TAG: v1.5.1
# Verifies the installer at that tag before it runs
INSTALLER_SHA256: c395d700898249a49c54072950fbd2d0e4d3719acf5b4390f1cb142680ec1f05
# The installer downloads the extism-js binary separately (unverified), so also pin the installed
# binary (Linux x86_64 asset). A changed release asset fails here, before it ever runs.
EXTISM_JS_SHA256: 4552ee7385d2f0583363448c9e45aa733dec8d7edac8d646b69ee1271ad09483
run: |
curl -fLs "https://raw.githubusercontent.com/extism/js-pdk/${EXTISM_JS_TAG}/install.sh" -o extism-install.sh
echo "${INSTALLER_SHA256} extism-install.sh" | sha256sum -c -
bash extism-install.sh "$EXTISM_JS_TAG"
echo "${EXTISM_JS_SHA256} $(command -v extism-js)" | sha256sum -c -

- uses: oven-sh/setup-bun@v2
name: Setup Bun
with:
bun-version: ${{ inputs.bun-version }}

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: bun install --frozen-lockfile

- name: Compile Connector
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
COMMAND: ${{ inputs.command }}
run: bash -eo pipefail -c "$COMMAND"
42 changes: 42 additions & 0 deletions .github/workflows/package-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Package CI

on:
workflow_call:
inputs:
package:
description: Workspace package name to check
required: true
type: string
path:
description: Package directory, relative to the repo root
required: true
type: string

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
env:
PACKAGE: ${{ inputs.package }}
steps:
- uses: actions/checkout@v6

- name: Install tools and dependencies, then compile
uses: ./.github/actions/compile
with:
command: bunx turbo run compile --filter="$PACKAGE"

- name: Lint
env:
PACKAGE_PATH: ${{ inputs.path }}
run: bunx oxlint "$PACKAGE_PATH"

# turbo also runs each task for whatever the package depends on
- name: Typecheck
run: bunx turbo run typecheck --filter="$PACKAGE"

# test depends on compile, which turbo replays from the cache of the compile step
- name: Test
run: bunx turbo run test --filter="$PACKAGE"
67 changes: 44 additions & 23 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,74 @@ concurrency:
cancel-in-progress: true

jobs:
ci:
detect:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.affected.outputs.packages }}
steps:
- uses: actions/checkout@v6
with:
# turbo needs the history to diff against the base commit
fetch-depth: 0

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.4

- name: Install extism-js
env:
# Version is pinned in package.json (config.extism-js-version);
# the checksum verifies the installer at that tag before it runs.
INSTALLER_SHA256: c395d700898249a49c54072950fbd2d0e4d3719acf5b4390f1cb142680ec1f05
# The installer downloads the extism-js binary separately (unverified), so
# also pin the installed binary. Linux x86_64 asset for the tag above; a
# changed release asset mismatches here and fails before it ever compiles.
EXTISM_JS_SHA256: 4552ee7385d2f0583363448c9e45aa733dec8d7edac8d646b69ee1271ad09483
run: |
EXTISM_JS_TAG="$(jq -r '.config["extism-js-version"]' package.json)"
curl -fLs "https://raw.githubusercontent.com/extism/js-pdk/${EXTISM_JS_TAG}/install.sh" -o /tmp/extism-install.sh
echo "${INSTALLER_SHA256} /tmp/extism-install.sh" | sha256sum -c -
bash /tmp/extism-install.sh "$EXTISM_JS_TAG"
echo "${EXTISM_JS_SHA256} $(command -v extism-js)" | sha256sum -c -
bun-version: 1.4.5

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Typecheck, Lint, test and compile
run: bunx turbo run typecheck "//#lint" test compile
# Changed packages plus every package that depends on them
- name: Detect affected packages
id: affected
env:
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
run: bun scripts/affected-packages.ts

package:
needs: detect
# An empty matrix is an error, so skip the job instead
if: ${{ needs.detect.outputs.packages != '[]' }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.detect.outputs.packages) }}
name: ${{ matrix.package.name }}
uses: ./.github/workflows/package-ci.yml
with:
package: ${{ matrix.package.name }}
path: ${{ matrix.package.path }}

# Single status to require in branch protection; matrix job names vary per PR
ci:
needs: [detect, package]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Fail if any job failed
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1

changeset-check:
needs: ci
runs-on: ubuntu-latest
# Version PRs (changeset-release/*) and dependency bots don't carry changesets
if: ${{ !startsWith(github.head_ref, 'changeset-release/') }}
# !cancelled() is needed: a skipped matrix job upstream would otherwise skip this one too
if: >-
${{ !cancelled() && needs.ci.result == 'success' &&
!startsWith(github.head_ref, 'changeset-release/') }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.5

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Check for changesets
# Fails when packages under connectors/ or packages/ changed
# without a changeset
# Fails when a connector changed without a changeset (the SDK is ignored until it is published)
run: bunx changeset status --since="origin/${{ github.base_ref }}"
39 changes: 10 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,8 @@ jobs:
fetch-depth: 0

- uses: oven-sh/setup-bun@v2

- name: Install extism-js
env:
# Version is pinned in package.json (config.extism-js-version);
# the checksum verifies the installer at that tag before it
# runs with this job's write token.
INSTALLER_SHA256: c395d700898249a49c54072950fbd2d0e4d3719acf5b4390f1cb142680ec1f05
# The installer downloads the extism-js binary separately (unverified), so
# also pin the installed binary. Linux x86_64 asset for the tag above; a
# changed release asset mismatches here and fails before it ever runs.
EXTISM_JS_SHA256: 4552ee7385d2f0583363448c9e45aa733dec8d7edac8d646b69ee1271ad09483
run: |
EXTISM_JS_TAG="$(jq -r '.config["extism-js-version"]' package.json)"
curl -fLs "https://raw.githubusercontent.com/extism/js-pdk/${EXTISM_JS_TAG}/install.sh" -o /tmp/extism-install.sh
echo "${INSTALLER_SHA256} /tmp/extism-install.sh" | sha256sum -c -
bash /tmp/extism-install.sh "$EXTISM_JS_TAG"
echo "${EXTISM_JS_SHA256} $(command -v extism-js)" | sha256sum -c -
with:
bun-version: 1.4.5

- name: Install dependencies
run: bun install --frozen-lockfile
Expand All @@ -52,18 +37,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Compile and publish GitHub release
- name: Install tools and dependencies, then compile
if: steps.changesets.outputs.hasChangesets == 'false'
uses: ./.github/actions/compile
with:
command: bunx turbo run compile

- name: Publish GitHub releases
if: steps.changesets.outputs.hasChangesets == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="@open-iga/aws-sink@$(jq -r .version connectors/aws/package.json)"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists; nothing to do."
exit 0
fi
bunx turbo run compile
cd connectors/aws/.open-iga
sha256sum AWS.wasm | cut -d' ' -f1 > AWS.wasm.hash.txt
gh release create "$TAG" --title "$TAG" --generate-notes \
AWS.wasm AWS.wasm.hash.txt
run: bun scripts/release.ts
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is a [Bun workspaces](https://bun.sh/docs/install/workspaces) monorepo.
| Path | Package | Role |
| ---------------------------- | --------------------------- | -------------------------------------------------------------------------------- |
| `packages/connector-sdk` | `@open-iga/connector-sdk` | Build toolchain + runtime that connector authors depend on; compiles TS to WASM. |
| `connectors/aws` | `@open-iga/aws-sink` | AWS connector built on the SDK — account actions (IAM users) and entitlements. |
| `sink-connectors/aws` | `@open-iga/aws-sink` | AWS connector built on the SDK — account actions (IAM users) and entitlements. |
| `source-connectors/personio` | `@open-iga/personio-source` | Personio source connector — lists employees. |

## Getting started
Expand All @@ -23,14 +23,36 @@ bun install # install workspace dependencies
bun run test # build + test every workspace (via turbo)
```

Per connector (e.g. `connectors/aws`):
Per connector (e.g. `sink-connectors/aws`):

```sh
bun run compile # compile the connector to a .wasm module (open-iga compile)
bun run test # compile, then run the test suite
bun run typecheck # type-check app and test sources
```

## CI

Pull requests run the [PR workflow](.github/workflows/pr.yml): it asks turbo for the changed packages and everything
that depends on them, then runs [Package CI](.github/workflows/package-ci.yml) (compile, lint, typecheck, test) once
per package. Changing the root `tsconfig.json`, `oxlint.config.ts`, `turbo.json`, `scripts/` or the CI files checks every package.

### Compile action for other repositories

The [compile action](.github/actions/compile/action.yml) does everything a compile needs on a Linux x86_64 runner, in
this order: install the pinned `extism-js` CLI, install Bun (the `open-iga` CLI runs on it), install your dependencies,
run your compile command. Check out your code first:

```yaml
steps:
- uses: actions/checkout@v6
- uses: open-iga/plugins/.github/actions/compile@main # pin a tag or commit SHA
with:
command: bun run compile # default
working-directory: . # default
bun-version: 1.4.5 # default
```

## Writing a connector

A connector is plain TypeScript that defines its capabilities against `@open-iga/connector-sdk` and
Expand All @@ -47,7 +69,7 @@ A `source` connector declares:

- **Identities** — a paged `list` of people (e.g. employees).

See `connectors/aws` for a complete reference implementation.
See `sink-connectors/aws` for a complete reference implementation.

## Roadmap

Expand Down
Loading
Loading