chore: use Nx affected tasks in CI (#5110)

Closes #5097

- Uses "nx affected" to detect what projects need to be checked in the
current PR (for now, `ci-front` and `ci-server` workflows only).
- Caches results of certain tasks (`lint`, `typecheck`, `test`,
`storybook:build`) when a PR pipeline runs. The next runs of the same
PR's pipeline will then be able to reuse the PR's task cache to execute
tasks faster.
- Caches Yarn's cache folder to install dependencies faster in CI jobs.
- Rewrites the node modules cache/install steps as a custom, reusable
Github action.
- Distributes `ci-front` jobs with a "matrix" strategy.
- Sets common tasks config at the root `nx.json`. For instance, to
activate the `typecheck` task in a project, add `typecheck: {}` to its
`project.json` and it'll use the default config set in `nx.json` for the
`typecheck` task. Options can be overridden in each individual
`project.json` if needed.
- Adds "scope" tags to some projects: `scope:frontend`, `scope:backend`,
`scope:shared`. An eslint rule ensures that `scope:frontend` only
depends on `scope:frontent` or `scope:shared` projects, same for
`scope:backend`. These tags are used by `nx affected` to filter projects
by scope and generates different task cache keys according to the
requested scope.
- Enables checks for twenty-emails in the `ci-server` workflow.
This commit is contained in:
Thaïs 2024-04-30 16:28:25 +02:00 committed by GitHub
parent a77cb023c0
commit c193663a71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 13485 additions and 13474 deletions

View File

@ -24,8 +24,16 @@ module.exports = {
allow: [], allow: [],
depConstraints: [ depConstraints: [
{ {
sourceTag: '*', sourceTag: 'scope:shared',
onlyDependOnLibsWithTags: ['*'], onlyDependOnLibsWithTags: ['scope:shared'],
},
{
sourceTag: 'scope:backend',
onlyDependOnLibsWithTags: ['scope:shared', 'scope:backend'],
},
{
sourceTag: 'scope:frontend',
onlyDependOnLibsWithTags: ['scope:shared', 'scope:frontend'],
}, },
], ],
}, },

View File

@ -0,0 +1,21 @@
name: Nx Affected CI
inputs:
parallel:
required: false
types: [number]
default: 3
tag:
required: false
types: [string]
tasks:
required: true
types: [string]
runs:
using: "composite"
steps:
- name: Get last successful commit
uses: nrwl/nx-set-shas@v4
- name: Run affected command
shell: bash
run: npx nx affected --nxBail --configuration=ci -t=${{ inputs.tasks }} --parallel=${{ inputs.parallel }} --exclude='*,!tag:${{ inputs.tag }}'

View File

@ -0,0 +1,29 @@
name: Restore Tasks Cache CI
inputs:
tag:
required: false
types: [string]
tasks:
required: false
types: [string]
default: all
suffix:
required: false
types: [string]
runs:
using: "composite"
steps:
- name: Compute tasks key
id: tasks-key
shell: bash
run: echo "key=${{ inputs.tasks }}" | tr , - >> $GITHUB_OUTPUT
- name: Restore tasks cache
uses: actions/cache@v3
with:
path: |
.cache
.nx/cache
key: tasks-cache-${{ inputs.tag }}-${{ steps.tasks-key.outputs.key }}${{ inputs.suffix }}-${{ github.sha }}
restore-keys: |
tasks-cache-${{ inputs.tag }}-${{ steps.tasks-key.outputs.key }}${{ inputs.suffix }}-

View File

@ -0,0 +1,23 @@
name: Yarn Install
runs:
using: "composite"
steps:
- name: Setup Node.js and get yarn cache
uses: actions/setup-node@v3
with:
node-version: "18"
cache: yarn
- name: Cache node modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
key: root-node_modules-${{ hashFiles('yarn.lock') }}
restore-keys: root-node_modules-
- name: Install Dependencies
shell: bash
run: yarn --immutable --check-cache
if: steps.node-modules-cache.outputs.cache-hit != 'true'

View File

@ -27,17 +27,13 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js - name: Install dependencies
uses: actions/setup-node@v3 uses: ./.github/workflows/actions/yarn-install
with:
node-version: "18"
- name: Front / Write .env - name: Front / Write .env
run: | run: |
cd packages/twenty-front cd packages/twenty-front
touch .env touch .env
echo "REACT_APP_SERVER_BASE_URL: $REACT_APP_SERVER_BASE_URL" >> .env echo "REACT_APP_SERVER_BASE_URL: $REACT_APP_SERVER_BASE_URL" >> .env
- name: Front / Install Dependencies
run: yarn
- name: Publish to Chromatic - name: Publish to Chromatic
run: | run: |
cd packages/twenty-front cd packages/twenty-front

View File

