Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Refactor changed files integration #9643

Merged
merged 22 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
16bc6db
refactor: ci-server centralized changed-files stuff
prastoin Jan 15, 2025
82452c6
fix: checkout to repo before changed-files action
prastoin Jan 15, 2025
6b92046
ci: always run ci-server-final
prastoin Jan 15, 2025
6e64cfe
ci: do not run final job is workflow has been cancelled
prastoin Jan 15, 2025
084904e
ci: programmatically fail final job if any needs failed
prastoin Jan 15, 2025
b18c112
fix: expose outputs any_changed from prerequisites
prastoin Jan 15, 2025
7883b10
chore: remove logs
prastoin Jan 15, 2025
0fe3a56
ci: upgrade to latest changed-files version ci-server
prastoin Jan 15, 2025
1f44731
refactor: use reusable worfklow
prastoin Jan 15, 2025
529648f
fix: always and cancelled on workflow call
prastoin Jan 15, 2025
4d0fe1b
refactor: use composite action to read needs
prastoin Jan 15, 2025
8bfd190
chore: always and cancelled on composite action call
prastoin Jan 15, 2025
c39869f
chore: to drop logs
prastoin Jan 15, 2025
0fa79f6
fix: composite action path
prastoin Jan 15, 2025
e245a91
fix: checkout before using composite local action
prastoin Jan 15, 2025
77e8fd9
chore: comeback to raw job
prastoin Jan 15, 2025
aa928dc
chore: rename composite action from yml to yaml
prastoin Jan 15, 2025
092eaca
refactor: ci-front changed-files integration
prastoin Jan 16, 2025
f8bdb39
chore: ci-front remove previous changed-files logs steps
prastoin Jan 16, 2025
0db332f
refactor: remaining workflows consuming changed-files directly
prastoin Jan 16, 2025
6144c9d
lint: ci-website.yaml
prastoin Jan 16, 2025
e1ed78e
refactor: mv ci-NAME-final ci-NAME-status-check
prastoin Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/changed-files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Changed files reusable workflow
on:
workflow_call:
inputs:
files:
required: true
type: string
outputs:
any_changed:
value: ${{ jobs.changed-files.outputs.any_changed }}

jobs:
changed-files:
timeout-minutes: 5
prastoin marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- name: Fetch custom Github Actions and base branch history
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: ${{ inputs.files }}
37 changes: 19 additions & 18 deletions .github/workflows/ci-chrome-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ on:
push:
branches:
- main

pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
prerequisites:
uses: ./.github/workflows/changed-files.yaml
with:
files: |
package.json
packages/twenty-chrome-extension/**
chrome-extension-build:
needs: prerequisites
if: needs.prerequisites.outputs.any_changed == 'true'
timeout-minutes: 15
runs-on: ubuntu-latest
env:
Expand All @@ -25,23 +33,16 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- 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
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/workflows/actions/yarn-install
- name: Chrome Extension / Run build
if: steps.changed-files.outputs.any_changed == 'true'
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."
ci-chrome-extension-status-check:
if: always() && !cancelled()
prastoin marked this conversation as resolved.
Show resolved Hide resolved
timeout-minutes: 1
runs-on: ubuntu-latest
needs: [prerequisites, chrome-extension-build]
steps:
- name: Fail job if any needs failed
if: contains(needs.*.result, 'failure')
run: exit 1
43 changes: 18 additions & 25 deletions .github/workflows/ci-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,76 +63,52 @@ 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
cp packages/twenty-e2e-testing/.env.example packages/twenty-e2e-testing/.env
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
Expand All @@ -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
prastoin marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading