Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): reusable action to run backend (api, worker) for clients #3991

Merged
merged 1 commit into from
Aug 17, 2023
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
38 changes: 38 additions & 0 deletions .github/actions/run-backend/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: ''

runs:
using: composite

steps:
- name: Start API in TEST
shell: bash
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"
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
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
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check http://localhost:1342/v1/health-check
26 changes: 5 additions & 21 deletions .github/workflows/reusable-web-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:

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

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

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

- name: Start WS
env:
IN_MEMORY_CLUSTER_MODE_ENABLED: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in use in WS.

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: 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
25 changes: 6 additions & 19 deletions .github/workflows/reusable-widget-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jobs:
targets: build
projects: '@novu/widget,@novu/embed,@novu/api,@novu/worker,@novu/ws'

- uses: ./.github/actions/run-backend
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend should be available before we try to connect the clients.

with:
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,25 +85,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: 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