@ -15,33 +15,7 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
chrome-extension-yarn-install:
runs-on: ci-8-cores
env:
VITE_SERVER_BASE_URL: http://localhost:3000
VITE_FRONT_BASE_URL: http://localhost:3001
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Cache chrome extension node modules
uses: actions/cache@v3
with:
path: packages/twenty-chrome-extension/node_modules
key: chrome-extension-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: chrome-extension-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Chrome Extension / Install Dependencies
run: yarn
chrome-extension-build: chrome-extension-build:
needs: chrome-extension-yarn-install
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
VITE_SERVER_BASE_URL: http://localhost:3000 VITE_SERVER_BASE_URL: http://localhost:3000
@ -52,21 +26,7 @@ jobs:
with: with:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Node.js - name: Install dependencies
uses: actions/setup-node@v3 uses: ./.github/workflows/actions/yarn-install
with:
node-version: "18"
- name: Cache chrome extension node modules
uses: actions/cache@v3
with:
path: packages/twenty-chrome-extension/node_modules
key: chrome-extension-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: chrome-extension-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Chrome Extension / Run build - name: Chrome Extension / Run build
run: npx nx build twenty-chrome-extension run: npx nx build twenty-chrome-extension

View File

@ -21,12 +21,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Node.js - name: Install dependencies
uses: actions/setup-node@v3 uses: ./.github/workflows/actions/yarn-install
with:
node-version: "18"
- name: Docs / Install Dependencies
run: yarn
- name: Docs / Build Documentation - name: Docs / Build Documentation
run: npx nx build twenty-docs run: npx nx build twenty-docs
vale: vale:

View File

@ -17,167 +17,63 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
front-yarn-install: front-sb-test:
runs-on: ci-8-cores
env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Cache front node modules
uses: actions/cache@v3
with:
path: packages/twenty-front/node_modules
key: front-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: front-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Front / Install Dependencies
run: yarn
front-pages-sb-test:
needs: front-yarn-install
runs-on: ci-8-cores runs-on: ci-8-cores
strategy:
matrix:
storybook_scope: [pages, modules]
env: env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000 REACT_APP_SERVER_BASE_URL: http://localhost:3000
STORYBOOK_SCOPE: ${{ matrix.storybook_scope }}
steps: steps:
- name: Cancel Previous Runs - name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0 uses: styfle/cancel-workflow-action@0.11.0
with: with:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- uses: actions/checkout@v4 - name: Fetch local actions
- name: Setup Node.js uses: actions/checkout@v4
uses: actions/setup-node@v3 - name: Install dependencies
with: uses: ./.github/workflows/actions/yarn-install
node-version: "18"
- name: Front / Write .env
run: |
cd packages/twenty-front
cp .env.example .env
- name: Cache front node modules
uses: actions/cache@v3
with:
path: packages/twenty-front/node_modules
key: front-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: front-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Install Playwright - name: Install Playwright
run: cd packages/twenty-front && npx playwright install run: cd packages/twenty-front && npx playwright install
- name: Front / Restore Storybook Task Cache
uses: ./.github/workflows/actions/task-cache
with:
tag: scope:frontend
tasks: storybook:build
suffix: _${{ matrix.storybook_scope }}
- name: Front / Write .env
run: npx nx reset:env twenty-front
- name: Run storybook tests - name: Run storybook tests
run: | run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"STORYBOOK_SCOPE=pages npx nx run twenty-front:storybook:static:ci" \ "npx nx storybook:static twenty-front" \
"npx wait-on tcp:6006 && STORYBOOK_SCOPE=pages npx nx run twenty-front:storybook:test" "npx wait-on tcp:6006 && npx nx storybook:test twenty-front"
front-modules-sb-test: front-task:
needs: front-yarn-install
runs-on: ci-4-cores
env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Front / Write .env
run: |
cd packages/twenty-front
cp .env.example .env
- name: Cache front node modules
uses: actions/cache@v3
with:
path: packages/twenty-front/node_modules
key: front-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: front-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Install Playwright
run: cd packages/twenty-front && npx playwright install
- name: Run storybook tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"STORYBOOK_SCOPE=modules npx nx run twenty-front:storybook:static:ci" \
"npx wait-on tcp:6006 && STORYBOOK_SCOPE=modules npx nx run twenty-front:storybook:test"
front-lint-tsc:
needs: front-yarn-install
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
task: [lint, typecheck, test]
env: env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000 REACT_APP_SERVER_BASE_URL: http://localhost:3000
steps: steps:
- name: Cancel Previous Runs - name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0 uses: styfle/cancel-workflow-action@0.11.0
with: with:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- uses: actions/checkout@v4 - name: Fetch local actions and base branch history
- name: Setup Node.js uses: actions/checkout@v4
uses: actions/setup-node@v3
with: with:
node-version: "18" fetch-depth: 0
- name: Cache front node modules - name: Install dependencies
uses: actions/cache@v3 uses: ./.github/workflows/actions/yarn-install
- name: Front / Restore Task Cache
uses: ./.github/workflows/actions/task-cache
with: with:
path: packages/twenty-front/node_modules tag: scope:frontend
key: front-node_modules-${{hashFiles('yarn.lock')}} tasks: ${{ matrix.task }}
restore-keys: front-node_modules- - name: Front / Run task
- name: Cache root node modules uses: ./.github/workflows/actions/nx-affected
uses: actions/cache@v3
with: with:
path: node_modules tag: scope:frontend
key: root-node_modules-${{hashFiles('yarn.lock')}} tasks: ${{ matrix.task }}
restore-keys: root-node_modules-
- name: UI / Run linter
run: npx nx lint twenty-ui
- name: UI / Run Typescript Check
run: npx nx run twenty-ui:typecheck:ci
- name: Front / Run linter
run: npx nx run twenty-front:lint:ci
- name: Front / Run Typescript Check
run: npx nx run twenty-front:typecheck:ci
front-jest:
needs: front-yarn-install
runs-on: ubuntu-latest
env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Cache front node modules
uses: actions/cache@v3
with:
path: packages/twenty-front/node_modules
key: front-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: front-node_modules-
- name: Cache root node modules
uses: actions/cache@v3
with:
path: node_modules
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Front / Run jest
run: npx nx test twenty-front --configuration=ci

