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

Reduce PR CI/CD pipeline time execution #17775

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/actions/analyze/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ runs:
TRUSTPILOT_API_KEY: ${{ inputs.TRUSTPILOT_API_KEY }}
NODE_OPTIONS: "--max_old_space_size=4096"
shell: bash
run: npm run build:prod && npm run analyze:stats && npm run analyze:build
run: npm run build:prod-analyze && npm run analyze:stats && npm run analyze:build

- name: Compare report to master
id: diff
Expand Down
12 changes: 11 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ inputs:
description: 'Node environment'
required: false
default: 'test'
STRICT_BUILD:
description: 'When true, runs `build:all` script without cache skipping for components, account, bot-web-ui and trader packages,
when false, runs `build:all-cache` script with cache skipping for all packages, except components package'
required: false
default: true
DATADOG_CLIENT_TOKEN:
description: 'Datadog client token'
required: false
Expand Down Expand Up @@ -77,5 +82,10 @@ runs:
REF_NAME: ${{ inputs.REF_NAME }}
REMOTE_CONFIG_URL: ${{ inputs.REMOTE_CONFIG_URL }}
TRUSTPILOT_API_KEY: ${{ inputs.TRUSTPILOT_API_KEY }}
run: npm run build:all
run: |
if [ "${{ inputs.STRICT_BUILD }}" = "true" ]; then
npm run build:all
else
npm run build:all-cache
fi
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/restore_npm_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Restore npm cache
description: Restores the NPM cache

outputs:
cache-hit:
description: Indicates if the cache was restored successfully
value: ${{ steps.restored_cache.outputs.cache-hit }}

runs:
using: composite
steps:
- name: Restore cache
id: restored_cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
packages/*/node_modules
key: node_modules-cache-${{ hashFiles('package-lock.json', 'packages/*/package.json') }}
17 changes: 17 additions & 0 deletions .github/actions/restore_nx_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Restore NX cache
description: Restores the NX cache

outputs:
cache-hit:
description: Indicates if the cache was restored successfully
value: ${{ steps.restored_cache.outputs.cache-hit }}

runs:
using: composite
steps:
- name: Restore cache
id: restored_cache
uses: actions/cache/restore@v4
with:
path: .nx
key: nx-cache-${{ hashFiles('nx.json', 'package-lock.json', 'packages/*/package.json') }}
8 changes: 7 additions & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup Node
uses: "./.github/actions/setup_node"
- name: Install dependencies
- name: Restore npm cache
id: restored_npm_cache
uses: ./.github/actions/restore_npm_cache
- if: ${{ steps.restored_npm_cache.outputs.cache-hit != 'true' }}
name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Restore NX cache
uses: ./.github/actions/restore_nx_cache
- name: Analyze
uses: "./.github/actions/analyze"
with:
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ jobs:
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Restore npm cache
uses: actions/cache/restore@v4
id: cache-npm
with:
path: |
node_modules
packages/*/node_modules
key: node_modules-cache-${{ hashFiles('package-lock.json', 'packages/*/package.json') }}
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
id: restored_npm_cache
uses: ./.github/actions/restore_npm_cache
- if: ${{ steps.restored_npm_cache.outputs.cache-hit != 'true' }}
name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build components package
Expand All @@ -45,7 +40,7 @@ jobs:
finish:
name: Coveralls Finished
needs: [test]
runs-on: Runner_16cores_Deriv-app
runs-on: Runner_8cores_Deriv-app
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ jobs:
uses: "./.github/actions/setup_node"
- name: Check imports
run: npm run check-imports
- name: Install dependencies
- name: Restore npm cache
id: restored_npm_cache
uses: ./.github/actions/restore_npm_cache
- if: ${{ steps.restored_npm_cache.outputs.cache-hit != 'true' }}
name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
# - name: Invalidate NPM Cache
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# uses: "./.github/actions/invalidate_npm_cache"
- name: Restore NX cache
uses: ./.github/actions/restore_nx_cache
- name: Build
uses: "./.github/actions/build"
with:
STRICT_BUILD: false
- name: Check TypeScript for @deriv/api
run: npx tsc --project packages/api/tsconfig.json -noEmit
- name: Check TypeScript for @deriv/api-v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_npm_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build_cache:
name: Build cache
runs-on: Runner_16cores_Deriv-app
runs-on: Runner_8cores_Deriv-app
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/update_nx_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Update NX cache

