Skip to content

chore: Upgrade to pnpm 9, add conventional commit PR title linting #8241

chore: Upgrade to pnpm 9, add conventional commit PR title linting

chore: Upgrade to pnpm 9, add conventional commit PR title linting #8241

Workflow file for this run

name: Testing Pipeline
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
workflow_dispatch:
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@v4
spellcheck:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: streetsidesoftware/cspell-action@v5
get-affected:
name: Get Affected Packages
runs-on: ubuntu-latest
outputs:
test-unit: ${{ steps.get-projects-arrays.outputs.test-unit }}
test-e2e: ${{ steps.get-projects-arrays.outputs.test-e2e }}
test-e2e-ee: ${{ steps.get-projects-arrays.outputs.test-e2e-ee }}
test-cypress: ${{ steps.get-projects-arrays.outputs.test-cypress }}
test-providers: ${{ steps.get-projects-arrays.outputs.test-providers }}
test-packages: ${{ steps.get-projects-arrays.outputs.test-packages }}
test-libs: ${{ steps.get-projects-arrays.outputs.test-libs }}
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
# Get current branch name
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7.0.7
# Get base branch name to compare with. Base branch on a PR, "main" branch on pushing.
- name: Get base branch name
id: get-base-branch-name
run: |
if [[ "${{github.event.pull_request.base.ref}}" != "" ]]; then
echo "branch=${{github.event.pull_request.base.ref}}" >> $GITHUB_OUTPUT
else
echo "branch=main" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/setup-project
with:
slim: 'true'
# Configure Nx to be able to detect changes between branches when we are in a PR
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: ${{steps.get-base-branch-name.outputs.branch}}
- name: Get affected
id: get-projects-arrays
# When not in a PR and the current branch is main, pass --all flag. Otherwise pass the base branch
run: |
if [[ "${{github.event.pull_request.base.ref}}" == "" && "${{steps.branch-name.outputs.current_branch}}" == "main" ]]; then
echo "Running ALL"
echo "test-unit=$(pnpm run get-affected test:unit --all | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-e2e=$(pnpm run get-affected test:e2e --all | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-e2e-ee=$(pnpm run get-affected test:e2e:ee --all | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-cypress=$(pnpm run get-affected cypress:run --all | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-providers=$(pnpm run get-affected test --all providers | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-packages=$(pnpm run get-affected test --all packages | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-libs=$(pnpm run get-affected test --all libs | tail -n +5)" >> $GITHUB_OUTPUT
else
echo "Running PR origin/${{steps.get-base-branch-name.outputs.branch}}"
echo "test-unit=$(pnpm run get-affected test origin/${{steps.get-base-branch-name.outputs.branch}} | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-e2e=$(pnpm run get-affected test:e2e origin/${{steps.get-base-branch-name.outputs.branch}} | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-e2e-ee=$(pnpm run get-affected test:e2e:ee origin/${{steps.get-base-branch-name.outputs.branch}} | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-cypress=$(pnpm run get-affected cypress:run origin/${{steps.get-base-branch-name.outputs.branch}} | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-providers=$(pnpm run get-affected test origin/${{steps.get-base-branch-name.outputs.branch}} providers | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-packages=$(pnpm run get-affected test origin/${{steps.get-base-branch-name.outputs.branch}} packages | tail -n +5)" >> $GITHUB_OUTPUT
echo "test-libs=$(pnpm run get-affected test origin/${{steps.get-base-branch-name.outputs.branch}} libs | tail -n +5)" >> $GITHUB_OUTPUT
fi
test_web:
name: Test Web Cypress
needs: [get-affected]
# if: ${{ contains(fromJson(needs.get-affected.outputs.test-cypress), '@novu/web') }}
if: contains(github.event.pull_request.labels.*.name, 'run-e2e')
uses: ./.github/workflows/reusable-web-e2e.yml
secrets: inherit
with:
ee: true
test_widget:
name: Test Widget Cypress
needs: [get-affected]
uses: ./.github/workflows/reusable-widget-e2e.yml
with:
ee: true
if: contains(github.event.pull_request.labels.*.name, 'run-e2e')
# if: ${{ contains(fromJson(needs.get-affected.outputs.test-cypress), '@novu/widget') || contains(fromJson(needs.get-affected.outputs.test-unit), '@novu/notification-center') || contains(fromJson(needs.get-affected.outputs.test-unit), '@novu/ws') }}
secrets: inherit
test_providers:
name: Unit Test Providers
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-providers)[0] }}
timeout-minutes: 80
steps:
- run: echo '${{ needs.get-affected.outputs.test-providers }}'
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
with:
slim: 'true'
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint,build,test
parallel: 5
projects: ${{join(fromJson(needs.get-affected.outputs.test-providers), ',')}}
test_packages:
name: Unit Test Packages
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-packages)[0] }}
timeout-minutes: 80
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
- name: Display Test Packages
run: echo '${{ needs.get-affected.outputs.test-packages }}'
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Project
uses: ./.github/actions/setup-project
with:
slim: 'true'
- name: Setup Redis Cluster
uses: ./.github/actions/setup-redis-cluster
- name: Run Lint, Build, Test
uses: mansagroup/nrwl-nx-action@v3
env:
LOGGING_LEVEL: 'info'
with:
targets: lint,build,test
projects: ${{join(fromJson(needs.get-affected.outputs.test-packages), ',')}}
test_libs:
name: Unit Test Libs
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-libs)[0] }}
timeout-minutes: 80
steps:
- run: echo '${{ needs.get-affected.outputs.test-libs }}'
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint,build,test
projects: ${{join(fromJson(needs.get-affected.outputs.test-libs), ',')}}
test_unit_api:
name: Test API
needs: [get-affected]
if: contains(github.event.pull_request.labels.*.name, 'run-e2e')
strategy:
# The order is important for ee to be first, otherwise outputs not work correctly
matrix:
name: ['novu/api-ee', 'novu/api']
uses: ./.github/workflows/reusable-api-e2e.yml
with:
ee: ${{ contains (matrix.name,'-ee') }}
test-e2e-affected: ${{ contains(fromJson(needs.get-affected.outputs.test-e2e), '@novu/api') }}
test-e2e-ee-affected: ${{ contains(fromJson(needs.get-affected.outputs.test-e2e-ee), '@novu/api') }}
job-name: ${{ matrix.name }}
secrets: inherit
test_unit:
name: Unit Test
runs-on: ubuntu-latest
needs: [get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
timeout-minutes: 80
strategy:
# One job for each different project and node version
matrix:
projectName: ${{ fromJson(needs.get-affected.outputs.test-unit) }}
permissions:
contents: read
packages: write
deployments: write
id-token: write
steps:
- run: echo ${{ matrix.projectName }}
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
with:
# Don't run redis and etc... for other unit tests
slim: ${{ !contains(matrix.projectName, '@novu/api') && !contains(matrix.projectName, '@novu/worker') && !contains(matrix.projectName, '@novu/ws') && !contains(matrix.projectName, '@novu/inbound-mail')}}
- 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_openapi:
name: Validate OpenAPI
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-openapi