mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 21:47:38 +00:00
## Summary Fully replaces ESLint with OxLint across the entire monorepo: - **Replaced all ESLint configs** (`eslint.config.mjs`) with OxLint configs (`.oxlintrc.json`) for every package: `twenty-front`, `twenty-server`, `twenty-emails`, `twenty-ui`, `twenty-shared`, `twenty-sdk`, `twenty-zapier`, `twenty-docs`, `twenty-website`, `twenty-apps/*`, `create-twenty-app` - **Migrated custom lint rules** from ESLint plugin format to OxLint JS plugin system (`@oxlint/plugins`), including `styled-components-prefixed-with-styled`, `no-hardcoded-colors`, `sort-css-properties-alphabetically`, `graphql-resolvers-should-be-guarded`, `rest-api-methods-should-be-guarded`, `max-consts-per-file`, and Jotai-related rules - **Migrated custom rule tests** from ESLint `RuleTester` + Jest to `oxlint/plugins-dev` `RuleTester` + Vitest - **Removed all ESLint dependencies** from `package.json` files and regenerated lockfiles - **Updated Nx targets** (`lint`, `lint:diff-with-main`, `fmt`) in `nx.json` and per-project `project.json` to use `oxlint` commands with proper `dependsOn` for plugin builds - **Updated CI workflows** (`.github/workflows/ci-*.yaml`) — no more ESLint executor - **Updated IDE setup**: replaced `dbaeumer.vscode-eslint` with `oxc.oxc-vscode` extension, configured `source.fixAll.oxc` and format-on-save with Prettier - **Replaced all `eslint-disable` comments** with `oxlint-disable` equivalents across the codebase - **Updated docs** (`twenty-docs`) to reference OxLint instead of ESLint - **Renamed** `twenty-eslint-rules` package to `twenty-oxlint-rules` ### Temporarily disabled rules (tracked in `OXLINT_MIGRATION_TODO.md`) | Rule | Package | Violations | Auto-fixable | |------|---------|-----------|-------------| | `twenty/sort-css-properties-alphabetically` | twenty-front | 578 | Yes | | `typescript/consistent-type-imports` | twenty-server | 3814 | Yes | | `twenty/max-consts-per-file` | twenty-server | 94 | No | ### Dropped plugins (no OxLint equivalent) `eslint-plugin-project-structure`, `lingui/*`, `@stylistic/*`, `import/order`, `prefer-arrow/prefer-arrow-functions`, `eslint-plugin-mdx`, `@next/eslint-plugin-next`, `eslint-plugin-storybook`, `eslint-plugin-react-refresh`. Partial coverage for `jsx-a11y` and `unused-imports`. ### Additional fixes (pre-existing issues exposed by merge) - Fixed `EmailThreadPreview.tsx` broken import from main rename (`useOpenEmailThreadInSidePanel`) - Restored truthiness guard in `getActivityTargetObjectRecords.ts` - Fixed `AgentTurnResolver` return types to match entity (virtual `fileMediaType`/`fileUrl` are resolved via `@ResolveField()`) ## Test plan - [x] `npx nx lint twenty-front` passes - [x] `npx nx lint twenty-server` passes - [x] `npx nx lint twenty-docs` passes - [x] Custom oxlint rules validated with Vitest: `npx nx test twenty-oxlint-rules` - [x] `npx nx typecheck twenty-front` passes - [x] `npx nx typecheck twenty-server` passes - [x] CI workflows trigger correctly with `dependsOn: ["twenty-oxlint-rules:build"]` - [x] IDE linting works with `oxc.oxc-vscode` extension
374 lines
12 KiB
YAML
374 lines
12 KiB
YAML
name: CI Front and E2E
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
merge_group:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
env:
|
|
# restore-cache action adds 'v4-' prefix and '-<branch>-<sha>' suffix to the key
|
|
STORYBOOK_BUILD_CACHE_KEY_FOR_RESTORE_ACTION: storybook-build-ubuntu-latest-8-cores-runner
|
|
STORYBOOK_BUILD_CACHE_KEY_FOR_SAVE_ACTION: v4-storybook-build-ubuntu-latest-8-cores-runner-${{ github.ref_name }}-${{ github.sha }}
|
|
|
|
jobs:
|
|
changed-files-check:
|
|
uses: ./.github/workflows/changed-files.yaml
|
|
with:
|
|
files: |
|
|
package.json
|
|
yarn.lock
|
|
packages/twenty-front/**
|
|
packages/twenty-ui/**
|
|
packages/twenty-shared/**
|
|
packages/twenty-sdk/**
|
|
!packages/twenty-sdk/package.json
|
|
changed-files-check-e2e:
|
|
uses: ./.github/workflows/changed-files.yaml
|
|
with:
|
|
files: |
|
|
packages/**
|
|
!packages/create-twenty-app/package.json
|
|
!packages/twenty-sdk/package.json
|
|
playwright.config.ts
|
|
.github/workflows/ci-front.yaml
|
|
front-sb-build:
|
|
needs: changed-files-check
|
|
if: needs.changed-files-check.outputs.any_changed == 'true'
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest-8-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 }}
|
|
- name: Fetch local actions
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Diagnostic disk space issue
|
|
run: df -h
|
|
- name: Front / Write .env
|
|
run: npx nx reset:env twenty-front
|
|
- name: Front / Build storybook
|
|
run: npx nx storybook:build twenty-front
|
|
- name: Save storybook build cache
|
|
uses: ./.github/actions/save-cache
|
|
with:
|
|
key: ${{ env.STORYBOOK_BUILD_CACHE_KEY_FOR_SAVE_ACTION }}
|
|
front-sb-test:
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest-8-cores
|
|
needs: front-sb-build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4]
|
|
storybook_scope: [modules, pages, performance]
|
|
env:
|
|
SHARD_COUNTER: 4
|
|
REACT_APP_SERVER_BASE_URL: http://localhost:3000
|
|
steps:
|
|
- name: Fetch local actions
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Build dependencies
|
|
run: |
|
|
npx nx build twenty-shared
|
|
npx nx build twenty-ui
|
|
npx nx build twenty-sdk
|
|
- name: Install Playwright
|
|
run: |
|
|
cd packages/twenty-front
|
|
npx playwright install
|
|
- name: Front / Write .env
|
|
run: npx nx reset:env twenty-front
|
|
- name: Run storybook tests
|
|
run: npx nx storybook:test twenty-front --configuration=${{ matrix.storybook_scope }} --shard=${{ matrix.shard }}/${{ env.SHARD_COUNTER }}
|
|
# - name: Rename coverage file
|
|
# run: |
|
|
# if [ -f "packages/twenty-front/coverage/storybook/coverage-final.json" ]; then
|
|
# mv packages/twenty-front/coverage/storybook/coverage-final.json packages/twenty-front/coverage/storybook/coverage-shard-${{matrix.shard}}.json
|
|
# else
|
|
# echo "Error: coverage-final.json not found"
|
|
# ls -la packages/twenty-front/coverage/storybook/ || echo "Coverage directory does not exist"
|
|
# exit 1
|
|
# fi
|
|
# - name: Upload coverage artifact
|
|
# uses: actions/upload-artifact@v4
|
|
# with:
|
|
# retention-days: 1
|
|
# name: coverage-artifacts-${{ matrix.storybook_scope }}-${{ github.run_id }}-${{ matrix.shard }}
|
|
# path: packages/twenty-front/coverage/storybook/coverage-shard-${{matrix.shard}}.json
|
|
# merge-reports-and-check-coverage:
|
|
# timeout-minutes: 30
|
|
# runs-on: ubuntu-latest
|
|
# needs: front-sb-test
|
|
# env:
|
|
# PATH_TO_COVERAGE: packages/twenty-front/coverage/storybook
|
|
# strategy:
|
|
# matrix:
|
|
# storybook_scope: [modules, pages, performance]
|
|
# steps:
|
|
# - uses: actions/checkout@v4
|
|
# with:
|
|
# fetch-depth: 10
|
|
# - name: Install dependencies
|
|
# uses: ./.github/actions/yarn-install
|
|
# - uses: actions/download-artifact@v4
|
|
# with:
|
|
# pattern: coverage-artifacts-${{ matrix.storybook_scope }}-${{ github.run_id }}-*
|
|
# merge-multiple: true
|
|
# path: coverage-artifacts
|
|
# - name: Merge coverage reports
|
|
# run: |
|
|
# mkdir -p ${{ env.PATH_TO_COVERAGE }}
|
|
# npx nyc merge coverage-artifacts ${{ env.PATH_TO_COVERAGE }}/coverage-storybook.json
|
|
# - name: Checking coverage
|
|
# run: npx nx storybook:coverage twenty-front --checkCoverage=true --configuration=${{ matrix.storybook_scope }}
|
|
front-chromatic-deployment:
|
|
timeout-minutes: 30
|
|
if: false
|
|
needs: front-sb-build
|
|
runs-on: ubuntu-latest-8-cores
|
|
env:
|
|
REACT_APP_SERVER_BASE_URL: http://127.0.0.1:3000
|
|
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Restore storybook build cache
|
|
uses: ./.github/actions/restore-cache
|
|
with:
|
|
key: ${{ env.STORYBOOK_BUILD_CACHE_KEY_FOR_RESTORE_ACTION }}
|
|
- name: Front / Write .env
|
|
run: |
|
|
cd packages/twenty-front
|
|
touch .env
|
|
echo "" >> .env
|
|
echo "REACT_APP_SERVER_BASE_URL=$REACT_APP_SERVER_BASE_URL" >> .env
|
|
- name: Publish to Chromatic
|
|
run: npx nx run twenty-front:chromatic:ci
|
|
front-task:
|
|
needs: changed-files-check
|
|
if: needs.changed-files-check.outputs.any_changed == 'true'
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NODE_OPTIONS: '--max-old-space-size=4096'
|
|
TASK_CACHE_KEY: front-task-${{ matrix.task }}
|
|
strategy:
|
|
matrix:
|
|
task: [lint, typecheck, test]
|
|
steps:
|
|
- name: Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
with:
|
|
access_token: ${{ github.token }}
|
|
- name: Fetch custom Github Actions and base branch history
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Restore ${{ matrix.task }} cache
|
|
id: restore-task-cache
|
|
uses: ./.github/actions/restore-cache
|
|
with:
|
|
key: ${{ env.TASK_CACHE_KEY }}
|
|
- name: Reset .env
|
|
uses: ./.github/actions/nx-affected
|
|
with:
|
|
tag: scope:frontend
|
|
tasks: reset:env
|
|
- name: Run ${{ matrix.task }} task
|
|
id: run-task
|
|
uses: ./.github/actions/nx-affected
|
|
with:
|
|
tag: scope:frontend
|
|
tasks: ${{ matrix.task }}
|
|
- name: Save ${{ matrix.task }} cache
|
|
uses: ./.github/actions/save-cache
|
|
with:
|
|
key: ${{ steps.restore-task-cache.outputs.cache-primary-key }}
|
|
front-build:
|
|
needs: changed-files-check
|
|
if: needs.changed-files-check.outputs.any_changed == 'true'
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest-8-cores
|
|
env:
|
|
NODE_OPTIONS: "--max-old-space-size=10240"
|
|
steps:
|
|
- name: Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
with:
|
|
access_token: ${{ github.token }}
|
|
- name: Fetch custom Github Actions and base branch history
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
- name: Front / Write .env
|
|
run: npx nx reset:env twenty-front
|
|
- name: Build frontend
|
|
run: npx nx build twenty-front
|
|
# - name: Upload frontend build artifact
|
|
# uses: actions/upload-artifact@v4
|
|
# with:
|
|
# name: frontend-build
|
|
# path: packages/twenty-front/build
|
|
# retention-days: 1
|
|
e2e-test:
|
|
runs-on: ubuntu-latest
|
|
needs: [changed-files-check-e2e, front-build]
|
|
if: |
|
|
always() &&
|
|
needs.changed-files-check-e2e.outputs.any_changed == 'true' &&
|
|
(needs.front-build.result == 'success' || needs.front-build.result == 'skipped') &&
|
|
(github.event_name == 'push' || github.event_name == 'merge_group' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-e2e')))
|
|
timeout-minutes: 30
|
|
env:
|
|
NODE_OPTIONS: "--max-old-space-size=10240"
|
|
services:
|
|
postgres:
|
|
image: twentycrm/twenty-postgres-spilo
|
|
env:
|
|
PGUSER_SUPERUSER: postgres
|
|
PGPASSWORD_SUPERUSER: postgres
|
|
ALLOW_NOSSL: "true"
|
|
SPILO_PROVIDER: "local"
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 10
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
|
|
- name: Check system resources
|
|
run: |
|
|
echo "Available memory:"
|
|
free -h
|
|
echo "Available disk space:"
|
|
df -h
|
|
echo "CPU info:"
|
|
lscpu
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
|
|
- name: Build twenty-shared
|
|
run: npx nx build twenty-shared
|
|
|
|
- name: Install Playwright Browsers
|
|
run: npx nx setup twenty-e2e-testing
|
|
|
|
- name: Setup environment files
|
|
run: |
|
|
cp packages/twenty-front/.env.example packages/twenty-front/.env
|
|
npx nx reset:env:e2e-testing-server twenty-server
|
|
|
|
# - name: Download frontend build artifact
|
|
# if: needs.front-build.result == 'success'
|
|
# uses: actions/download-artifact@v4
|
|
# with:
|
|
# name: frontend-build
|
|
# path: packages/twenty-front/build
|
|
|
|
# - name: Build frontend (if not available from front-build)
|
|
# if: needs.front-build.result == 'skipped'
|
|
# run: NODE_ENV=production NODE_OPTIONS="--max-old-space-size=10240" npx nx build twenty-front
|
|
|
|
- name: Build frontend
|
|
run: NODE_ENV=production NODE_OPTIONS="--max-old-space-size=10240" npx nx build twenty-front
|
|
|
|
- name: Build server
|
|
run: npx nx build twenty-server
|
|
|
|
- name: Create and setup database
|
|
run: |
|
|
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'
|
|
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";'
|
|
npx nx run twenty-server:database:reset
|
|
|
|
- name: Start server
|
|
run: |
|
|
npx nx start twenty-server &
|
|
echo "Waiting for server to be ready..."
|
|
timeout 60 bash -c 'until curl -s http://localhost:3000/health; do sleep 2; done'
|
|
|
|
- name: Start frontend
|
|
run: |
|
|
npm_config_yes=true npx serve -s packages/twenty-front/build -l 3001 &
|
|
echo "Waiting for frontend to be ready..."
|
|
timeout 60 bash -c 'until curl -s http://localhost:3001; do sleep 2; done'
|
|
|
|
- name: Start worker
|
|
run: |
|
|
npx nx run twenty-server:worker &
|
|
echo "Worker started"
|
|
|
|
- name: Run Playwright tests
|
|
run: npx nx test twenty-e2e-testing
|
|
|
|
# - uses: actions/upload-artifact@v4
|
|
# if: always()
|
|
# with:
|
|
# name: playwright-report
|
|
# path: packages/twenty-e2e-testing/run_results/
|
|
# retention-days: 30
|
|
|
|
ci-front-status-check:
|
|
if: always() && !cancelled()
|
|
timeout-minutes: 5
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
[
|
|
changed-files-check,
|
|
front-task,
|
|
front-build,
|
|
# merge-reports-and-check-coverage,
|
|
front-sb-test,
|
|
front-sb-build,
|
|
]
|
|
steps:
|
|
- name: Fail job if any needs failed
|
|
if: contains(needs.*.result, 'failure')
|
|
run: exit 1
|
|
ci-e2e-status-check:
|
|
if: always() && !cancelled()
|
|
timeout-minutes: 5
|
|
runs-on: ubuntu-latest
|
|
needs: [changed-files-check-e2e, e2e-test]
|
|
steps:
|
|
- name: Fail job if any needs failed
|
|
if: contains(needs.*.result, 'failure')
|
|
run: exit 1
|