[CI] Refactor changed files integration (#9643)
# BEFORE [run](https://github.com/twentyhq/twenty/actions/runs/12806801953)  # AFTER [run](https://github.com/twentyhq/twenty/actions/runs/12807034402)  ## Motivations: - less workflow to whitelist as blocking for PRs - less if condition per step cons: - quite verbose - need to manually sync the `ci-NAME-status-check` needs list to any other existing and should be dep jobs ## Version migration Migrated to the latest `changed-files@45` version, getting rid of the `set-output` usage warnings ## Tests runs: With mutation: - [Success flow](https://github.com/twentyhq/twenty/actions/runs/12791958651/job/35661546343) - [server-setup failure flow](https://github.com/twentyhq/twenty/actions/runs/12792225779) - [Other job failure flow](https://github.com/twentyhq/twenty/actions/runs/12792313463), one of the `inner` job failed - [Manual cancel flow](https://github.com/twentyhq/twenty/actions/runs/12792313463) `ci-server-status-check` also has the `cancelled` status - [Matrix failure](https://github.com/twentyhq/twenty/actions/runs/12806883553) Without mutation: - [Nothing to do flow](https://github.com/twentyhq/twenty/actions/runs/12792098384), skipped `inner` job but `ci-server-status-check` still succeeded ## Notes ### Linter We should setup a `yml` prettier and linter for the `.github/worfklows` folder ### Centralized `ci-NAME-status-check` logic Unfortunately I couldn't achieve to either make a `composite` action or a `reusable-workflow`, as I could not access the correct layer to run the `always` but also acessing the `needs` context
This commit is contained in:
43
.github/workflows/ci-e2e.yaml
vendored
43
.github/workflows/ci-e2e.yaml
vendored
@ -11,9 +11,17 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
prerequisites:
|
||||
uses: ./.github/workflows/changed-files.yaml
|
||||
with:
|
||||
files: |
|
||||
packages/**
|
||||
playwright.config.ts
|
||||
.github/workflows/ci-e2e.yaml
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-e2e'))
|
||||
needs: prerequisites
|
||||
if: needs.prerequisites.outputs.any_changed == 'true' && ( github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-e2e')))
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
|
||||
@ -55,29 +63,13 @@ jobs:
|
||||
echo "CPU info:"
|
||||
lscpu
|
||||
|
||||
- name: Check for changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v11
|
||||
with:
|
||||
files: |
|
||||
packages/**
|
||||
playwright.config.ts
|
||||
.github/workflows/ci-e2e.yaml
|
||||
|
||||
- name: Skip if no relevant changes
|
||||
if: steps.changed-files.outputs.any_changed == 'false'
|
||||
run: echo "No relevant changes detected. Marking as valid."
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
uses: ./.github/workflows/actions/yarn-install
|
||||
|
||||
- name: Build twenty-shared
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: npx nx build twenty-shared
|
||||
|
||||
- name: Setup environment files
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: |
|
||||
cp packages/twenty-e2e-testing/.env.example packages/twenty-e2e-testing/.env
|
||||
cp packages/twenty-front/.env.example packages/twenty-front/.env
|
||||
@ -85,46 +77,38 @@ jobs:
|
||||
npx nx reset:env twenty-server
|
||||
|
||||
- name: Build frontend
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: NODE_ENV=production NODE_OPTIONS="--max-old-space-size=10240" npx nx build twenty-front
|
||||
|
||||
- name: Build server
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: NODE_ENV=production npx nx build twenty-server
|
||||
|
||||
- name: Create and setup database
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
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
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
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
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
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
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: |
|
||||
npx nx run twenty-server:worker:ci &
|
||||
echo "Worker started"
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: npx nx setup twenty-e2e-testing
|
||||
|
||||
- name: Run Playwright tests
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: npx nx test twenty-e2e-testing
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
@ -140,3 +124,12 @@ jobs:
|
||||
name: playwright-report
|
||||
path: packages/twenty-e2e-testing/playwright-report/
|
||||
retention-days: 30
|
||||
ci-e2e-status-check:
|
||||
if: always() && !cancelled()
|
||||
timeout-minutes: 1
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prerequisites, test]
|
||||
steps:
|
||||
- name: Fail job if any needs failed
|
||||
if: contains(needs.*.result, 'failure')
|
||||
run: exit 1
|
||||
|
||||
Reference in New Issue
Block a user