Skip to content

Commit

Permalink
Unified Testing Action (#3254)
Browse files Browse the repository at this point in the history
* fix: trigger change

* fix: run linter

* fix: run worker pre reqs

* fix: bad equals signs

* fix: syntax

* fix: test

* add action for test e2e

* fix: trigger worker

* fix: lint build

* fix: split unit tests

* fix: trigger tests

* fix: ws tests

* fix: providers t esting

* fix: lint for app generic

* fix: run parallel

* refactor: remove duplicate jobs

* fix: pipeline concurrency

* fix: lint commands for providers

* fix: application generic lint errors

* fix: tests for client

* fix: embed tests

* fix: add work in progress

* fix: test providers flow

* fix: test providers

* fix: yml structure

* fix: yml structure

* fix: indentation

* fix: import statement

* fix: remove duplicate test

* fix: affected run

* fix: pnpm get affected

* fix: true position

* fix: log command

* fix: tail commands

* fix: tail to +5

* fix: change

* fix: test provider

* fix: test

* fix: test

* fix: providers

* fix: test

* fix: providers run only

* fix: utilize nx for providers

* fix: move docker build test

* fix: tests for providers

* fix: update cache

* fix: tests

* fix: timeout time for failed

* fix: reduce job

* fix: speed up affected calls

* fix: restore commands

* fix: remove last duplicates

* fix: deploy to dev

* fix: nest testing

* fix: mandril tests

* fix: input

* fix: pipe env

* fix: skip previously failing tests

TODO: fix later and re enable

* fix: package linters

* fix: missing tests

* fix: stateless tests

* fix: testing lib tests

* fix: widget tests

* feat: resolve app generic spec for unit tests

* fix: quick fix for application generic-tests

* fix: debug reporter silence

* fix: try nx_daemon off for install env

* fix: trigger build

fix: flaky widget test

fix: packages combine

fix: filtered items sync

fix: filtered items sync

fix: packages filter for app generic

fix: debug app generic flow

fix: play with network idle to crrect

fix: test cached packages folder

fix: cache path

fix: add codeql concurrency

fix: add more caching

fix: cache

fix: cache

fix: branch name

fix: testing count for processing

fix: testing count for processing

fix: remove wait for template callback

fix: widget add network idle

fix: test cypress cache

fix: cypress in ci

fix: inputs

fix: trigger build

fix: test

fix: worker tests

fix: test setup node

fix: restore

fix: wait for network idle

fix: add network idle

fix: org id to template id

fix: network idle

ci: try idle

test: try remove visit templates

fix: e2e gap

fix: templates

fix: wait unseen

fix: run mode retries

fix: activities

fix: maybe like this?

fix: retest

fix: widget

fix: test

ci: remove flaky tests

fix: build

fix: wait for

fix: combine test libs

fix: performance

fix: start static worker

ci: wip

fix: restore

fix: unseen wait

fix: wait for

fix: unify searches for packages

* fix: refactor widget tests

* fix: add ws

* fix: dist path

* fix: try env

* fix: add timeout
  • Loading branch information
scopsy authored Apr 25, 2023
1 parent 6e80280 commit f00e2f5
Show file tree
Hide file tree
Showing 116 changed files with 9,730 additions and 14,021 deletions.
26 changes: 26 additions & 0 deletions .github/actions/run-worker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

name: Run Worker

description: Sets up a Redis Cluster instance needed to run the tests

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

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

- name: Wait on worker
shell: bash
run: wait-on --timeout=180000 http://localhost:1342/v1/health-check
30 changes: 9 additions & 21 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ inputs:
description: 'The version of cypress to install'
required: false
default: ''
slim:
description: 'Should only install dependencies and checkout code'
required: false
default: 'false'
outputs:
cypress_cache_hit:
description: 'Did cypress use binary cache'
Expand All @@ -19,40 +23,24 @@ runs:
- name: ⚙️ Setup kernel for react native, increase watchers
shell: bash
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- uses: pnpm/action-setup@v2

- uses: actions/setup-node@v3
name: ⚙️ Setup Node Version
with:
node-version: '16.15.1'
cache: 'pnpm'

- name: 💵 Start Redis
if: ${{ inputs.slim == 'false' }}
uses: supercharge/[email protected]

- name: 📚 Start MongoDB
if: ${{ inputs.slim == 'false' }}
uses: supercharge/[email protected]
with:
mongodb-version: 4.2.8

- uses: pnpm/action-setup@v2
name: 🛟 Install pnpm
id: pnpm-install
with:
run_install: false

- name: ⛏️ Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: 🏦 Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Cache Cypress Binary For Version
id: cache-cypress-binary-version
if: ${{ inputs.cypress_version != '' }}
Expand All @@ -71,4 +59,4 @@ runs:

- name: 🛟 Install dependencies
shell: bash
run: pnpm install
run: pnpm install --frozen-lockfile
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# supported CodeQL languages.
#
name: "CodeQL"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/dependency-review.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: api
terraform_workspace: novu-prod-eu
# This is a workaround to an issue with matrix outputs
Expand All @@ -91,6 +92,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: api
terraform_workspace: novu-prod
# This is a workaround to an issue with matrix outputs
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-inbound-mail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: inbound_mail
terraform_workspace: novu-prod-eu
docker_image: ghcr.io/novuhq/novu/inbound-mail-ee:${{ github.sha }}
Expand All @@ -78,6 +79,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: inbound_mail
terraform_workspace: novu-prod
docker_image: ghcr.io/novuhq/novu/inbound-mail-ee:${{ github.sha }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: webhook
terraform_workspace: novu-prod-eu
docker_image: ${{ needs.build_prod_image.outputs.docker_image }}
Expand All @@ -67,6 +68,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: webhook
terraform_workspace: novu-prod
docker_image: ${{ needs.build_prod_image.outputs.docker_image }}
2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: worker
terraform_workspace: novu-prod-eu
# This is a workaround to an issue with matrix outputs
Expand All @@ -92,6 +93,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: worker
terraform_workspace: novu-prod
# This is a workaround to an issue with matrix outputs
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prod-deploy-ws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: ws
terraform_workspace: novu-prod-eu
# This is a workaround to an issue with matrix outputs
Expand All @@ -70,6 +71,7 @@ jobs:
uses: ./.github/workflows/reusable-app-service-deploy.yml
secrets: inherit
with:
environment: Production
service_name: ws
terraform_workspace: novu-prod
# This is a workaround to an issue with matrix outputs
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/reusable-app-service-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: Deploy Service Job
on:
workflow_call:
inputs:
environment:
required: true
type: string
terraform_workspace:
required: true
type: string
Expand All @@ -26,7 +29,7 @@ jobs:
deploy_service:
runs-on: ubuntu-latest
timeout-minutes: 80
environment: Production
environment: ${{ inputs.environment }}
env:
TF_WORKSPACE: ${{ inputs.terraform_workspace }}
permissions:
Expand Down
47 changes: 18 additions & 29 deletions .github/workflows/reusable-web-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,23 @@ jobs:

- uses: ./.github/actions/setup-project
id: setup-project
with:
cypress: true

- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint
projects: '@novu/web'
targets: lint,build
projects: '@novu/web,@novu/api,@novu/worker'

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

# Runs a single command using the runners shell
- name: Build
run: CI='' pnpm build:web

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

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

- name: Start Client
working-directory: apps/web
env:
REACT_APP_API_URL: http://localhost:1336
REACT_APP_WS_URL: http://localhost:1340
REACT_APP_WEBHOOK_URL: http://localhost:1341
run: pnpm pnpm start:static:build &
run: pnpm start:static:build &

- name: Start WS
run: pnpm start:ws:test &
Expand All @@ -65,40 +57,37 @@ jobs:
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:test &
run: cd apps/api && pnpm start:build &

- name: Start worker
run: cd apps/worker && pnpm start:test &
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 API
run: wait-on --timeout=180000 http://localhost:1336/v1/health-check

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

- name: Wait on WS
run: wait-on --timeout=180000 http://localhost:1340/v1/health-check

- name: Wait on WEB
run: wait-on --timeout=180000 http://localhost:4200
- 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 cypress install only when cache was not hit
- name: Cypress install
if: steps.setup-project.outputs.cypress_cache_hit != 'true'
working-directory: apps/web
run: pnpm cypress install



- uses: browser-actions/setup-chrome@latest
- run: |
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV
- name: Cypress run e2e
uses: cypress-io/github-action@v4
uses: cypress-io/github-action@v5
env:
NODE_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Loading

3 comments on commit f00e2f5

@github-actions
Copy link

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.