Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/novuhq/novu into add-fcm-da…
Browse files Browse the repository at this point in the history
…ta-messages
  • Loading branch information
raikasdev committed Aug 22, 2023
2 parents a070c2f + ca6b16a commit 981c7be
Show file tree
Hide file tree
Showing 139 changed files with 10,150 additions and 14,373 deletions.
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@
"stddev",
"shortid",
"upsert",
"upserted",
"cond",
"redismaster",
"appendonly",
Expand Down Expand Up @@ -497,7 +498,8 @@
"reactjs",
"nextjs",
"vanillajs",
"quckstart"
"quckstart",
"errmsg"
],
"flagWords": [],
"patterns": [
Expand Down
28 changes: 28 additions & 0 deletions .github/actions/run-api/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run API

description: Starts and waits for an API running instance

inputs:
launch_darkly_sdk_key:
description: 'The Launch Darkly SDK key to use'
required: false
default: ''

runs:
using: composite

steps:
- name: Build API
shell: bash
run: CI='' pnpm build:api

- name: Start API
shell: bash
env:
IS_IN_MEMORY_CLUSTER_MODE_ENABLED: true
LAUNCH_DARKLY_SDK_KEY: ${{ inputs.launch_darkly_sdk_key }}
run: cd apps/api && pnpm start:test &

- name: Wait on API
shell: bash
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check
46 changes: 46 additions & 0 deletions .github/actions/run-backend/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run Backend

description: Starts and waits for the API and Worker instance

inputs:
launch_darkly_sdk_key:
description: 'The Launch Darkly SDK key to use'
required: false
default: ''
cypress_github_oauth_client_id:
description: 'Cypress GitHub client ID'
required: true
cypress_github_oauth_client_secret:
description: 'Cypress GitHub client secret'
required: true

runs:
using: composite

steps:
- name: Start API in TEST
shell: bash
env:
GITHUB_OAUTH_CLIENT_ID: ${{ inputs.cypress_github_oauth_client_id }}
GITHUB_OAUTH_CLIENT_SECRET: ${{ inputs.cypress_github_oauth_client_secret }}
NODE_ENV: "test"
PORT: "1336"
TZ: "UTC"
GITHUB_OAUTH_REDIRECT: "http://localhost:1336/v1/auth/github/callback"
LAUNCH_DARKLY_SDK_KEY: ${{ inputs.launch_darkly_sdk_key }}
IN_MEMORY_CLUSTER_MODE_ENABLED: true
run: cd apps/api && pnpm start:build &

- name: Start Worker
shell: bash
env:
NODE_ENV: "test"
PORT: "1342"
TZ: "UTC"
LAUNCH_DARKLY_SDK_KEY: ${{ inputs.launch_darkly_sdk_key }}
IN_MEMORY_CLUSTER_MODE_ENABLED: true
run: cd apps/worker && pnpm start:prod &

- name: Wait on API and Worker
shell: bash
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check http://localhost:1342/v1/health-check
4 changes: 0 additions & 4 deletions .github/actions/run-worker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ runs:
using: composite

steps:
- name: Install wait-on plugin
shell: bash
run: npm i -g wait-on

- name: Build worker
shell: bash
run: CI='' pnpm build:worker
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ runs:
- name: 🛟 Install dependencies
shell: bash
run: pnpm install --frozen-lockfile

- name: Install wait-on plugin
shell: bash
run: pnpm i -g wait-on
20 changes: 20 additions & 0 deletions .github/actions/validate-swagger/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Validate Swagger

description: Validates the swagger from the API

runs:
using: composite

steps:
- name: Get swagger json as file
shell: bash
run: |
curl -o swagger.json http://localhost:1336/api-json
- uses: char0n/swagger-editor-validate@v1
with:
definition-file: swagger.json

- name: Kill port for api 1336 for unit tests
shell: bash
run: sudo kill -9 $(sudo lsof -t -i:1336)
14 changes: 1 addition & 13 deletions .github/workflows/reusable-api-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,7 @@ jobs:

- uses: ./.github/actions/start-localstack

- name: Install wait-on plugin
run: npm i -g wait-on

- name: Build worker
run: CI='' pnpm build:worker

- name: Start worker
env:
IN_MEMORY_CLUSTER_MODE_ENABLED: true
run: cd apps/worker && pnpm start:test &

- name: Wait on worker
run: wait-on --timeout=180000 http://localhost:1342/v1/health-check
- uses: ./.github/actions/run-worker

# Runs a single command using the runners shell
- name: Build API
Expand Down
32 changes: 8 additions & 24 deletions .github/workflows/reusable-web-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ jobs:
projects: '@novu/web,@novu/api,@novu/worker'

- uses: ./.github/actions/start-localstack
- uses: ./.github/actions/setup-redis-cluster

- uses: ./.github/actions/run-backend
with:
cypress_github_oauth_client_id: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_ID }}
cypress_github_oauth_client_secret: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_SECRET }}
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}

- name: Start Client
working-directory: apps/web
Expand All @@ -78,34 +85,11 @@ jobs:
run: pnpm start:static:build &

