Skip to content

Commit

Permalink
Merge branch 'main' into fix/extraneous-property-client-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Nov 17, 2023
2 parents 6fbcb66 + bb8dca6 commit 8f3c48b
Show file tree
Hide file tree
Showing 158 changed files with 4,893 additions and 597 deletions.
6 changes: 6 additions & 0 deletions .github/actions/setup-and-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
description: 'The directory to run the action in.'
required: false
default: '.'
install-dependencies:
description: 'Whether dependencies should be installed.'
required: false
default: true
build:
description: 'Whether the build step should be run.'
required: false
Expand All @@ -14,6 +18,7 @@ runs:
steps:
- uses: pnpm/action-setup@v2
with:
version: "8.6.2"
run_install: false

- uses: actions/setup-node@v3
Expand All @@ -26,6 +31,7 @@ runs:
shell: bash

- name: Install dependencies
if: ${{ inputs.install-dependencies == 'true' }}
run: pnpm install
shell: bash
working-directory: ${{ inputs.working-directory }}/packages/inngest
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Label PR based on changed package

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: ./.github/actions/setup-and-build
with:
install-dependencies: false
build: false

- run: pnpm install

- name: Label PR
run: node scripts/labelPrs.js
env:
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }} # inngest-release-bot
129 changes: 31 additions & 98 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
NODE_AUTH_TOKEN: nothing

jobs:
test:
name: Runtime
inngest_test:
name: "inngest: Runtime tests"
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -39,8 +39,8 @@ jobs:
# Uses npm as pnpm doesn't support Node < 16
- run: node --version && npm --version && npm run test

types:
name: Types
inngest_types:
name: "inngest: Type tests"
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -62,8 +62,8 @@ jobs:
- run: pnpm add -D typescript@${{ matrix.tsVersion }}
- run: pnpm run test:types

api_diff:
name: Local API diff
inngest_api_diff:
name: "inngest: Local API diff"
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -73,8 +73,8 @@ jobs:
- uses: ./.github/actions/setup-and-build
- run: pnpm run api-extractor run

lint:
name: Lint
inngest_lint:
name: "inngest: Lint"
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -84,8 +84,23 @@ jobs:
- uses: ./.github/actions/setup-and-build
- run: pnpm run lint

package:
name: Package
"eslint-plugin_test":
name: "eslint-plugin: Test"
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/eslint-plugin
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-and-build
with:
install-dependencies: false
build: false
- run: pnpm install
- run: pnpm test

package_inngest:
name: "inngest: Package"
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -111,15 +126,16 @@ jobs:

- id: matrix
run: |
echo "matrix=$(find examples -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
blocklist=$(grep -v '^#' examples/.inngestignore | jq -R . | jq -s .)
echo "matrix=$(find examples -mindepth 1 -maxdepth 1 -type d -name 'framework-*' | grep -v -f <(echo $blocklist | jq -r '.[]') | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
examples:
name: Test examples
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/inngest
needs: [examples-matrix, package]
needs: [examples-matrix, package_inngest]
strategy:
fail-fast: false
matrix:
Expand All @@ -135,90 +151,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: inngestpkg
path: examples/${{ matrix.example }}

# Install dependencies in the example repo
# Don't use "npm ci", "--immutable" etc., as example repos won't be
# shipped with lock files.
- name: Add local SDK to example with dependencies
working-directory: examples/${{ matrix.example }}
run: npm install ./inngest.tgz

# Copy any SDK function examples to the example repo so that we're always
# testing many functions against many handlers.
- name: Find inngest functions path in example
id: inngest-functions-path
run: echo "dir=$(dirname $(echo \"$(git ls-files | grep inngest/index.ts)))\"" >> $GITHUB_OUTPUT
working-directory: examples/${{ matrix.example }}
- name: Remove any existing inngest functions
run: rm -rf ${{ steps.inngest-functions-path.outputs.dir }}
working-directory: examples/${{ matrix.example }}
- name: Copy functions to test to example
run: cp -Tr ../../packages/inngest/src/test/functions/ ${{ steps.inngest-functions-path.outputs.dir }}
working-directory: examples/${{ matrix.example }}

# Rules for every project can be different; ignore the example functions
# we've just added.
- name: Ignore ESLint in example functions
run: echo '**/inngest/**' >> .eslintignore
working-directory: examples/${{ matrix.example }}
# This also covers projects not using ESLint.
- name: Ignore TS checks in examples functions
run: find ${{ steps.inngest-functions-path.outputs.dir }} -type f -name "*.ts" -exec sed -i '1i // @ts-nocheck' {} \;
working-directory: examples/${{ matrix.example }}

# Try to build the example
- name: Build the example
run: npm run build
working-directory: examples/${{ matrix.example }}

- name: Run the Inngest dev server
run: npx inngest-cli@latest dev > cli.log 2>&1 &
working-directory: examples/${{ matrix.example }}
env:
DO_NOT_TRACK: 1
- name: Wait for the Inngest dev server to start
uses: mydea/action-wait-for-api@v1
with:
url: "http://localhost:8288"
timeout: "60"

# Run the example
- name: Run the example's dev server
run: |
if [[ $(jq '.scripts["start"]' < package.json;) != null ]]; then
(npm run start > dev.log 2>&1 &)
else
(npm run dev > dev.log 2>&1 &)
fi
working-directory: examples/${{ matrix.example }}
# Provide the example any env vars it might need
env:
HOST: "0.0.0.0"
PORT: 3000
DO_NOT_TRACK: 1
NODE_ENV: "development"
INNGEST_BASE_URL: "http://127.0.0.1:8288/"
INNGEST_DEVSERVER_URL: "http://127.0.0.1:8288/"
- name: Wait for the example to start
uses: mydea/action-wait-for-api@v1
with:
url: "http://localhost:3000/api/inngest"
timeout: "60"

