d37ed7e07c
## Summary - **Merge queue optimization**: Created a dedicated `ci-merge-queue.yaml` workflow that only runs Playwright E2E tests on `ubuntu-latest-8-cores`. Removed `merge_group` trigger from all 7 existing CI workflows (front, server, shared, website, sdk, zapier, docker-compose). The merge queue goes from ~30+ parallel jobs to a single focused E2E job. - **Label-based merge queue simulation**: Added `run-merge-queue` label support so developers can trigger the exact merge queue E2E pipeline on any open PR before it enters the queue. - **Prettier in lint**: Chained `prettier --check` into `lint` and `prettier --write` into `lint --configuration=fix` across `nx.json` defaults, `twenty-front`, and `twenty-server`. Prettier formatting errors are now caught by `lint` and fixed by `lint:fix` / `lint:diff-with-main --configuration=fix`. ## After merge (manual repo settings) Update GitHub branch protection required status checks: 1. Remove old per-workflow merge queue checks (`ci-front-status-check`, `ci-e2e-status-check`, `ci-server-status-check`, etc.) 2. Add `ci-merge-queue-status-check` as the required check for the merge queue
266 lines
9.1 KiB
YAML
266 lines
9.1 KiB
YAML
name: CI Front
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
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
|
|
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: Upload storybook build
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: packages/twenty-front/storybook-static
|
|
retention-days: 1
|
|
- 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
|
|
STORYBOOK_URL: http://localhost:6006
|
|
steps:
|
|
- name: Fetch local actions
|
|
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: Clean stale storybook vitest cache
|
|
run: rm -rf packages/twenty-front/node_modules/.cache/storybook
|
|
- name: Build dependencies
|
|
run: |
|
|
npx nx build twenty-shared
|
|
npx nx build twenty-ui
|
|
npx nx build twenty-sdk
|
|
- name: Download storybook build
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: packages/twenty-front/storybook-static
|
|
- name: Install Playwright
|
|
run: |
|
|
cd packages/twenty-front
|
|
npx playwright install
|
|
- name: Front / Write .env
|
|
run: npx nx reset:env twenty-front
|
|
- name: Serve storybook & run tests
|
|
run: |
|
|
npx http-server packages/twenty-front/storybook-static --port 6006 --silent &
|
|
timeout 30 bash -c 'until curl -sf http://localhost:6006 > /dev/null 2>&1; do sleep 1; done'
|
|
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"
|
|
ANALYZE: "true"
|
|
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
|
|
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
|