- name: Start WS
env:
IN_MEMORY_CLUSTER_MODE_ENABLED: false
run: |
cd apps/ws && pnpm start:test &
- name: Start API in TEST
env:
GITHUB_OAUTH_CLIENT_ID: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_ID }}
GITHUB_OAUTH_CLIENT_SECRET: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_SECRET }}
NODE_ENV: "test"
PORT: "1336"
TZ: "UTC"
GITHUB_OAUTH_REDIRECT: "http://localhost:1336/v1/auth/github/callback"
run: cd apps/api && pnpm start:build &

- name: Start worker
env:
NODE_ENV: "test"
PORT: 1342
TZ: "UTC"
IN_MEMORY_CLUSTER_MODE_ENABLED: false
run: cd apps/worker && pnpm start:prod &

- name: Install wait-on plugin
run: npm i -g wait-on

- name: Wait on Services
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check http://localhost:1342/v1/health-check http://localhost:1340/v1/health-check http://localhost:4200
run: wait-on --timeout=180000 http://localhost:1340/v1/health-check http://localhost:4200

# run cypress install only when cache was not hit
- name: Cypress install
Expand Down
31 changes: 9 additions & 22 deletions .github/workflows/reusable-widget-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
with:
cypress_version: 12.9.0
cypress: true
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint
Expand All @@ -69,6 +70,12 @@ jobs:
targets: build
projects: '@novu/widget,@novu/embed,@novu/api,@novu/worker,@novu/ws'

- uses: ./.github/actions/run-backend
with:
cypress_github_oauth_client_id: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_ID }}
cypress_github_oauth_client_secret: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_SECRET }}
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}

# Runs a single command using the runners shell
- name: Start Client
run: pnpm start:widget:test &
Expand All @@ -81,28 +88,8 @@ jobs:
cp apps/ws/src/.env.test apps/ws/dist/src/.env.test
cd apps/ws && pnpm start:prod &
- name: Start API in TEST
env:
GITHUB_OAUTH_CLIENT_ID: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_ID }}
GITHUB_OAUTH_CLIENT_SECRET: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_SECRET }}
NODE_ENV: "test"
PORT: "1336"
TZ: "UTC"
GITHUB_OAUTH_REDIRECT: "http://localhost:1336/v1/auth/github/callback"
run: cd apps/api && pnpm start:build &

- name: Start worker
env:
NODE_ENV: "test"
PORT: 1342
TZ: "UTC"
run: cd apps/worker && pnpm start:prod &

- name: Install wait-on plugin
run: npm i -g wait-on

- name: Wait on Services
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check http://localhost:1342/v1/health-check http://localhost:1340/v1/health-check http://localhost:3500
- name: Wait on Widget and WS Services
run: wait-on --timeout=180000 http://localhost:1340/v1/health-check http://localhost:3500

- name: Cypress install
if: steps.setup-project.outputs.cypress_cache_hit != 'true'
Expand Down
31 changes: 29 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ on:

jobs:
dependency-review:
name: Dependency review
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3

spellcheck: # run the action
spellcheck:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -203,6 +205,7 @@ jobs:
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
name: Lint and build
with:
targets: lint,build
projects: ${{matrix.projectName}}
Expand All @@ -215,6 +218,7 @@ jobs:
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}

- uses: mansagroup/nrwl-nx-action@v3
name: Running the E2E tests
env:
IN_MEMORY_CLUSTER_MODE_ENABLED: true
LAUNCH_DARKLY_SDK_KEY: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}
Expand All @@ -226,7 +230,7 @@ jobs:
name: Unit Test
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
timeout-minutes: 80
strategy:
# One job for each different project and node version
Expand All @@ -246,6 +250,29 @@ jobs:
slim: ${{ !contains(matrix.projectName, '@novu/api') && !contains(matrix.projectName, '@novu/worker') && !contains(matrix.projectName, '@novu/ws') }}
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
name: Lint and build and test
with:
targets: lint,build,test
projects: ${{matrix.projectName}}

validate_swagger:
name: Validate Swagger
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
timeout-minutes: 10
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: ./.github/actions/run-api
with:
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}

- uses: ./.github/actions/validate-swagger

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The ultimate service for managing multi-channel notifications with a single API.
· <a href="https://github.com/novuhq/elixir">Elixir</a>
· <a href="https://github.com/novuhq/rust">Rust</a>
· <a href="https://github.com/novuhq/novu-python">Python</a>
· <a href="https://github.com/novuhq/novu-java">Java</a>
</p>

## ⭐️ Why Novu?
Expand Down Expand Up @@ -221,5 +222,5 @@ Novu is licensed under the MIT License - see the [LICENSE](https://github.com/no
Thanks a lot for spending your time helping Novu grow. Keep rocking 🥂

<a href="https://novu.co/contributors">
<img src="https://contributors-img.web.app/image?repo=novuhq/novu" />
<img src="https://contributors-img.web.app/image?repo=novuhq/novu" alt="Contributors"/>
</a>
Loading

0 comments on commit 981c7be

Please sign in to comment.