Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Browse files Browse the repository at this point in the history
… P2PS-1329/issues-when-refreshing-the-page
  • Loading branch information
Farhan-slurrp committed Oct 4, 2023
2 parents cbb790a + ad3eb3b commit 4d08c20
Show file tree
Hide file tree
Showing 697 changed files with 15,042 additions and 9,091 deletions.
64 changes: 64 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build
description: Build all packages
inputs:
NODE_ENV:
description: 'Node environment'
required: false
default: 'staging'
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_STAGING_KEY:
description: 'Rudderstack staging key'
required: false
RUDDERSTACK_PRODUCTION_KEY:
description: 'Rudderstack production key'
required: false
RUDDERSTACK_URL:
description: 'Rudderstack url'
required: false
DATADOG_SESSION_SAMPLE_RATE_LOGS:
description: 'Datadog session sample rate for logs'
required: false

runs:
using: composite
steps:
- name: Build all packages
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
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 }}
GD_API_KEY: ${{ inputs.GD_API_KEY }}
GD_APP_ID: ${{ inputs.GD_APP_ID }}
GD_CLIENT_ID: ${{ inputs.GD_CLIENT_ID }}
RUDDERSTACK_STAGING_KEY: ${{ inputs.RUDDERSTACK_STAGING_KEY }}
RUDDERSTACK_URL: ${{ inputs.RUDDERSTACK_URL }}

run: npm run build:prod
shell: bash
32 changes: 32 additions & 0 deletions .github/actions/invalidate_master_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: invalidate_npm_cache
description: Invalidate the Master NPM cache
runs:
using: composite
steps:

- name: save_cache
uses: actions/cache/save@v3
with:
path: |-
node_modules
packages/account/node_modules
packages/api/node_modules
packages/appstore/node_modules
packages/bot-skeleton/node_modules
packages/bot-web-ui/node_modules
packages/cashier/node_modules
packages/components/node_modules
packages/core/node_modules
packages/hooks/node_modules
packages/cfd/node_modules
packages/indicators/node_modules
packages/p2p/node_modules
packages/reports/node_modules
packages/shared/node_modules
packages/stores/node_modules
packages/trader/node_modules
packages/translations/node_modules
packages/utils/node_modules
packages/analytics/node_modules
packages/wallets/node_modules
key: ${{ runner.os }}-build-master-cache-${{ hashFiles('./package-lock.json') }}
41 changes: 41 additions & 0 deletions .github/actions/npm_install_from_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: npm_install_from_cache
description: Install npm packages from cache
runs:
using: composite
steps:
# - name: Set ownership
# run: |
# # this is to fix GIT not linking owner of the checkout dir
# git config --system --add safe.directory '*'
# shell: bash
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache/restore@v3
with:
path: |-
node_modules
packages/account/node_modules
packages/api/node_modules
packages/appstore/node_modules
packages/bot-skeleton/node_modules
packages/bot-web-ui/node_modules
packages/cashier/node_modules
packages/components/node_modules
packages/core/node_modules
packages/hooks/node_modules
packages/cfd/node_modules
packages/indicators/node_modules
packages/p2p/node_modules
packages/reports/node_modules
packages/shared/node_modules
packages/stores/node_modules
packages/trader/node_modules
packages/translations/node_modules
packages/utils/node_modules
packages/analytics/node_modules
packages/wallets/node_modules
key: ${{ runner.os }}-build-master-cache-${{ hashFiles('./package-lock.json') }}
- name: Install npm packages
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm run bootstrap
shell: bash
26 changes: 26 additions & 0 deletions .github/actions/publish_to_pages_production/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: publish_to_pages_production
description: Publish to cloudflare pages (production)
inputs:
version:
description: 'Version of the app to release'
required: true
CLOUDFLARE_ACCOUNT_ID:
description: 'Cloudflare account id'
required: true
CLOUDFLARE_API_TOKEN:
description: 'Cloudflare token'
required: true
runs:
using: composite
steps:
- name: Publish to cloudflare pages (production)
env:
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }}
version: ${{ inputs.version }}
run: |-
npm i wrangler@3.1.0
cd packages/core
npx wrangler pages deploy dist/ --project-name=deriv-app-pages --branch=main
echo "New website - http://cf-pages-deriv-app.deriv.com"
shell: bash
26 changes: 26 additions & 0 deletions .github/actions/publish_to_pages_staging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: publish_to_pages_staging
description: Publish to cloudflare pages (staging)
inputs:
version:
description: 'Version of the app to release'
required: true
CLOUDFLARE_ACCOUNT_ID:
description: 'Cloudflare account id'
required: true
CLOUDFLARE_API_TOKEN:
description: 'Cloudflare token'
required: true
runs:
using: composite
steps:
- name: Publish to cloudflare pages (staging)
env:
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }}
version: ${{ inputs.version }}
run: |-
npm i wrangler@3.1.0
cd packages/core
npx wrangler pages deploy dist/ --project-name=deriv-app-pages --branch=staging
echo "New staging website - http://staging.cf-pages-deriv-app.deriv.com"
shell: bash
38 changes: 38 additions & 0 deletions .github/actions/send_slack_notifications/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: send_slack_notifications
description: Send Slack notifications
inputs:
SLACK_WEBHOOK_URL:
description: 'Slack webhook URL'
required: true
status:
description: 'Job status'
required: true
release_type:
description: 'Release type'
required: true
version:
description: 'Version'
required: true
default: 'N/A'
runs:
using: composite
steps:
- name: Send Slack Notification on Success
if: inputs.status == 'success'
run: |-
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "'"${{ inputs.release_type }}"' Release succeeded for app.deriv.com with version *'"${{ inputs.version }}"'*"
}' \
$SLACK_WEBHOOK_URL
shell: bash