# Give the dev server 5 seconds to register with the example
# TODO Check logs instead of sleeping
- name: Wait 5 seconds for dev server registration
run: sleep 5

# Run the examples test suite against the dev server
- name: Run integration test suite
run: pnpm run test:examples

- if: ${{ always() }}
run: cat dev.log
working-directory: examples/${{ matrix.example }}
path: packages/inngest

- if: ${{ always() }}
run: cat cli.log
working-directory: examples/${{ matrix.example }}
- name: Run integration tests
run: pnpm run itest ${{ matrix.example }}
64 changes: 59 additions & 5 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
prelease:
prelease_inngest:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
defaults:
run:
working-directory: packages/inngest
if: contains(github.event.pull_request.labels.*.name, 'prerelease/inngest')
steps:
- uses: actions/checkout@v3
Expand All @@ -24,22 +27,22 @@ jobs:
- uses: ./.github/actions/setup-and-build

- name: Prerelease PR
run: node scripts/prerelease.js
working-directory: packages/inngest
run: node ../../scripts/release/prerelease.js
env:
TAG: pr-${{ github.event.pull_request.number }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_ENV: test # disable npm access checks; they don't work in CI
DIST_DIR: dist

- name: Update PR with latest prerelease
uses: edumserrano/find-create-or-update-comment@v1
with:
token: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-prerelease-comment -->'
body-includes: '<!-- pr-prerelease-comment-inngest -->'
comment-author: 'inngest-release-bot'
body: | # can be a single value or you can compose text with multi-line values
<!-- pr-prerelease-comment -->
<!-- pr-prerelease-comment-inngest -->
A user has added the <kbd>[prerelease/inngest](https://github.com/inngest/inngest-js/labels/prerelease%2Finngest)</kbd> label, so this PR will be published to npm with the tag `pr-${{ github.event.pull_request.number }}`. It will be updated with the latest changes as you push commits to this PR.
You can install this prerelease version with:
Expand All @@ -50,3 +53,54 @@ jobs:
The last release was built and published from ${{ github.event.pull_request.head.sha }}.
edit-mode: replace

prerelease_eslint-plugin:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
defaults:
run:
working-directory: packages/eslint-plugin
if: contains(github.event.pull_request.labels.*.name, 'prerelease/eslint-plugin')
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- uses: ./.github/actions/setup-and-build
with:
install-dependencies: false
build: false

- run: pnpm install

- run: pnpm build

- name: Prerelease PR
run: node ../../scripts/release/prerelease.js
env:
TAG: pr-${{ github.event.pull_request.number }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_ENV: test # disable npm access checks; they don't work in CI

- name: Update PR with latest prerelease
uses: edumserrano/find-create-or-update-comment@v1
with:
token: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-prerelease-comment-eslint-plugin -->'
comment-author: 'inngest-release-bot'
body: | # can be a single value or you can compose text with multi-line values
<!-- pr-prerelease-comment-eslint-plugin -->
A user has added the <kbd>[prerelease/eslint-plugin](https://github.com/inngest/inngest-js/labels/prerelease%2Feslint-plugin)</kbd> label, so this PR will be published to npm with the tag `pr-${{ github.event.pull_request.number }}`. It will be updated with the latest changes as you push commits to this PR.
You can install this prerelease version with:
```sh
npm install @inngest/eslint-plugin@pr-${{ github.event.pull_request.number }}
```
The last release was built and published from ${{ github.event.pull_request.head.sha }}.
edit-mode: replace

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: changesets/action@v1
id: changesets
with:
publish: pnpm run --if-present --recursive release
publish: pnpm run release:all
title: ${{ github.ref_name == 'main' && 'Release @latest' || format('Release {0}', github.ref_name) }}
env:
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
yarn.lock
pnpm-lock.yaml
package-lock.json
bun.lockb
3 changes: 3 additions & 0 deletions examples/.inngestignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Used to ignore some directories when running integration tests.
# These tests will change anyway to be less reliant on GH Actions.
framework-nestjs
2 changes: 2 additions & 0 deletions examples/framework-koa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
31 changes: 31 additions & 0 deletions examples/framework-koa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Inngest Koa Template

This is a [Koa](https://koajs.com/) project . It is a reference on how to send and receive events with Inngest and Koa.

## Getting Started

## How to use

Use [`create-next-app`](https://www.npmjs.com/package/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example https://github.com/inngest/inngest-js/tree/main/examples/framework-koa inngest-koa
```

```bash
yarn create next-app --example https://github.com/inngest/inngest-js/tree/main/examples/framework-koa inngest-koa
```

```bash
pnpm create next-app --example https://github.com/inngest/inngest-js/tree/main/examples/framework-koa inngest-koa
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

- [Inngest functions](https://www.inngest.com/docs/functions) are available at `src/inngest/`.
- The [Inngest handler](https://www.inngest.com/docs/frameworks/nextjs) is available a `src/index.ts`.

## Learn More

- [Inngest Documentation](https://www.inngest.com/docs) - learn about the Inngest SDK, functions, and events
- [Koa Documentation](https://koajs.com/) - learn about Koa features and API.

0 comments on commit 8f3c48b

Please sign in to comment.