Update workflows to optimize CI processes (#7828)

This Pull Request addresses the need to optimize our Continuous
Integration (CI) workflows for Playwright tests and release processes.
The changes implemented aim to reduce unnecessary resource usage by
conditionally executing jobs based on relevant file changes and
Implement https://github.com/tj-actions/changed-files step

## Changes logs
- Updated `ci-test-docker-compose.yaml , ci-chrome-extension.yaml ` to
check for changed files before running tests.
- Updated `ci-front.yaml , ci-utils.yaml , ci-website.yaml ,
ci-server.yaml` to check for changed files before running tests.
- Enhanced `playwright.yml` to skip unnecessary tests based on file
changes.
This commit is contained in:
shubham yadav
2024-10-21 15:32:14 +05:30
committed by GitHub
parent fc6748de0a
commit b914182b78
7 changed files with 239 additions and 31 deletions

View File

@ -3,13 +3,9 @@ on:
push: push:
branches: branches:
- main - main
paths:
- 'package.json'
- 'packages/twenty-chrome-extension/**'
pull_request: pull_request:
paths:
- 'package.json'
- 'packages/twenty-chrome-extension/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -26,7 +22,23 @@ jobs:
with: with:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
package.json
packages/twenty-chrome-extension/**
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Chrome Extension / Run build - name: Chrome Extension / Run build
if: steps.changed-files.outputs.changed == 'true'
run: npx nx build twenty-chrome-extension run: npx nx build twenty-chrome-extension
- name: Mark as Valid if No Changes
if: steps.changed-files.outputs.changed != 'true'
run: |
echo "No relevant changes detected. Marking as valid."

View File

@ -3,15 +3,9 @@ on:
push: push:
branches: branches:
- main - main
paths:
- 'package.json'
- 'packages/twenty-front/**'
- 'packages/twenty-ui/**'
pull_request: pull_request:
paths:
- 'package.json'
- 'packages/twenty-front/**'
- 'packages/twenty-ui/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -29,20 +23,81 @@ jobs:
access_token: ${{ github.token }} access_token: ${{ github.token }}
- name: Fetch local actions - name: Fetch local actions
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
package.json
packages/twenty-front/**
packages/twenty-ui/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Diagnostic disk space issue - name: Diagnostic disk space issue
if: steps.changed-files.outputs.any_changed == 'true'
run: df -h run: df -h
- name: Front / Restore Storybook Task Cache - name: Front / Restore Storybook Task Cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:frontend tag: scope:frontend
tasks: storybook:build tasks: storybook:build
- name: Front / Write .env - name: Front / Write .env
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx reset:env twenty-front run: npx nx reset:env twenty-front
- name: Front / Build storybook - name: Front / Build storybook
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx storybook:build twenty-front run: npx nx storybook:build twenty-front
front-sb-test: front-sb-test:
runs-on: ci-8-cores
timeout-minutes: 60
needs: front-sb-build
strategy:
matrix:
storybook_scope: [pages, modules]
env:
REACT_APP_SERVER_BASE_URL: http://localhost:3000
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
steps:
- name: Fetch local actions
uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-front/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install
- name: Install Playwright
if: steps.changed-files.outputs.any_changed == 'true'
run: cd packages/twenty-front && npx playwright install
- name: Front / Restore Storybook Task Cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache
with:
tag: scope:frontend
tasks: storybook:build
- name: Front / Write .env
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx reset:env twenty-front
- name: Run storybook tests
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx storybook:serve-and-test:static twenty-front --configuration=${{ matrix.storybook_scope }}
front-sb-test-shipfox:
runs-on: shipfox-8vcpu-ubuntu-2204 runs-on: shipfox-8vcpu-ubuntu-2204
timeout-minutes: 60 timeout-minutes: 60
needs: front-sb-build needs: front-sb-build
@ -55,18 +110,35 @@ jobs:
steps: steps:
- name: Fetch local actions - name: Fetch local actions
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-front/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Install Playwright - name: Install Playwright
if: steps.changed-files.outputs.any_changed == 'true'
run: cd packages/twenty-front && npx playwright install run: cd packages/twenty-front && npx playwright install
- name: Front / Restore Storybook Task Cache - name: Front / Restore Storybook Task Cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:frontend tag: scope:frontend
tasks: storybook:build tasks: storybook:build
- name: Front / Write .env - name: Front / Write .env
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx reset:env twenty-front run: npx nx reset:env twenty-front
- name: Run storybook tests - name: Run storybook tests
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx storybook:serve-and-test:static twenty-front --configuration=${{ matrix.storybook_scope }} run: npx nx storybook:serve-and-test:static twenty-front --configuration=${{ matrix.storybook_scope }}
front-sb-test-performance: front-sb-test-performance:
runs-on: shipfox-8vcpu-ubuntu-2204 runs-on: shipfox-8vcpu-ubuntu-2204
@ -77,13 +149,28 @@ jobs:
steps: steps:
- name: Fetch local actions - name: Fetch local actions
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-front/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Install Playwright - name: Install Playwright
if: steps.changed-files.outputs.any_changed == 'true'
run: cd packages/twenty-front && npx playwright install run: cd packages/twenty-front && npx playwright install
- name: Front / Write .env - name: Front / Write .env
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx reset:env twenty-front run: npx nx reset:env twenty-front
- name: Run storybook tests - name: Run storybook tests
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx storybook:serve-and-test:static:performance twenty-front run: npx nx storybook:serve-and-test:static:performance twenty-front
front-chromatic-deployment: front-chromatic-deployment:
if: contains(github.event.pull_request.labels.*.name, 'run-chromatic') || github.event_name == 'push' if: contains(github.event.pull_request.labels.*.name, 'run-chromatic') || github.event_name == 'push'
@ -97,19 +184,35 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-front/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Front / Restore Storybook Task Cache - name: Front / Restore Storybook Task Cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:frontend tag: scope:frontend
tasks: storybook:build tasks: storybook:build
- name: Front / Write .env - name: Front / Write .env
if: steps.changed-files.outputs.any_changed == 'true'
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: Publish to Chromatic - name: Publish to Chromatic
if: steps.changed-files.outputs.any_changed == 'true'
run: npx nx run twenty-front:chromatic:ci run: npx nx run twenty-front:chromatic:ci
front-task: front-task:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -127,19 +230,34 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-front/**
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No relevant changes. Skipping CI."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Front / Restore ${{ matrix.task }} task cache - name: Front / Restore ${{ matrix.task }} task cache
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:frontend tag: scope:frontend
tasks: ${{ matrix.task }} tasks: ${{ matrix.task }}
- name: Reset .env - name: Reset .env
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/nx-affected uses: ./.github/workflows/actions/nx-affected
with: with:
tag: scope:frontend tag: scope:frontend
tasks: reset:env tasks: reset:env
- name: Run ${{ matrix.task }} task - name: Run ${{ matrix.task }} task
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/nx-affected uses: ./.github/workflows/actions/nx-affected
with: with:
tag: scope:frontend tag: scope:frontend

View File

@ -3,15 +3,9 @@ on:
push: push:
branches: branches:
- main - main
paths:
- 'package.json'
- 'packages/twenty-server/**'
- 'packages/twenty-emails/**'
pull_request: pull_request:
paths:
- 'package.json'
- 'packages/twenty-server/**'
- 'packages/twenty-emails/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -38,22 +32,35 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'package.json, packages/twenty-server/**, packages/twenty-emails/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Server / Restore Task Cache - name: Server / Restore Task Cache
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:backend tag: scope:backend
- name: Server / Run lint & typecheck - name: Server / Run lint & typecheck
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/nx-affected uses: ./.github/workflows/actions/nx-affected
with: with:
tag: scope:backend tag: scope:backend
tasks: lint,typecheck tasks: lint,typecheck
- name: Server / Build - name: Server / Build
if: steps.changed-files.outputs.changed == 'true'
run: npx nx build twenty-server run: npx nx build twenty-server
- name: Server / Write .env - name: Server / Write .env
if: steps.changed-files.outputs.changed == 'true'
run: npx nx reset:env twenty-server run: npx nx reset:env twenty-server
- name: Worker / Run - name: Worker / Run
if: steps.changed-files.outputs.changed == 'true'
run: npx nx run twenty-server:worker:ci run: npx nx run twenty-server:worker:ci
server-test: server-test:
@ -66,13 +73,23 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'package.json, packages/twenty-server/**, packages/twenty-emails/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Server / Restore Task Cache - name: Server / Restore Task Cache
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:backend tag: scope:backend
- name: Server / Run Tests - name: Server / Run Tests
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/nx-affected uses: ./.github/workflows/actions/nx-affected
with: with:
tag: scope:backend tag: scope:backend
@ -100,13 +117,23 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'package.json, packages/twenty-server/**, packages/twenty-emails/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Server / Restore Task Cache - name: Server / Restore Task Cache
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/task-cache uses: ./.github/workflows/actions/task-cache
with: with:
tag: scope:backend tag: scope:backend
- name: Server / Run Integration Tests - name: Server / Run Integration Tests
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/nx-affected uses: ./.github/workflows/actions/nx-affected
with: with:
tag: scope:backend tag: scope:backend

View File

@ -1,8 +1,7 @@
name: 'Test Docker Compose' name: 'Test Docker Compose'
on: on:
pull_request: pull_request:
paths:
- 'packages/twenty-docker/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -13,8 +12,19 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/twenty-docker/**
docker-compose.yml
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed != 'true'
run: echo "No relevant changes detected. Marking as valid."
- name: Run compose - name: Run compose
if: steps.changed-files.outputs.any_changed == 'true'
run: | run: |
echo "Patching docker-compose.yml..." echo "Patching docker-compose.yml..."
# change image to localbuild using yq # change image to localbuild using yq

View File

@ -23,9 +23,16 @@ jobs:
if: github.event.action != 'closed' if: github.event.action != 'closed'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'packages/twenty-utils/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Utils / Run Danger.js - name: Utils / Run Danger.js
if: steps.changed-files.outputs.changed == 'true'
run: cd packages/twenty-utils && npx nx danger:ci run: cd packages/twenty-utils && npx nx danger:ci
env: env:
DANGER_GITHUB_API_TOKEN: ${{ github.token }} DANGER_GITHUB_API_TOKEN: ${{ github.token }}
@ -35,9 +42,16 @@ jobs:
if: github.event.action == 'closed' && github.event.pull_request.merged == true if: github.event.action == 'closed' && github.event.pull_request.merged == true
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'packages/twenty-utils/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Run congratulate-dangerfile.js - name: Run congratulate-dangerfile.js
if: steps.changed-files.outputs.changed == 'true'
run: cd packages/twenty-utils && npx nx danger:congratulate run: cd packages/twenty-utils && npx nx danger:congratulate
env: env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -3,13 +3,10 @@ on:
push: push:
branches: branches:
- main - main
paths:
- 'package.json'
- 'packages/twenty-website/**'
pull_request: pull_request:
paths:
- 'package.json'
- 'packages/twenty-website/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -27,13 +24,27 @@ jobs:
- 5432:5432 - 5432:5432
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: 'package.json, packages/twenty-website/**'
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.changed == 'true'
uses: ./.github/workflows/actions/yarn-install uses: ./.github/workflows/actions/yarn-install
- name: Website / Run migrations - name: Website / Run migrations
if: steps.changed-files.outputs.changed == 'true'
run: npx nx database:migrate twenty-website run: npx nx database:migrate twenty-website
env: env:
DATABASE_PG_URL: postgres://twenty:twenty@localhost:5432/default DATABASE_PG_URL: postgres://twenty:twenty@localhost:5432/default
- name: Website / Build Website - name: Website / Build Website
if: steps.changed-files.outputs.changed == 'true'
run: npx nx build twenty-website run: npx nx build twenty-website
env: env:
DATABASE_PG_URL: postgres://twenty:twenty@localhost:5432/default DATABASE_PG_URL: postgres://twenty:twenty@localhost:5432/default
- name: Mark as VALID
if: steps.changed-files.outputs.changed != 'true' # If no changes, mark as valid
run: echo "No relevant changes detected. CI is valid."

View File

@ -13,11 +13,27 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: lts/* node-version: lts/*
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v11
with:
files: |
packages/** # Adjust this to your relevant directories
playwright.config.ts # Include any relevant config files
- name: Skip if no relevant changes
if: steps.changed-files.outputs.any_changed != 'true'
run: echo "No relevant changes detected. Marking as valid."
- name: Install dependencies - name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: npm install -g yarn && yarn run: npm install -g yarn && yarn
- name: Install Playwright Browsers - name: Install Playwright Browsers
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Run Playwright tests - name: Run Playwright tests
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn test:e2e companies run: yarn test:e2e companies
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()