View File

@ -28,22 +28,29 @@ jobs:
ports: ports:
- 5432:5432 - 5432:5432
steps: steps:
- uses: actions/checkout@v4 - name: Fetch local actions and base branch history
- name: Setup Node.js uses: actions/checkout@v4
uses: actions/setup-node@v3
with: with:
node-version: "18" fetch-depth: 0
- name: Server / Install Dependencies - name: Install dependencies
run: yarn uses: ./.github/workflows/actions/yarn-install
- name: Server / Run linter - name: Server / Restore Tasks Cache
run: npx nx lint twenty-server uses: ./.github/workflows/actions/task-cache
- name: Server / Run jest tests with:
run: npx nx test:unit twenty-server tag: scope:backend
- name: Server / Run lint & typecheck
uses: ./.github/workflows/actions/nx-affected
with:
tag: scope:backend
tasks: lint,typecheck
- name: Server / Run tests
uses: ./.github/workflows/actions/nx-affected
with:
tag: scope:backend
tasks: test
- name: Server / Build - name: Server / Build
run: npx nx build twenty-server run: npx nx build twenty-server
- name: Server / Write .env - name: Server / Write .env
run: | run: npx nx reset:env twenty-server
cd packages/twenty-server
cp .env.example .env
- name: Worker / Run - name: Worker / Run
run: MESSAGE_QUEUE_TYPE=sync npx nx worker twenty-server run: MESSAGE_QUEUE_TYPE=sync npx nx worker twenty-server

View File

@ -21,12 +21,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Node.js - name: Install dependencies
uses: actions/setup-node@v3 uses: ./.github/workflows/actions/yarn-install
with:
node-version: "18"
- name: Utils / Install Dependencies
run: yarn
- name: Utils / Run Danger.js - name: Utils / Run Danger.js
run: cd packages/twenty-utils && npx nx danger:ci run: cd packages/twenty-utils && npx nx danger:ci
env: env:

View File

@ -27,12 +27,8 @@ jobs:
- 5432:5432 - 5432:5432
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Node.js - name: Install dependencies
uses: actions/setup-node@v3 uses: ./.github/workflows/actions/yarn-install
with:
node-version: "18"
- name: Website / Install Dependencies
run: yarn
- name: Website / Run migrations - name: Website / Run migrations
run: npx nx database:migrate twenty-website run: npx nx database:migrate twenty-website
env: env:

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ dist
storybook-static storybook-static
*.tsbuildinfo *.tsbuildinfo
.eslintcache .eslintcache
.cache

108
nx.json
View File

