Skip to content

Commit

Permalink
refactor: use reusable worfklow
Browse files Browse the repository at this point in the history
  • Loading branch information
prastoin committed Jan 15, 2025
1 parent 978a502 commit 027571f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 32 deletions.
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
runs-on: depot-ubuntu-24.04-8
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 }}
15 changes: 15 additions & 0 deletions .github/workflows/ci-final-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI final check reusable workflow
on:
workflow_call:

jobs:
ci-server-final:
if: always() && !cancelled()
timeout-minutes: 1
runs-on: depot-ubuntu-24.04-8
steps:
- run: echo ${{ needs.prerequisites.result }}
- run: echo "${{ toJson(needs.*.result) }}"
- name: Fail job if any needs failed ${{ needs }}
if: contains(needs.*.result, 'failure')
run: exit 1
47 changes: 15 additions & 32 deletions .github/workflows/ci-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main

pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -15,24 +15,13 @@ env:

jobs:
prerequisites:
timeout-minutes: 5
runs-on: depot-ubuntu-24.04-8
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: |
package.json
packages/twenty-server/**
packages/twenty-emails/**
packages/twenty-shared/**
uses: ./.github/workflows/changed-files.yaml
with:
files: |
package.json
packages/twenty-server/**
packages/twenty-emails/**
packages/twenty-shared/**
server-setup:
needs: prerequisites
if: needs.prerequisites.outputs.any_changed == 'true'
Expand All @@ -46,8 +35,8 @@ jobs:
env:
PGUSER_SUPERUSER: postgres
PGPASSWORD_SUPERUSER: postgres
ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local"
ALLOW_NOSSL: 'true'
SPILO_PROVIDER: 'local'
ports:
- 5432:5432
options: >-
Expand Down Expand Up @@ -130,7 +119,7 @@ jobs:
uses: ./.github/workflows/actions/restore-cache
with:
key: ${{ env.SERVER_SETUP_CACHE_KEY }}
- name: Server / Run Tests
- name: Server / Run Tests
uses: ./.github/workflows/actions/nx-affected
with:
tag: scope:backend
Expand All @@ -146,8 +135,8 @@ jobs:
env:
PGUSER_SUPERUSER: postgres
PGPASSWORD_SUPERUSER: postgres
ALLOW_NOSSL: "true"
SPILO_PROVIDER: "local"
ALLOW_NOSSL: 'true'
SPILO_PROVIDER: 'local'
ports:
- 5432:5432
options: >-
Expand Down Expand Up @@ -182,19 +171,13 @@ jobs:
uses: ./.github/workflows/actions/nx-affected
with:
tag: scope:backend
tasks: "test:integration:with-db-reset"
tasks: 'test:integration:with-db-reset'
- name: Server / Upload reset-logs file
if: always()
uses: actions/upload-artifact@v4
with:
name: reset-logs
path: reset-logs.log
ci-server-final:
if: always() && !cancelled()
timeout-minutes: 1
runs-on: depot-ubuntu-24.04-8
needs: [prerequisites, server-setup, server-test, server-integration-test]
steps:
- name: Fail job if any needs failed
if: contains(needs.*.result, 'failure')
run: exit 1
uses: ./.github/workflows/ci-final-check.yaml

0 comments on commit 027571f

Please sign in to comment.