on:
push:
branches:
- master

jobs:
build_cache:
name: Build cache
runs-on: Runner_8cores_Deriv-app
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Cache NX cache
id: cache-nx
uses: actions/cache@v4
with:
path: .nx
key: nx-cache-${{ hashFiles('nx.json', 'package-lock.json', 'packages/*/package.json') }}
- if: ${{ steps.cache-nx.outputs.cache-hit != 'true' }}
name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build
uses: "./.github/actions/build"


6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"analyze:build": "nx run-many --target=analyze:build",
"analyze:stats": "nx run-many --target=analyze:stats",
"build:all": "nx build @deriv/components --skip-nx-cache && nx build @deriv/account --skip-nx-cache && nx build @deriv/bot-web-ui --skip-nx-cache && nx build @deriv/trader --skip-nx-cache && nx run-many --target=build",
"build:all-cache": "nx build @deriv/components --skip-nx-cache && nx run-many --target=build",
"build:one": "f () { nx build @deriv/$1 $2 ;}; f",
"build:since": "nx affected --target=build",
"test:eslint-all": "nx run-many --target=test:eslint",
Expand All @@ -81,6 +82,7 @@
"build:local": "f () { nx run-many --target=build --projects=@deriv/bot-web-ui,@deriv/trader --parallel=2 ;}; f",
"build:travis": "nx run-many --projects=@deriv/shared,@deriv/components,@deriv/translations,@deriv/cashier,@deriv/account,@deriv/p2p,@deriv/cfd,@deriv/reports --target=build:travis",
"build:prod": "export NODE_ENV=staging && npm run build:all && export NODE_ENV=",
"build:prod-analyze": "export NODE_ENV=staging && npm run build:all-cache && export NODE_ENV=",
"build:storybook": "cd packages/components && sb build --output-dir .out",
"build:gh-pages": "f () { nx run-many --target=build --projects=@deriv/components,@deriv/p2p && nx run-many --target=build --projects=@deriv/cashier,@deriv/account,@deriv/cfd,@deriv/reports && npm run build:local $1 ;}; f",
"check-imports": "node ./scripts/check-imports.js",
Expand All @@ -93,9 +95,9 @@
"publish_package": "f () { npm exec --workspace=@deriv/${1:-'*'} -- npm run publish_package $2 ;}; f",
"serve": "f () { npm exec --workspace=@deriv/${1:-'*'} -- npm run serve $npm_config_open;}; f",
"start": "f () { npm exec --workspace=@deriv/${1:-'*'} -- npm run start ;}; f",
"test": "f () { npm run test:stylelint && npm run test:eslint-all && npm run test:jest ;}; f",
"test": "f () { npm run test:stylelint && npm run test:eslint-all && npm run test:jest ;}; f",
"test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"",
"test:ci": "f () { npm run test:stylelint && npm run test:eslint-all ;}; f",
"test:ci": "f () { npm run test:stylelint && npm run test:eslint-all ;}; f",
"test:shard": "jest --all --shard=${SHARD_INDEX}/${SHARD_COUNT} --maxWorkers=${JEST_MAX_WORKERS:-'50%'}",
"test:jest": "jest --all --maxWorkers=${JEST_MAX_WORKERS:-'50%'}",
"test:performance": "cd e2e-tests && jest -c ./jest.config.js --detectOpenHandles performance",
Expand Down
Loading