@ -1,4 +1,8 @@
{ {
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/.github/workflows/**/*"]
},
"targetDefaults": { "targetDefaults": {
"build": { "build": {
"cache": true, "cache": true,
@ -9,17 +13,73 @@
"dependsOn": ["^build"] "dependsOn": ["^build"]
}, },
"lint": { "lint": {
"cache": true "executor": "@nx/eslint:lint",
"cache": true,
"outputs": ["{options.outputFile}"],
"options": {
"eslintConfig": "{projectRoot}/.eslintrc.cjs",
"cache": true,
"cacheLocation": "{workspaceRoot}/.cache/eslint",
"ignorePath": "{workspaceRoot}/.gitignore"
},
"configurations": {
"ci": { "cacheStrategy": "content" },
"fix": { "fix": true }
}
},
"fmt": {
"executor": "nx:run-commands",
"cache": true,
"options": {
"cwd": "{projectRoot}",
"command": "prettier {args.files} --check --cache {args.cache} --cache-location {args.cacheLocation} --write {args.write} --cache-strategy {args.cacheStrategy}",
"cache": true,
"cacheLocation": "../../.cache/prettier/{projectRoot}",
"cacheStrategy": "metadata",
"write": false
},
"configurations": {
"ci": { "cacheStrategy": "content" },
"fix": { "write": true }
}
},
"typecheck": {
"executor": "nx:run-commands",
"cache": true,
"options": {
"cwd": "{projectRoot}",
"command": "tsc -b tsconfig.json --incremental"
},
"configurations": {
"watch": { "watch": true }
}
}, },
"test": { "test": {
"executor": "@nx/jest:jest",
"cache": true, "cache": true,
"dependsOn": ["^build"] "dependsOn": ["^build"],
"outputs": ["{projectRoot}/coverage"],
"options": {
"jestConfig": "{projectRoot}/jest.config.ts",
"coverage": true,
"coverageReporters": ["text-summary"],
"cacheDirectory": "../../.cache/jest/{projectRoot}"
},
"configurations": {
"ci": {
"ci": true,
"maxWorkers": 3
},
"coverage": { "coverageReporters": ["lcov", "text"] },
"watch": { "watch": true }
}
}, },
"test:e2e": { "test:e2e": {
"cache": true, "cache": true,
"dependsOn": ["^build"] "dependsOn": ["^build"]
}, },
"storybook:build": { "storybook:build": {
"executor": "@nx/storybook:build",
"cache": true, "cache": true,
"dependsOn": ["^build"], "dependsOn": ["^build"],
"inputs": [ "inputs": [
@ -27,11 +87,51 @@
"^default", "^default",
"{projectRoot}/.storybook/**/*", "{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json" "{projectRoot}/tsconfig.storybook.json"
] ],
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "{projectRoot}/storybook-static",
"configDir": "{projectRoot}/.storybook"
}
}, },
"storybook:dev": { "storybook:dev": {
"executor": "@nx/storybook:storybook",
"cache": true, "cache": true,
"dependsOn": ["^build"] "dependsOn": ["^build"],
"options": {
"configDir": "{projectRoot}/.storybook"
}
},
"storybook:static": {
"executor": "@nx/web:file-server",
"options": {
"staticFilePath": "{projectRoot}/storybook-static",
"watch": false
}
},
"storybook:test": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"commands": [
"test-storybook --url {options.url} --maxWorkers=3 --coverage",
"nyc report --reporter=lcov --reporter=text-summary -t coverage/storybook --report-dir coverage/storybook --check-coverage"
],
"parallel": false
}
},
"chromatic": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "cross-var chromatic --project-token=$CHROMATIC_PROJECT_TOKEN --build-script-name=storybook:build --exit-zero-on-changes={args.ci}",
"ci": false
},
"configurations": {
"ci": {
"ci": true
}
}
}, },
"@nx/jest:jest": { "@nx/jest:jest": {
"cache": true, "cache": true,

View File

@ -335,7 +335,7 @@
"version": "0.2.1", "version": "0.2.1",
"nx": {}, "nx": {},
"scripts": { "scripts": {
"start": "nx run-many -t start -p twenty-server twenty-front" "start": "npx nx run-many -t start -p twenty-server twenty-front"
}, },
"workspaces": { "workspaces": {
"packages": [ "packages": [

View File

@ -6,9 +6,9 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-chrome-extension node ../../node_modules/nx/bin/nx.js", "nx": "NX_DEFAULT_PROJECT=twenty-chrome-extension node ../../node_modules/nx/bin/nx.js",
"clean": "rimraf ./dist", "clean": "npx rimraf ./dist",
"start": "yarn clean && VITE_MODE=development vite", "start": "yarn clean && VITE_MODE=development vite",
"build": "yarn clean && tsc && vite build", "build": "yarn clean && npx tsc && npx vite build",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0 --config .eslintrc.cjs", "lint": "eslint . --report-unused-disable-directives --max-warnings 0 --config .eslintrc.cjs",
"graphql:generate": "graphql-codegen", "graphql:generate": "graphql-codegen",
"fmt": "prettier --check \"src/**/*.ts\" \"src/**/*.tsx\"", "fmt": "prettier --check \"src/**/*.ts\" \"src/**/*.tsx\"",

View File

@ -1,7 +1,7 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc" "outDir": "../../.cache/tsc"
}, },
"exclude": [ "exclude": [
"**/*.spec.ts", "**/*.spec.ts",

View File

@ -1,7 +1,7 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc", "outDir": "../../.cache/tsc",
"types": ["jest", "node"] "types": ["jest", "node"]
}, },
"include": [ "include": [

View File

@ -7,9 +7,7 @@
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "./dist/index.js", "main": "./dist/index.js",
"scripts": { "scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-emails node ../../node_modules/nx/bin/nx.js", "build": "npx vite build"
"build": "npx vite build",
"lint": "eslint"
}, },
"exports": { "exports": {
".": { ".": {
@ -21,8 +19,5 @@
"node": "^18.17.1", "node": "^18.17.1",
"npm": "please-use-yarn", "npm": "please-use-yarn",
"yarn": "^4.0.2" "yarn": "^4.0.2"
},
"nx": {
"projectType": "library"
} }
} }

View File

@ -0,0 +1,35 @@
{
"name": "twenty-emails",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"tags": ["scope:backend"],
"targets": {
"build": {
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "{projectRoot}/dist"
}
},
"typecheck": {},
"lint": {
"options": {
"lintFilePatterns": [
"{projectRoot}/src/**/*.{ts,tsx,json}",
"{projectRoot}/package.json"
],
"reportUnusedDisableDirectives": "error"
},
"configurations": {
"fix": {}
}
},
"fmt": {
"options": {
"files": "src"
},
"configurations": {
"fix": {}
}
}
}
}

View File

@ -1,3 +1,5 @@
/* eslint-disable @nx/workspace-no-hardcoded-colors */
const grayScale = { const grayScale = {
gray100: '#000000', gray100: '#000000',
gray90: '#141414', gray90: '#141414',

View File

@ -1,5 +1,6 @@
import { PropsWithChildren } from 'react'; import { PropsWithChildren } from 'react';
import { Container, Html } from '@react-email/components'; import { Container, Html } from '@react-email/components';
import { BaseHead } from 'src/components/BaseHead'; import { BaseHead } from 'src/components/BaseHead';
import { Logo } from 'src/components/Logo'; import { Logo } from 'src/components/Logo';

View File

@ -1,4 +1,5 @@
import { Font, Head } from '@react-email/components'; import { Font, Head } from '@react-email/components';
import { emailTheme } from 'src/common-style'; import { emailTheme } from 'src/common-style';
export const BaseHead = () => { export const BaseHead = () => {

View File

@ -1,5 +1,6 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { Button } from '@react-email/button'; import { Button } from '@react-email/button';
import { emailTheme } from 'src/common-style'; import { emailTheme } from 'src/common-style';
const callToActionStyle = { const callToActionStyle = {

View File

@ -2,6 +2,7 @@ import { ReactNode } from 'react';
import { Column } from '@react-email/components'; import { Column } from '@react-email/components';
import { Row } from '@react-email/row'; import { Row } from '@react-email/row';
import { Text } from '@react-email/text'; import { Text } from '@react-email/text';
import { emailTheme } from 'src/common-style'; import { emailTheme } from 'src/common-style';
const rowStyle = { const rowStyle = {

View File

@ -1,5 +1,6 @@
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { Link as EmailLink } from '@react-email/components'; import { Link as EmailLink } from '@react-email/components';
import { emailTheme } from 'src/common-style'; import { emailTheme } from 'src/common-style';
const linkStyle = { const linkStyle = {

View File

@ -1,5 +1,6 @@
import { PropsWithChildren } from 'react'; import { PropsWithChildren as MainTextProps } from 'react';
import { Text } from '@react-email/text'; import { Text } from '@react-email/text';
import { emailTheme } from 'src/common-style'; import { emailTheme } from 'src/common-style';
const mainTextStyle = { const mainTextStyle = {
@ -8,6 +9,6 @@ const mainTextStyle = {
color: emailTheme.font.colors.primary, color: emailTheme.font.colors.primary,
}; };
export const MainText = ({ children }: PropsWithChildren) => { export const MainText = ({ children }: MainTextProps) => {
return <Text style={mainTextStyle}>{children}</Text>; return <Text style={mainTextStyle}>{children}</Text>;
}; };

View File

@ -4,7 +4,7 @@ import { HighlightedText } from 'src/components/HighlightedText';
import { MainText } from 'src/components/MainText'; import { MainText } from 'src/components/MainText';
import { Title } from 'src/components/Title'; import { Title } from 'src/components/Title';
type CleanInactiveWorkspaceEmailData = { type CleanInactiveWorkspaceEmailProps = {
daysLeft: number; daysLeft: number;
userName: string; userName: string;
workspaceDisplayName: string; workspaceDisplayName: string;
@ -14,7 +14,7 @@ export const CleanInactiveWorkspaceEmail = ({
daysLeft, daysLeft,
userName, userName,
workspaceDisplayName, workspaceDisplayName,
}: CleanInactiveWorkspaceEmailData) => { }: CleanInactiveWorkspaceEmailProps) => {
const dayOrDays = daysLeft > 1 ? 'days' : 'day'; const dayOrDays = daysLeft > 1 ? 'days' : 'day';
const remainingDays = daysLeft > 1 ? `${daysLeft} ` : ''; const remainingDays = daysLeft > 1 ? `${daysLeft} ` : '';

View File

@ -1,4 +1,5 @@
import { Column, Row, Section } from '@react-email/components'; import { Column, Row, Section } from '@react-email/components';
import { BaseEmail } from 'src/components/BaseEmail'; import { BaseEmail } from 'src/components/BaseEmail';
import { MainText } from 'src/components/MainText'; import { MainText } from 'src/components/MainText';
import { Title } from 'src/components/Title'; import { Title } from 'src/components/Title';

View File

@ -1,4 +1,5 @@
import { format } from 'date-fns'; import { format } from 'date-fns';
import { BaseEmail } from 'src/components/BaseEmail'; import { BaseEmail } from 'src/components/BaseEmail';
import { CallToAction } from 'src/components/CallToAction'; import { CallToAction } from 'src/components/CallToAction';
import { MainText } from 'src/components/MainText'; import { MainText } from 'src/components/MainText';

View File

@ -1,7 +1,7 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc", "outDir": "../../.cache/tsc",
"types": [ "types": [
"node", "node",
"@nx/react/typings/image.d.ts", "@nx/react/typings/image.d.ts",

View File

@ -2,6 +2,7 @@
"name": "twenty-front", "name": "twenty-front",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application", "projectType": "application",
"tags": ["scope:frontend"],
"targets": { "targets": {
"build": { "build": {
"outputs": ["{options.outputPath}"], "outputs": ["{options.outputPath}"],
@ -24,115 +25,58 @@
"open": true "open": true
} }
}, },
"typecheck": { "reset:env": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"inputs": ["{projectRoot}/.env.example"],
"outputs": ["{projectRoot}/.env"],
"cache": true,
"options": { "options": {
"cwd": "{projectRoot}", "cwd": "{projectRoot}",
"command": "tsc -b tsconfig.json", "command": "cp .env.example .env"
"args": ["--incremental"]
},
"configurations": {
"ci": { "args": [] },
"watch": { "watch": true }
} }
}, },
"typecheck": {},
"lint": { "lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": { "options": {
"eslintConfig": "{projectRoot}/.eslintrc.cjs",
"ignorePath": "{workspaceRoot}/.gitignore",
"lintFilePatterns": [ "lintFilePatterns": [
"{projectRoot}/src/**/*.{ts,tsx,json}", "{projectRoot}/src/**/*.{ts,tsx,json}",
"{projectRoot}/package.json" "{projectRoot}/package.json"
], ],
"maxWarnings": 0, "maxWarnings": 0,
"reportUnusedDisableDirectives": "error", "reportUnusedDisableDirectives": "error"
"cache": true
}, },
"configurations": { "configurations": {
"ci": { "ci": { "eslintConfig": "{projectRoot}/.eslintrc-ci.cjs" },
"eslintConfig": "{projectRoot}/.eslintrc-ci.cjs", "fix": {}
"cache": false
},
"fix": {
"fix": true
}
} }
}, },
"fmt": { "fmt": {
"executor": "nx:run-commands",
"inputs": ["{projectRoot}/src/**/*"],
"cache": true,
"options": { "options": {
"cwd": "{projectRoot}", "files": "src"
"command": "prettier src --check"
}, },
"configurations": { "configurations": {
"fix": { "args": ["--write"] } "fix": {}
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{projectRoot}/coverage"],
"options": {
"jestConfig": "{projectRoot}/jest.config.ts",
"coverage": true,
"coverageReporters": ["text-summary"]
},
"configurations": {
"ci": {
"ci": true,
"maxWorkers": 3
},
"coverage": {
"coverageReporters": ["lcov", "text"]
},
"watch": { "watch": true }
}
},
"storybook:build": {
"executor": "@nx/storybook:build",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "{projectRoot}/storybook-static",
"configDir": "{projectRoot}/.storybook"
} }
}, },
"test": {},
"storybook:build": {},
"storybook:dev": { "storybook:dev": {
"executor": "@nx/storybook:storybook", "options": { "port": 6006 }
"options": {
"port": 6006,
"configDir": "{projectRoot}/.storybook"
}
}, },
"storybook:static": { "storybook:static": {
"executor": "@nx/web:file-server",
"options": { "options": {
"buildTarget": "twenty-front:storybook:build", "buildTarget": "twenty-front:storybook:build",
"port": 6006, "port": 6006
"staticFilePath": "{projectRoot}/storybook-static",
"watch": false
} }
}, },
"storybook:test": { "storybook:test": {
"executor": "nx:run-commands",
"options": { "options": {
"cwd": "{projectRoot}", "url": "http://localhost:6006"
"commands": [
"test-storybook --url http://localhost:6006 --maxWorkers=3 --coverage",
"nyc report --reporter=lcov --reporter=text-summary -t coverage/storybook --report-dir coverage/storybook --check-coverage"
],
"parallel": false
}, },
"configurations": { "configurations": {
"docs": { "docs": { "env": { "STORYBOOK_SCOPE": "ui-docs" } },
"commands": ["STORYBOOK_SCOPE=ui-docs nx storybook:test"] "modules": { "env": { "STORYBOOK_SCOPE": "modules" } },
}, "pages": { "env": { "STORYBOOK_SCOPE": "pages" } }
"modules": {
"commands": ["STORYBOOK_SCOPE=modules nx storybook:test"]
},
"pages": { "commands": ["STORYBOOK_SCOPE=pages nx storybook:test"] }
} }
}, },
"graphql:generate": { "graphql:generate": {
@ -144,24 +88,13 @@
}, },
"configurations": { "configurations": {
"data": { "data": {
"args": ["--config=codegen.cjs"] "config": "codegen.cjs"
}, },
"metadata": { "metadata": {
"args": ["--config=codegen-metadata.cjs"] "config": "codegen-metadata.cjs"
} }
} }
}, },
"chromatic": { "chromatic": {}
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "cross-var chromatic --project-token=$CHROMATIC_PROJECT_TOKEN --build-script-name=storybook:build"
},
"configurations": {
"ci": {
"args": ["--exit-zero-on-changes"]
}
}
}
} }
} }

View File

@ -9,12 +9,12 @@ import {
} from '@/object-record/record-field/types/FieldMetadata'; } from '@/object-record/record-field/types/FieldMetadata';
import { type } from 'os'; import { type } from 'os';
import { FieldMetadataType } from '~/generated-metadata/graphql'; import { FieldMetadataType } from '~/generated-metadata/graphql';
import { mockedCompanyObjectMetadataItem, mockedPersonObjectMetadataItem } from '~/testing/mock-data/metadata'; import {
; mockedCompanyObjectMetadataItem,
mockedPersonObjectMetadataItem,
} from '~/testing/mock-data/metadata';
export const fieldMetadataId = 'fieldMetadataId'; export const fieldMetadataId = 'fieldMetadataId';
export const textfieldDefinition: FieldDefinition<FieldTextMetadata> = { export const textfieldDefinition: FieldDefinition<FieldTextMetadata> = {
fieldMetadataId, fieldMetadataId,
label: 'User Name', label: 'User Name',
@ -64,7 +64,7 @@ export const linkFieldDefinition: FieldDefinition<FieldLinkMetadata> = {
label: 'LinkedIn URL', label: 'LinkedIn URL',
iconName: 'url', iconName: 'url',
type: FieldMetadataType.Link, type: FieldMetadataType.Link,
defaultValue: { label: '', url: ''}, defaultValue: { label: '', url: '' },
metadata: { metadata: {
fieldName: 'linkedInURL', fieldName: 'linkedInURL',
placeHolder: 'https://linkedin.com/user', placeHolder: 'https://linkedin.com/user',

View File

@ -19,7 +19,7 @@
"noUnusedParameters": false, "noUnusedParameters": false,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"outDir": "../../dist/out-tsc", "outDir": "../../.cache/tsc",
"paths": { "paths": {
"@/*": ["packages/twenty-front/src/modules/*"], "@/*": ["packages/twenty-front/src/modules/*"],
"~/*": ["packages/twenty-front/src/*"], "~/*": ["packages/twenty-front/src/*"],

View File

@ -3,7 +3,7 @@
"collection": "@nestjs/schematics", "collection": "@nestjs/schematics",
"sourceRoot": "src", "sourceRoot": "src",
"compilerOptions": { "compilerOptions": {
"builder": "swc", "builder": "swc",
"typeCheck": true "typeCheck": true
} }
} }

View File

@ -2,6 +2,7 @@
"name": "twenty-server", "name": "twenty-server",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application", "projectType": "application",
"tags": ["scope:backend"],
"targets": { "targets": {
"build": { "build": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
@ -35,6 +36,16 @@
"command": "nx start --debug" "command": "nx start --debug"
} }
}, },
"reset:env": {
"executor": "nx:run-commands",
"inputs": ["{projectRoot}/.env.example"],
"outputs": ["{projectRoot}/.env"],
"cache": true,
"options": {
"cwd": "{projectRoot}",
"command": "cp .env.example .env"
}
},
"command": { "command": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"dependsOn": ["build"], "dependsOn": ["build"],
@ -81,42 +92,16 @@
} }
}, },
"lint": { "lint": {
"executor": "@nx/eslint:lint",
"options": { "options": {
"eslintConfig": "{projectRoot}/.eslintrc.cjs",
"ignorePath": "{workspaceRoot}/.gitignore",
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"] "lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"]
}, },
"configurations": { "configurations": {
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] }, "ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
"fix": { "fix": true } "fix": {}
} }
}, },
"test:unit": { "test": {},
"executor": "nx:run-commands", "test:debug": {
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"command": "jest"
}
},
"test:unit:watch": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"command": "jest --watch"
}
},
"test:unit:coverage": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"command": "jest --coverage"
}
},
"test:unit:debug": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
"cwd": "packages/twenty-server", "cwd": "packages/twenty-server",

View File

@ -81,11 +81,13 @@ describe('CompanyResolver (e2e)', () => {
.expect(200) .expect(200)
.expect((res) => { .expect((res) => {
const data = res.body.data.findManyCompany; const data = res.body.data.findManyCompany;
expect(data).toBeDefined(); expect(data).toBeDefined();
expect(Array.isArray(data)).toBe(true); expect(Array.isArray(data)).toBe(true);
expect(data.length).toBeGreaterThan(0); expect(data.length).toBeGreaterThan(0);
const company = data.find((c) => c.id === companyId); const company = data.find((c) => c.id === companyId);
expect(company).toBeDefined(); expect(company).toBeDefined();
expect(company).toHaveProperty('id'); expect(company).toHaveProperty('id');
expect(company).toHaveProperty('name', 'New Company'); expect(company).toHaveProperty('name', 'New Company');
@ -94,6 +96,7 @@ describe('CompanyResolver (e2e)', () => {
// Check if we have access to ressources outside of our workspace // Check if we have access to ressources outside of our workspace
const instagramCompany = data.find((c) => c.name === 'Instagram'); const instagramCompany = data.find((c) => c.name === 'Instagram');
expect(instagramCompany).toBeUndefined(); expect(instagramCompany).toBeUndefined();
}); });
}); });

View File

@ -31,7 +31,7 @@ export const createApp = async (
imports: [AppModule], imports: [AppModule],
}); });
if (!!config.moduleBuilderHook) { if (config.moduleBuilderHook) {
moduleBuilder = config.moduleBuilderHook(moduleBuilder); moduleBuilder = config.moduleBuilderHook(moduleBuilder);
} }

View File

@ -3,6 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/twenty-ui/src", "sourceRoot": "packages/twenty-ui/src",
"projectType": "library", "projectType": "library",
"tags": ["scope:frontend"],
"targets": { "targets": {
"build": { "build": {
"dependsOn": ["^build", "generateBarrels"] "dependsOn": ["^build", "generateBarrels"]
@ -21,68 +22,40 @@
} }
}, },
"lint": { "lint": {
"executor": "@nx/eslint:lint",
"options": { "options": {
"eslintConfig": "{projectRoot}/.eslintrc.cjs",
"ignorePath": "{workspaceRoot}/.gitignore",
"lintFilePatterns": [ "lintFilePatterns": [
"{projectRoot}/src/**/*.{ts,tsx,json}", "{projectRoot}/src/**/*.{ts,tsx,json}",
"{projectRoot}/package.json" "{projectRoot}/package.json"
], ]
"cache": true
}, },
"configurations": { "configurations": {
"fix": { "fix": true } "fix": {}
} }
}, },
"test": { "fmt": {
"executor": "@nx/jest:jest",
"outputs": ["{projectRoot}/coverage"],
"options": { "options": {
"jestConfig": "{projectRoot}/jest.config.ts" "files": "src"
}
},
"typecheck": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "tsc -b tsconfig.json",
"incremental": true
}, },
"configurations": { "configurations": {
"ci": { "incremental": false }, "fix": {}
"watch": { "watch": true }
} }
}, },
"test": {},
"typecheck": {},
"storybook:build": {},
"storybook:dev": { "storybook:dev": {
"executor": "@nx/storybook:storybook", "options": { "port": 6007 }
"options": {
"port": 6007,
"configDir": "{projectRoot}/.storybook"
},
"configurations": {
"ci": { "quiet": true }
}
}, },
"storybook:build": { "storybook:static": {
"executor": "@nx/storybook:build",
"outputs": ["{options.outputDir}"],
"options": { "options": {
"outputDir": "{projectRoot}/storybook-static", "buildTarget": "twenty-ui:storybook:build",
"configDir": "{projectRoot}/.storybook" "port": 6007
},
"configurations": {
"ci": {
"quiet": true
}
} }
}, },
"storybook:test": { "storybook:test": {
"executor": "nx:run-commands",
"options": { "options": {
"command": "test-storybook -c {projectRoot}/.storybook --url=http://localhost:6007" "url": "http://localhost:6007"
} }
} }
}, }
"tags": []
} }