- name: Send Slack Notification on Failure
if: inputs.status == 'failure'
run: |-
curl -X POST -H 'Content-type: application/json' \
--data '{
"text": "'"${{ inputs.release_type }}"' Release failed for app.deriv.com with version *'"${{ inputs.version }}"'*"
}' \
$SLACK_WEBHOOK_URL
shell: bash
9 changes: 9 additions & 0 deletions .github/actions/setup_node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Setup Node
description: 'Set up Node.js'
runs:
using: composite
steps:
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
12 changes: 12 additions & 0 deletions .github/actions/versioning/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: versioning
description: Versioning
inputs:
version_name:
description: Version name
required: false
runs:
using: composite
steps:
- name: Tag
run: echo "${{ inputs.version_name }}-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" > packages/core/dist/version
shell: bash
36 changes: 17 additions & 19 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
on: ["push", "pull_request"]

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, edited]
name: Coveralls

jobs:

build:
name: Reporter
runs-on: ubuntu-latest
runs-on: Runner_16cores_Deriv-app
steps:

- uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Bootstrap, Build, and make test-coverage
run: |
npm ci
npm run bootstrap
npm run build:all
JEST_MAX_WORKERS=3 npm run test:jest
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build
uses: "./.github/actions/build"
- name: Test
run: JEST_MAX_WORKERS=75% npm run test:jest -- --collectCoverage
- name: Coveralls
uses: coverallsapp/github-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/generate_and_push_deriv_api_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Checkout repo
id: step4
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout to repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge_and_release_to_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
timeout-minutes: 600
steps:
- name: Checkout to repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: master
- name: Setup node
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deriv App Production Workflow
on:
push:
tags:
- production.*
jobs:
build_test_and_publish:
name: Build, Test and Publish to Cloudflare Pages Production
environment: Production
runs-on: Runner_16cores_Deriv-app
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: "./.github/actions/setup_node"
- name: Install Dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build
uses: "./.github/actions/build"
with:
NODE_ENV: production
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
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_PRODUCTION_KEY: ${{ vars.RUDDERSTACK_PRODUCTION_KEY }}
RUDDERSTACK_URL: ${{ vars.RUDDERSTACK_URL }}
- name: Run tests
run: npm test
- name: Versioning
uses: "./.github/actions/versioning"
with:
version_name: production
- name: Publish to Cloudflare Pages Production
uses: "./.github/actions/publish_to_pages_production"
with:
version: $(echo cat packages/core/dist/version | bash)
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

send_slack_notification:
name: Send Slack notification
runs-on: Runner_16cores_Deriv-app
environment: Production
if: always()
needs: [build_test_and_publish]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Conclusion
uses: technote-space/workflow-conclusion-action@v3
- name: Send Slack Notification
uses: "./.github/actions/send_slack_notifications"
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ env.WORKFLOW_CONCLUSION }}
release_type: Production
version: $(echo cat packages/core/dist/version | bash)
Loading

0 comments on commit 4d08c20

Please sign in to comment.