Skip to content

Commit

Permalink
fix: analyze swallows errors, so this splits it out into a different …
Browse files Browse the repository at this point in the history
…script (deriv-com#14978)
  • Loading branch information
markw-deriv authored and vinu-deriv committed May 28, 2024
1 parent 04c733b commit ddb7f21
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 1,148 deletions.
94 changes: 94 additions & 0 deletions .github/actions/analyze/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: analyze
description: Analyze all packages
inputs:
REF_NAME:
description: 'Git ref name'
required: true
default: 'test'
NODE_ENV:
description: 'Node environment'
required: false
default: 'test'
CROWDIN_WALLETS_API_KEY:
description: 'Crowdin wallets api key'
required: false
DATADOG_CLIENT_TOKEN:
description: 'Datadog client token'
required: false
DATADOG_APPLICATION_ID:
description: 'Datadog application id'
required: false
DATADOG_CLIENT_TOKEN_LOGS:
description: 'Datadog client token for logs'
required: false
DATADOG_SESSION_REPLAY_SAMPLE_RATE:
description: 'Datadog session replay sample rate'
required: false
DATADOG_SESSION_SAMPLE_RATE:
description: 'Datadog session sample rate'
required: false
GD_API_KEY:
description: 'Google drive api key'
required: false
GD_APP_ID:
description: 'Google drive app id'
required: false
GD_CLIENT_ID:
description: 'Google drive client id'
required: false
RUDDERSTACK_KEY:
description: 'Rudderstack key'
required: false
GROWTHBOOK_CLIENT_KEY:
description: 'Growthbook key'
required: false
GROWTHBOOK_DECRYPTION_KEY:
description: 'Growthbook decryption key'
required: false
DATADOG_SESSION_SAMPLE_RATE_LOGS:
description: 'Datadog session sample rate for logs'
required: false
REMOTE_CONFIG_URL:
description: 'Remote config backup URL'
required: true
IS_GROWTHBOOK_ENABLED:
description: 'Is growthbook enabled'
required: true

runs:
using: composite
steps:
- name: Analyze all packages
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
CROWDIN_WALLETS_API_KEY: ${{ inputs.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }}
DATADOG_CLIENT_TOKEN_LOGS: ${{ inputs.DATADOG_CLIENT_TOKEN_LOGS }}
DATADOG_SESSION_REPLAY_SAMPLE_RATE: ${{ inputs.DATADOG_SESSION_REPLAY_SAMPLE_RATE }}
DATADOG_SESSION_SAMPLE_RATE: ${{ inputs.DATADOG_SESSION_SAMPLE_RATE }}
DATADOG_SESSION_SAMPLE_RATE_LOGS: ${{ inputs.DATADOG_SESSION_SAMPLE_RATE_LOGS }}
IS_GROWTHBOOK_ENABLED: ${{ inputs.IS_GROWTHBOOK_ENABLED }}
GD_API_KEY: ${{ inputs.GD_API_KEY }}
GD_APP_ID: ${{ inputs.GD_APP_ID }}
GD_CLIENT_ID: ${{ inputs.GD_CLIENT_ID }}
RUDDERSTACK_KEY: ${{ inputs.RUDDERSTACK_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ inputs.GROWTHBOOK_CLIENT_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ inputs.GROWTHBOOK_DECRYPTION_KEY }}
REF_NAME: ${{ inputs.REF_NAME }}
REMOTE_CONFIG_URL: ${{ inputs.REMOTE_CONFIG_URL }}
NODE_OPTIONS: "--max_old_space_size=4096"
run: npm run build:prod && npm run analyze:stats
shell: bash

- name: Zip all stats.json files
run: |
zip -r stats.zip packages/*/stats.json
shell: bash

- name: Upload stats.zip
uses: actions/upload-artifact@v4
with:
name: stats-${{ github.sha }}
path: stats.zip
retention-days: 1
41 changes: 41 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Analyse Bundle
on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build_and_test:
name: Analyze Bundle
runs-on: Runner_16cores_Deriv-app
environment: Preview
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup Node
uses: "./.github/actions/setup_node"
- name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Analyze
uses: "./.github/actions/analyze"
with:
NODE_ENV: production
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }}
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }}
DATADOG_CLIENT_TOKEN_LOGS: ${{ vars.DATADOG_CLIENT_TOKEN_LOGS }}
DATADOG_SESSION_REPLAY_SAMPLE_RATE: ${{ vars.DATADOG_SESSION_REPLAY_SAMPLE_RATE }}
DATADOG_SESSION_SAMPLE_RATE: ${{ vars.DATADOG_SESSION_SAMPLE_RATE }}
DATADOG_SESSION_SAMPLE_RATE_LOGS: ${{ vars.DATADOG_SESSION_SAMPLE_RATE_LOGS }}
GD_API_KEY: ${{ secrets.GD_API_KEY }}
GD_APP_ID: ${{ secrets.GD_APP_ID }}
GD_CLIENT_ID: ${{ secrets.GD_CLIENT_ID }}
RUDDERSTACK_KEY: ${{ vars.RUDDERSTACK_KEY }}
GROWTHBOOK_CLIENT_KEY: ${{ vars.GROWTHBOOK_CLIENT_KEY }}
GROWTHBOOK_DECRYPTION_KEY: ${{ vars.GROWTHBOOK_DECRYPTION_KEY }}
REF_NAME: ${{ github.ref_name }}
REMOTE_CONFIG_URL: ${{ vars.REMOTE_CONFIG_URL }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"ts-jest": "^26.4.2"
},
"scripts": {
"analyze": "nx run-many --target=analyze",
"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 run-many --target=build",
"build:one": "f () { nx build @deriv/$1 $2 ;}; f",
"build:since": "nx affected --target=build",
Expand Down
5 changes: 3 additions & 2 deletions packages/account-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"node": "18.x"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\" --profile --json > stats.json",
"analyze:stats": "NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\" --profile --json=stats.json",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\"",
"serve": "rimraf dist && concurrently \"cross-env BUILD_MODE='serve' NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config ./webpack.config.ts\" \"tsc -w --noEmit --preserveWatchOutput\"",
"start": "rimraf dist && npm run test && npm run serve"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
"node": "18.x"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"analyze:stats": "f () { NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./build/webpack.config.js\" --env base=$1 --profile --json=stats.json;}; f",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"start": "npm run test && npm run serve",
"serve": "echo \"Serving...\" && NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config \"./build/webpack.config.js\"",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1 --profile --json > stats.json;}; f",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1;}; f",
"build:travis": "rimraf dist && webpack --config \"./build/webpack.config.js\" --mode=production",
"test": "echo \"No test specified\"",
"test:eslint": "eslint \"./src/**/*.?(js|jsx|ts|tsx)\"",
Expand Down
5 changes: 3 additions & 2 deletions packages/appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"node": "18.x"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --profile --json > stats.json ",
"analyze:stats": "NODE_OPTIONS='-r ts-node/register' webpack --progress --profile --json=stats.json",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress",
"build:travis": "rimraf dist && webpack",
"serve": "rimraf dist && concurrently \"cross-env BUILD_MODE='serve' NODE_OPTIONS='-r ts-node/register' webpack --progress --watch\" \"tsc -w --noEmit --preserveWatchOutput\"",
"start": "rimraf dist && npm run test && npm run serve",
Expand Down
5 changes: 3 additions & 2 deletions packages/bot-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
"node": "18.x"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"analyze:stats": "f () { npm run build:skeleton && NODE_OPTIONS='-r ts-node/register' webpack --progress --env base=$1 --profile --json=stats.json;}; f",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"start": "npm run test && npm run serve",
"serve": "echo \"Serving...\" && NODE_OPTIONS='-r ts-node/register' webpack --progress --watch",
"build": "f () { npm run build:skeleton && NODE_OPTIONS='-r ts-node/register' webpack --progress --env base=$1 --profile --json > stats.json ;}; f",
"build": "f () { npm run build:skeleton && NODE_OPTIONS='-r ts-node/register' webpack --progress --env base=$1;}; f",
"build:skeleton": "lerna exec --scope @deriv/bot-skeleton -- npm run build",
"build:travis": "echo \"No build:travis specified\"",
"test:eslint": "eslint \"./src/**/*.?(js|jsx|ts|tsx|spec.ts|spec.js|spec.tsx|spec.tsx)\"",
Expand Down
5 changes: 3 additions & 2 deletions packages/cashier-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"node": "18.x"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\" --profile --json > stats.json",
"analyze:stats": "NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\" --profile --json=stats.json",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.ts\"",
"serve": "rimraf dist && concurrently \"cross-env BUILD_MODE='serve' NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config ./webpack.config.ts\" \"tsc -w --noEmit --preserveWatchOutput\"",
"start": "rimraf dist && npm run test && npm run serve"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
"url": "git+https://github.com/binary-com/deriv-app.git"
},
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"analyze:stats": "f () { NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./build/webpack.config.js\" --env base=$1 --profile --json=stats.json;}; f",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"test": "echo \"No test specified\"",
"test:eslint": "eslint \"./src/**/*.?(js|jsx|ts|tsx)\"",
"serve": "echo \"Serving...\" && NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config \"./build/webpack.config.js\"",
"build:travis": "rimraf dist && webpack --config \"./build/webpack.config.js\" --mode=production",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1 --profile --json > stats.json;}; f"
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1;}; f"
},
"bugs": {
"url": "https://github.com/binary-com/deriv-app/issues"
Expand Down
5 changes: 3 additions & 2 deletions packages/cfd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"main": "dist/cfd/js/cfd.js",
"private": true,
"scripts": {
"analyze": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"analyze:stats": "f () { NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./build/webpack.config.js\" --env base=$1 --profile --json=stats.json; }; f",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r analyzed.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"start": "npm run test && npm run serve",
"serve": "echo \"Serving...\" && NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config \"./build/webpack.config.js\"",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1 --profile --json > stats.json;}; f",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1; }; f",
"build:travis": "echo \"No build:travis specified\"",
"test:eslint": "eslint \"./src/**/*.?(js|jsx|ts|tsx)\"",
"deploy": "echo \"No deploy specified\"",
Expand Down
Loading

0 comments on commit ddb7f21

Please sign in to comment.