View File

@ -8,7 +8,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"noEmit": true, "noEmit": true,
"types": ["node"], "types": ["node"],
"outDir": "../../dist/out-tsc", "outDir": "../../.cache/tsc",
"paths": { "paths": {
"@ui/*": ["packages/twenty-ui/src/*"] "@ui/*": ["packages/twenty-ui/src/*"]
} }

View File

@ -2,20 +2,18 @@
"name": "eslint-rules", "name": "eslint-rules",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "tools/eslint-rules", "sourceRoot": "tools/eslint-rules",
"tags": ["scope:shared"],
"targets": { "targets": {
"lint": { "lint": {
"executor": "@nx/eslint:lint",
"options": { "options": {
"lintFilePatterns": ["{projectRoot}/**/*.ts"], "eslintConfig": "{workspaceRoot}/.eslintrc.cjs",
"fix": true "lintFilePatterns": ["{projectRoot}/**/*.ts"]
},
"configurations": {
"fix": {}
} }
}, },
"test": { "typecheck": {},
"executor": "@nx/jest:jest", "test": {}
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "tools/eslint-rules/jest.config.ts"
}
}
} }
} }

View File

@ -1,6 +1,7 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../.cache/tsc",
"esModuleInterop": true, "esModuleInterop": true,
"moduleResolution": "node16", "moduleResolution": "node16",
"module": "node16" "module": "node16"

View File

@ -1,7 +1,6 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"] "types": ["node"]
}, },
"exclude": ["**/*.spec.ts"], "exclude": ["**/*.spec.ts"],

View File

@ -1,7 +1,6 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["jest", "node"] "types": ["jest", "node"]
}, },
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]