From 50000f6e322606b6de0b44db42dc7c518384af2c Mon Sep 17 00:00:00 2001 From: balakrishna-binary Date: Fri, 29 Dec 2023 17:54:27 +0800 Subject: [PATCH 01/25] chore: setup preview link generation --- .github/actions/checkout.yml | 68 +++++++++ .github/workflows/generate_preview_link.yml | 138 ++++++++++++++++++ .../workflows/pre_generate_preview_link.yml | 36 +++++ 3 files changed, 242 insertions(+) create mode 100644 .github/actions/checkout.yml create mode 100644 .github/workflows/generate_preview_link.yml create mode 100644 .github/workflows/pre_generate_preview_link.yml diff --git a/.github/actions/checkout.yml b/.github/actions/checkout.yml new file mode 100644 index 0000000000..614eaadf52 --- /dev/null +++ b/.github/actions/checkout.yml @@ -0,0 +1,68 @@ +name: Checkout + +inputs: + fetch-depth: + default: 1 + required: false + type: number + path: + default: '' + required: false + type: string + repository: + default: ${{ github.repository }} + required: false + type: string + ref: + default: '' + required: false + type: string + alternate_ref: + default: '' + required: false + type: string + token: + default: ${{ github.token }} + required: false + type: string + +outputs: + ref_exists: + description: 'Specifies whether the ref exists or not' + value: ${{ steps.repo.outputs.ref-exists }} + +runs: + using: composite + + steps: + - id: repo + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: | + if git ls-remote --heads --quiet --exit-code https://${{ inputs.token }}@github.com/${{ inputs.repository }}.git ${{ inputs.ref }} + then + echo "::notice::Checkout: ${{ inputs.repository }} using ${{ inputs.ref }}" + echo "ref-exists=true" >> $GITHUB_OUTPUT + else + echo "::notice::Checkout: ${{ inputs.repository }} does not have ref ${{ inputs.ref }} (fallback to ${{ inputs.alternate_ref }})" + echo "ref-exists=false" >> $GITHUB_OUTPUT + fi + + - if: steps.repo.outputs.ref-exists == 'true' + uses: actions/checkout@v3 + with: + fetch-depth: ${{ inputs.fetch-depth }} + path: ${{ inputs.path }} + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + token: ${{ inputs.token }} + + - if: steps.repo.outputs.ref-exists == 'false' + uses: actions/checkout@v3 + with: + fetch-depth: ${{ inputs.fetch-depth }} + path: ${{ inputs.path }} + repository: ${{ inputs.repository }} + ref: ${{ inputs.alternate_ref }} + token: ${{ inputs.token }} diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml new file mode 100644 index 0000000000..5eb87dfaa0 --- /dev/null +++ b/.github/workflows/generate_preview_link.yml @@ -0,0 +1,138 @@ +name: Generate preview link + +permissions: + actions: write + checks: write + contents: write + deployments: write + pull-requests: write + statuses: write + +on: + workflow_run: + workflows: ['Pre-generate preview link'] + types: + - completed + +env: + HEAD_REF: ${{ github.head_ref }} + +concurrency: + group: cloudflare-pages-build-"$HEAD_REF" + cancel-in-progress: true + +jobs: + build_and_deploy_preview_link: + runs-on: Ubuntu-latest + steps: + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow_conclusion: success + run_id: ${{ github.event.workflow_run.id }} + name: 'pr-${{ github.event.workflow_run.id }}' + path: .pr + + - name: Retrieve pull request + id: pr_information + run: | + echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT + echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT + echo "branch_name=$(cat .pr/BRANCHNAME)" >> $GITHUB_OUTPUT + + - name: Post preview build comment + id: post_preview_build_comment + uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' + with: + issue_number: ${{steps.pr_information.outputs.issue_number}} + head_sha: ${{github.event.workflow_run.head_sha}} + + - name: Verify user + uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1' + with: + username: ${{steps.pr_information.outputs.username}} + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + + - name: Checkout SmartCharts + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/SmartCharts + path: SmartCharts + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: master + + - name: Checkout deriv-app + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/deriv-app + path: deriv-app + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: master + + - name: Custom flutter-chart + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/flutter-chart + path: flutter-chart + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: fe-changes + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 18.x + + - name: Setup deriv-app + run: cd deriv-app && npm install && npm run bootstrap + + - name: Remove @deriv-charts in deriv-app + run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist + + - name: Setup SmartCharts + run: cd SmartCharts && npm install + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.10.6' + channel: 'stable' + cache: true + + - name: Build flutter + run: | + cd SmartCharts/chart_app + flutter pub get + flutter build web --web-renderer html --release + + - name: Build SmartCharts + run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist + + - name: Run Tests + run: cd SmartCharts && npm run test + + - name: Build deriv-app + run: cd deriv-app && npm run build:all + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Publish to CF pages branch + id: publish_to_pages_branch + uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1' + with: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} + project_name: 'smartcharts-preview' + branch_name: 'pr-${{steps.pr_information.outputs.issue_number}}' + output_dir: deriv-app/packages/core/dist + + - name: 'Generate preview link comment' + uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1' + if: always() && steps.post_preview_build_comment.outcome == 'success' + with: + issue_number: ${{steps.pr_information.outputs.issue_number}} + check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}} + preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}} + status: ${{job.status}} diff --git a/.github/workflows/pre_generate_preview_link.yml b/.github/workflows/pre_generate_preview_link.yml new file mode 100644 index 0000000000..3700c728b2 --- /dev/null +++ b/.github/workflows/pre_generate_preview_link.yml @@ -0,0 +1,36 @@ +name: Pre-generate preview link + +permissions: + pull-requests: write + +on: + pull_request: + types: [opened, synchronize] + +env: + HEAD_REF: ${{ github.head_ref }} + +concurrency: + group: cloudflare-pages-verify-"$HEAD_REF" + cancel-in-progress: true + +jobs: + upload_pr_info: + runs-on: Ubuntu-latest + steps: + - name: Retrieve PR information + env: + ISSUE_NUMBER: ${{ github.event.number }} + USERNAME: ${{ github.event.pull_request.user.login }} + HEAD_REF: ${{ github.head_ref }} + run: | + mkdir -p ./pr + echo "$ISSUE_NUMBER" > ./pr/ISSUE_NUMBER + echo "$USERNAME" > ./pr/USERNAME + echo "$HEAD_REF" > ./pr/BRANCHNAME + + - name: Upload PR information to artifact + uses: actions/upload-artifact@v2 + with: + name: 'pr-${{github.run_id}}' + path: pr/ From cb3838b0cebcec7facf61ffe0a62225fb3b1ae5f Mon Sep 17 00:00:00 2001 From: balakrishna-binary Date: Fri, 29 Dec 2023 17:54:48 +0800 Subject: [PATCH 02/25] chore: remove unused workflows --- .github/workflows/release-automation.yml | 54 ------------------------ .github/workflows/tag-release.yml | 26 ------------ 2 files changed, 80 deletions(-) delete mode 100644 .github/workflows/release-automation.yml delete mode 100644 .github/workflows/tag-release.yml diff --git a/.github/workflows/release-automation.yml b/.github/workflows/release-automation.yml deleted file mode 100644 index a1f7464eff..0000000000 --- a/.github/workflows/release-automation.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Release automation for SmartCharts -permissions: - pull-requests: write -on: - workflow_dispatch: - inputs: - tag: - description: 'Tag' - required: true - skip_circleci_checks: - description: 'Skip checking CircleCI workflow' - type: boolean - required: false - skip_pending_checks: - description: 'Skip waiting for pull request checks' - type: boolean - required: false - - -concurrency: - group: release_automation_group - -jobs: - release_issues: - permissions: write-all - runs-on: ubuntu-latest - steps: - - name: Checkout to repo - uses: actions/checkout@v3 - with: - ref: master - - name: Setup node - uses: actions/setup-node@v2 - - name: Wait for logs to accumulate - run: | - sleep 10 - - name: Release issues in SmartCharts - uses: binary-com/fe-toolbox@production_V20230602_0 - with: - tag: ${{ inputs.tag }} - list_id: ${{ secrets.LIST_ID }} - platform: 'deriv-charts' - release_tags_list_id: ${{ secrets.RELEASE_TAGS_LIST_ID }} - regression_testing_template_id: ${{ secrets.REGRESSION_TESTING_TEMPLATE_ID }} - circleci_project_slug: 'gh/binary-com/SmartCharts' - circleci_workflow_name: 'release_staging' - skip_circleci_checks: ${{ inputs.skip_circleci_checks }} - skip_pending_checks: ${{ inputs.skip_pending_checks }} - CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }} - CLICKUP_API_TOKEN: ${{ secrets.CLICKUP_API_TOKEN }} - SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }} - SLACK_USER_TOKEN: ${{ secrets.SLACK_USER_TOKEN }} - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml deleted file mode 100644 index da54cf213e..0000000000 --- a/.github/workflows/tag-release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Tag for SmartCharts release - -permissions: write-all - -on: - workflow_dispatch: - inputs: - tag: - description: 'Tag' - required: true - -jobs: - create-tag: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Create and release tag - run: | - git config --global user.name "DerivFE" - git config --global user.email "fe-access@deriv.com" - - git tag ${{ inputs.tag }} ${{ github.ref }} - git push origin ${{ inputs.tag }} From bef66442cc46c0c6bc06d1e0a8ccd33ced8a89c9 Mon Sep 17 00:00:00 2001 From: balakrishna-binary Date: Fri, 29 Dec 2023 17:58:29 +0800 Subject: [PATCH 03/25] chore: add PAT --- .github/workflows/generate_preview_link.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 5eb87dfaa0..96fdeac057 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -103,6 +103,8 @@ jobs: cd SmartCharts/chart_app flutter pub get flutter build web --web-renderer html --release + env: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - name: Build SmartCharts run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist From a63ccff1c673a4a48c241ecaccfd6f131a5d2d1c Mon Sep 17 00:00:00 2001 From: balakrishna-binary Date: Fri, 29 Dec 2023 18:00:18 +0800 Subject: [PATCH 04/25] chore: remove deriv-app deploy --- scripts/deriv-app-deploy.sh | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 scripts/deriv-app-deploy.sh diff --git a/scripts/deriv-app-deploy.sh b/scripts/deriv-app-deploy.sh deleted file mode 100644 index 3ad4470911..0000000000 --- a/scripts/deriv-app-deploy.sh +++ /dev/null @@ -1,6 +0,0 @@ -npm run build -rm -rf node_modules && rm .*rc *.js *.ts && rm -rf deriv-app -git clone https://github.com/binary-com/deriv-app.git --depth 1 -cd deriv-app && npm run bootstrap && rm -rf node_modules/@deriv/deriv-charts/dist && cd .. -cp -R dist deriv-app/node_modules/@deriv/deriv-charts/ -cd deriv-app && npm run build:prod From 37f454f69d64fb3924d888fe5668009d6c4a97b5 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:09:41 +0800 Subject: [PATCH 05/25] new changes --- .github/CODEOWNERS | 6 + .github/actions/checkout.yml | 68 +++++++++ .github/dependabot.yml | 6 + .../generate_and_push_deriv_charts.yml | 4 +- .github/workflows/generate_preview_link.yml | 138 ++++++++++++++++++ .../workflows/pre_generate_preview_link.yml | 36 +++++ 6 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/actions/checkout.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/generate_preview_link.yml create mode 100644 .github/workflows/pre_generate_preview_link.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..1fe4aefe1f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,6 @@ +# Configuration of code ownership and review approvals for the binary-com/deriv-app repo. +# +# More info: https://help.github.com/articles/about-codeowners/ +# + +* @binary-com/write-admin-smartcharts \ No newline at end of file diff --git a/.github/actions/checkout.yml b/.github/actions/checkout.yml new file mode 100644 index 0000000000..406e637160 --- /dev/null +++ b/.github/actions/checkout.yml @@ -0,0 +1,68 @@ +name: Checkout + +inputs: + fetch-depth: + default: 1 + required: false + type: number + path: + default: '' + required: false + type: string + repository: + default: ${{ github.repository }} + required: false + type: string + ref: + default: '' + required: false + type: string + alternate_ref: + default: '' + required: false + type: string + token: + default: ${{ github.token }} + required: false + type: string + +outputs: + ref_exists: + description: 'Specifies whether the ref exists or not' + value: ${{ steps.repo.outputs.ref-exists }} + +runs: + using: composite + + steps: + - id: repo + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: | + if git ls-remote --heads --quiet --exit-code https://${{ inputs.token }}@github.com/${{ inputs.repository }}.git ${{ inputs.ref }} + then + echo "::notice::Checkout: ${{ inputs.repository }} using ${{ inputs.ref }}" + echo "ref-exists=true" >> $GITHUB_OUTPUT + else + echo "::notice::Checkout: ${{ inputs.repository }} does not have ref ${{ inputs.ref }} (fallback to ${{ inputs.alternate_ref }})" + echo "ref-exists=false" >> $GITHUB_OUTPUT + fi + + - if: steps.repo.outputs.ref-exists == 'true' + uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 + with: + fetch-depth: ${{ inputs.fetch-depth }} + path: ${{ inputs.path }} + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + token: ${{ inputs.token }} + + - if: steps.repo.outputs.ref-exists == 'false' + uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 + with: + fetch-depth: ${{ inputs.fetch-depth }} + path: ${{ inputs.path }} + repository: ${{ inputs.repository }} + ref: ${{ inputs.alternate_ref }} + token: ${{ inputs.token }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..7b2ee3a629 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/generate_and_push_deriv_charts.yml b/.github/workflows/generate_and_push_deriv_charts.yml index f4cdc0eac7..c34397f672 100644 --- a/.github/workflows/generate_and_push_deriv_charts.yml +++ b/.github/workflows/generate_and_push_deriv_charts.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Setup node and npm id: step1 - uses: actions/setup-node@v2 + uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a with: node-version: '18' check-latest: true @@ -18,7 +18,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - name: Checkout repo id: step2 - uses: actions/checkout@v3 + uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 with: fetch-depth: 1 ref: master diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml new file mode 100644 index 0000000000..03287449fa --- /dev/null +++ b/.github/workflows/generate_preview_link.yml @@ -0,0 +1,138 @@ +name: Generate preview link + +permissions: + actions: write + checks: write + contents: write + deployments: write + pull-requests: write + statuses: write + +on: + workflow_run: + workflows: ['Pre-generate preview link'] + types: + - completed + +env: + HEAD_REF: ${{ github.head_ref }} + +concurrency: + group: cloudflare-pages-build-"$HEAD_REF" + cancel-in-progress: true + +jobs: + build_and_deploy_preview_link: + runs-on: Ubuntu-latest + steps: + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow_conclusion: success + run_id: ${{ github.event.workflow_run.id }} + name: 'pr-${{ github.event.workflow_run.id }}' + path: .pr + - name: Verify user + uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1' + with: + username: ${{steps.pr_information.outputs.username}} + token: ${{ secrets.PREVIEW_LINK_TOKEN }} + - name: Retrieve pull request + id: pr_information + run: | + echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT + echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT + echo "branch_name=$(cat .pr/BRANCHNAME)" >> $GITHUB_OUTPUT + + - name: Post preview build comment + id: post_preview_build_comment + uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' + with: + issue_number: ${{steps.pr_information.outputs.issue_number}} + head_sha: ${{github.event.workflow_run.head_sha}} + + - name: Checkout SmartCharts + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/SmartCharts + path: SmartCharts + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: master + + - name: Checkout deriv-app + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/deriv-app + path: deriv-app + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: master + + - name: Custom flutter-chart + uses: './.github/actions/checkout' + with: + repository: ${{steps.pr_information.outputs.username}}/flutter-chart + path: flutter-chart + ref: ${{steps.pr_information.outputs.branch_name}} + alternate_ref: fe-changes + + - name: Setup Node + uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4 + with: + node-version: 18.x + + - name: Setup deriv-app + run: cd deriv-app && npm install && npm run bootstrap + + - name: Remove @deriv-charts in deriv-app + run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist + + - name: Setup SmartCharts + run: cd SmartCharts && npm install + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.10.6' + channel: 'stable' + cache: true + + - name: Build flutter + run: | + cd SmartCharts/chart_app + flutter pub get + flutter build web --web-renderer html --release + env: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + + - name: Build SmartCharts + run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist + + - name: Run Tests + run: cd SmartCharts && npm run test + + - name: Build deriv-app + run: cd deriv-app && npm run build:all + + - name: Setup Node + uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a + with: + node-version: 20 + + - name: Publish to CF pages branch + id: publish_to_pages_branch + uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1' + with: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} + project_name: 'smartcharts-preview' + branch_name: 'pr-${{steps.pr_information.outputs.issue_number}}' + output_dir: deriv-app/packages/core/dist + + - name: 'Generate preview link comment' + uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1' + if: always() && steps.post_preview_build_comment.outcome == 'success' + with: + issue_number: ${{steps.pr_information.outputs.issue_number}} + check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}} + preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}} + status: ${{job.status}} diff --git a/.github/workflows/pre_generate_preview_link.yml b/.github/workflows/pre_generate_preview_link.yml new file mode 100644 index 0000000000..f68fe0411c --- /dev/null +++ b/.github/workflows/pre_generate_preview_link.yml @@ -0,0 +1,36 @@ +name: Pre-generate preview link + +permissions: + pull-requests: write + +on: + pull_request: + types: [opened, synchronize] + +env: + HEAD_REF: ${{ github.head_ref }} + +concurrency: + group: cloudflare-pages-verify-"$HEAD_REF" + cancel-in-progress: true + +jobs: + upload_pr_info: + runs-on: Ubuntu-latest + steps: + - name: Retrieve PR information + env: + ISSUE_NUMBER: ${{ github.event.number }} + USERNAME: ${{ github.event.pull_request.user.login }} + HEAD_REF: ${{ github.head_ref }} + run: | + mkdir -p ./pr + echo "$ISSUE_NUMBER" > ./pr/ISSUE_NUMBER + echo "$USERNAME" > ./pr/USERNAME + echo "$HEAD_REF" > ./pr/BRANCHNAME + + - name: Upload PR information to artifact + uses: actions/upload-artifact@97b7dace6c8d860ce9708aba808be6a2ee4cbc3a + with: + name: 'pr-${{github.run_id}}' + path: pr/ From d15ca38f8fb621b8ef56c12c925a61f19459b8af Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:54:19 +0800 Subject: [PATCH 06/25] generate link --- .github/workflows/generate_preview_link.yml | 130 ++++++++---------- .../workflows/pre_generate_preview_link.yml | 36 ----- 2 files changed, 59 insertions(+), 107 deletions(-) delete mode 100644 .github/workflows/pre_generate_preview_link.yml diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 03287449fa..4f038c01f5 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -9,10 +9,8 @@ permissions: statuses: write on: - workflow_run: - workflows: ['Pre-generate preview link'] - types: - - completed + pull_request_target: + types: [opened, synchronize] env: HEAD_REF: ${{ github.head_ref }} @@ -25,114 +23,104 @@ jobs: build_and_deploy_preview_link: runs-on: Ubuntu-latest steps: - - name: Download artifact - id: download-artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow_conclusion: success - run_id: ${{ github.event.workflow_run.id }} - name: 'pr-${{ github.event.workflow_run.id }}' - path: .pr - - name: Verify user - uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1' - with: - username: ${{steps.pr_information.outputs.username}} - token: ${{ secrets.PREVIEW_LINK_TOKEN }} - - name: Retrieve pull request - id: pr_information - run: | + - name: Verify user + uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1" + with: + username: ${{steps.pr_information.outputs.username}} + token: ${{ secrets.PREVIEW_LINK_TOKEN }} + - name: Retrieve pull request + id: pr_information + run: | echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT echo "branch_name=$(cat .pr/BRANCHNAME)" >> $GITHUB_OUTPUT - - name: Post preview build comment - id: post_preview_build_comment - uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' - with: + - name: Post preview build comment + id: post_preview_build_comment + uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' + with: issue_number: ${{steps.pr_information.outputs.issue_number}} head_sha: ${{github.event.workflow_run.head_sha}} - - name: Checkout SmartCharts - uses: './.github/actions/checkout' - with: + - name: Checkout SmartCharts + uses: './.github/actions/checkout' + with: repository: ${{steps.pr_information.outputs.username}}/SmartCharts path: SmartCharts ref: ${{steps.pr_information.outputs.branch_name}} alternate_ref: master - - - name: Checkout deriv-app - uses: './.github/actions/checkout' - with: + - name: Checkout deriv-app + uses: './.github/actions/checkout' + with: repository: ${{steps.pr_information.outputs.username}}/deriv-app path: deriv-app ref: ${{steps.pr_information.outputs.branch_name}} alternate_ref: master - - - name: Custom flutter-chart - uses: './.github/actions/checkout' - with: + - name: Custom flutter-chart + uses: './.github/actions/checkout' + with: repository: ${{steps.pr_information.outputs.username}}/flutter-chart path: flutter-chart ref: ${{steps.pr_information.outputs.branch_name}} alternate_ref: fe-changes - - name: Setup Node - uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4 - with: + - name: Setup Node + uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4 + with: node-version: 18.x - - name: Setup deriv-app - run: cd deriv-app && npm install && npm run bootstrap + - name: Setup deriv-app + run: cd deriv-app && npm install && npm run bootstrap - - name: Remove @deriv-charts in deriv-app - run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist + - name: Remove @deriv-charts in deriv-app + run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist - - name: Setup SmartCharts - run: cd SmartCharts && npm install + - name: Setup SmartCharts + run: cd SmartCharts && npm install - - uses: subosito/flutter-action@v2 - with: + - uses: subosito/flutter-action@v2 + with: flutter-version: '3.10.6' channel: 'stable' cache: true - - name: Build flutter - run: | + - name: Build flutter + run: | cd SmartCharts/chart_app flutter pub get flutter build web --web-renderer html --release - env: - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + env: + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - name: Build SmartCharts - run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist + - name: Build SmartCharts + run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist - - name: Run Tests - run: cd SmartCharts && npm run test + - name: Run Tests + run: cd SmartCharts && npm run test - - name: Build deriv-app - run: cd deriv-app && npm run build:all + - name: Build deriv-app + run: cd deriv-app && npm run build:all - - name: Setup Node - uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a - with: - node-version: 20 + - name: Setup Node + uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a + with: + node-version: 20 - - name: Publish to CF pages branch - id: publish_to_pages_branch - uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1' - with: + - name: Publish to CF pages branch + id: publish_to_pages_branch + uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1' + with: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }} project_name: 'smartcharts-preview' - branch_name: 'pr-${{steps.pr_information.outputs.issue_number}}' + branch_name: 'pr-${{github.event.number}}' output_dir: deriv-app/packages/core/dist - - name: 'Generate preview link comment' - uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1' - if: always() && steps.post_preview_build_comment.outcome == 'success' - with: - issue_number: ${{steps.pr_information.outputs.issue_number}} + - name: 'Generate preview link comment' + if: always() && steps.post_preview_build_comment.outcome == 'success' + uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1' + with: + issue_number: ${{github.event.number}} check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}} preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}} - status: ${{job.status}} + status: ${{job.status}} \ No newline at end of file diff --git a/.github/workflows/pre_generate_preview_link.yml b/.github/workflows/pre_generate_preview_link.yml deleted file mode 100644 index f68fe0411c..0000000000 --- a/.github/workflows/pre_generate_preview_link.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Pre-generate preview link - -permissions: - pull-requests: write - -on: - pull_request: - types: [opened, synchronize] - -env: - HEAD_REF: ${{ github.head_ref }} - -concurrency: - group: cloudflare-pages-verify-"$HEAD_REF" - cancel-in-progress: true - -jobs: - upload_pr_info: - runs-on: Ubuntu-latest - steps: - - name: Retrieve PR information - env: - ISSUE_NUMBER: ${{ github.event.number }} - USERNAME: ${{ github.event.pull_request.user.login }} - HEAD_REF: ${{ github.head_ref }} - run: | - mkdir -p ./pr - echo "$ISSUE_NUMBER" > ./pr/ISSUE_NUMBER - echo "$USERNAME" > ./pr/USERNAME - echo "$HEAD_REF" > ./pr/BRANCHNAME - - - name: Upload PR information to artifact - uses: actions/upload-artifact@97b7dace6c8d860ce9708aba808be6a2ee4cbc3a - with: - name: 'pr-${{github.run_id}}' - path: pr/ From b959c6b23304a253ab7d3c09790b7728e591331f Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:07:53 +0800 Subject: [PATCH 07/25] testing test link --- .github/workflows/generate_preview_link.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 4f038c01f5..729a8ec875 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -23,11 +23,6 @@ jobs: build_and_deploy_preview_link: runs-on: Ubuntu-latest steps: - - name: Verify user - uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1" - with: - username: ${{steps.pr_information.outputs.username}} - token: ${{ secrets.PREVIEW_LINK_TOKEN }} - name: Retrieve pull request id: pr_information run: | @@ -40,7 +35,7 @@ jobs: uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' with: issue_number: ${{steps.pr_information.outputs.issue_number}} - head_sha: ${{github.event.workflow_run.head_sha}} + head_sha: ${{github.event.pull_request.head.sha}} - name: Checkout SmartCharts uses: './.github/actions/checkout' From dfd05ad802139fc2930456173d6b45f9bca33c14 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:23:42 +0800 Subject: [PATCH 08/25] test link --- .github/actions/{checkout.yml => checkout/action.yml} | 6 +++++- .github/workflows/generate_preview_link.yml | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) rename .github/actions/{checkout.yml => checkout/action.yml} (93%) diff --git a/.github/actions/checkout.yml b/.github/actions/checkout/action.yml similarity index 93% rename from .github/actions/checkout.yml rename to .github/actions/checkout/action.yml index 406e637160..d4017bbf09 100644 --- a/.github/actions/checkout.yml +++ b/.github/actions/checkout/action.yml @@ -17,6 +17,10 @@ inputs: default: '' required: false type: string + alternate_repository: + default: '' + required: false + type: string alternate_ref: default: '' required: false @@ -63,6 +67,6 @@ runs: with: fetch-depth: ${{ inputs.fetch-depth }} path: ${{ inputs.path }} - repository: ${{ inputs.repository }} + repository: ${{ inputs.alternate_repository }} ref: ${{ inputs.alternate_ref }} token: ${{ inputs.token }} diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 729a8ec875..e758fe850a 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -36,13 +36,13 @@ jobs: with: issue_number: ${{steps.pr_information.outputs.issue_number}} head_sha: ${{github.event.pull_request.head.sha}} - - name: Checkout SmartCharts uses: './.github/actions/checkout' with: repository: ${{steps.pr_information.outputs.username}}/SmartCharts path: SmartCharts ref: ${{steps.pr_information.outputs.branch_name}} + alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app uses: './.github/actions/checkout' @@ -50,6 +50,7 @@ jobs: repository: ${{steps.pr_information.outputs.username}}/deriv-app path: deriv-app ref: ${{steps.pr_information.outputs.branch_name}} + alternate_repository: 'binary-com/deriv-app' alternate_ref: master - name: Custom flutter-chart uses: './.github/actions/checkout' @@ -57,6 +58,7 @@ jobs: repository: ${{steps.pr_information.outputs.username}}/flutter-chart path: flutter-chart ref: ${{steps.pr_information.outputs.branch_name}} + alternate_repository: 'regentmarkets/flutter-chart' alternate_ref: fe-changes - name: Setup Node From 1967ff2bde0c1e8297dc58d091cf3115dfdacf1b Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:24:49 +0800 Subject: [PATCH 09/25] Delete README.md --- README.md | 693 ------------------------------------------------------ 1 file changed, 693 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index a9d1522f5a..0000000000 --- a/README.md +++ /dev/null @@ -1,693 +0,0 @@ -

- SmartCharts -

- -SmartCharts is both the name of the app ([charts.binary.com](https://charts.binary.com/)) and the charting library. - -[![npm](https://img.shields.io/badge/npm->=9-blue)](https://www.npmjs.com/package/@deriv/deriv-charts) ![node](https://img.shields.io/badge/node-%3E%3D18-blue.svg) - -## In this document: - -- [Pre-installation](#pre-installation) -- [Quick start](#quick-start) -- [Usage](#Usage) -- [How to contribute](#how-to-contribute) -- [Manage translations](#manage-translations) -- [Manage releases](#manage-releases) -- [FAQ](#faq) - -## Pre-installation - -Before running or contribute to this project, you need to have the setup of the following packages in your environment: - -- node -- npm -- git (for `contribution`) - -## Quick start - -1. **Fork the project** - - In order to work on your own version of the Deriv application, please fork the project to your own repo. - -2. **Clone using SSH** - - ```sh - git clone git@github.com:binary-com/SmartCharts.git - ``` - -3. **Enter project directory** - -In the `app` folder, we provide a working webpack project that uses the smartcharts library. Simply `cd` to that directory. - -4. **Install your dependencies:** - - ```sh - npm install - ``` - -5. **To start developing:** - - ```sh - npm start - ``` - -6. **Open the source code and start editing!** - - The sample app should be running in `http://localhost:8080`. - -### Other useful commands: - -- use `npm install` to install dependencies -- use `npm start` to launch webpack dev server -- use `npm run build` to build the library -- use `npm run build:app` to build the [charts.binary.com](https://charts.binary.com/) app -- use `npm run analyze` to run webpack-bundle-analyzer -- use `npm run test` to run unit tests -- use `npm run coverage` to see test coverage - -> Note: eventhough both `npm run build` and `npm run build:app` outputs `smartcharts.js` and `smartcharts.css`, **they are not the same files**. One outputs a library and the the other outputs an app. - -## Usage - -You can install the library using one of the following commands: - -Using npm: - -```bash -$ npm install @deriv/deriv-chart -``` - -Using yarn: - -```bash -$ yarn add @deriv/deriv-chart -``` - -**Important Note:** the license for the library is tied to the `binary.com` domain name; it will not work in github pages. - -You can add the library to your project using the following commands: - - yarn add @deriv/deriv-chart # Release - yarn add @deriv/deriv-chart@beta # Beta - -You can refer to library usage inside `app/index.jsx`: - -```jsx -import { SmartChart } from '@deriv/deriv-chart'; - -class App extends React.Component { - render() { - return ( - {}} // Passes the whole request object - requestForget={({ tick_history, granularity, ... }, cb) => {}} // request object and cb is exactly the same reference passed to subscribe - // for active_symbols, trading_times, ... (NOT streaming) - requestAPI={({...}) => Promise} // whole request object, shouldn't contain req_id - /> - ); - } -}; -``` - -SmartCharts expects library user to provide `requestSubscribe`, `requestForget` and `requestAPI`. Refer to [API](#api) for more details. - -The job of loading the active symbols or trading times or stream data from cache or retrieving from websocket is therefore NOT the responsibility of SmartCharts but the host application. SmartCharts simply makes the requests and expect a response in return. - -Some important notes on your webpack.config.js (refer to `app/webpack.config.js`): - -- smartcharts CSS file will need to be copied from the npm library (remember to include in your `index.html`). -- smartcharts consist of a few chunks (which has filenames `*.smartcharts.*`), which it downloads asynchronously during runtime. Therefore, it needs to know where the library user places its chunks via the `setSmartChartsPublicPath` function: - -```js -import { setSmartChartsPublicPath } from "@deriv/deriv-chart"; - -// SmartCharts chunk are deployed to https://mysite.com/dist/* -setSmartChartsPublicPath("/dist/"); -``` - -We can use the `copy-webpack-plugin` webpack plugin to copy over SmartCharts chunks: - -```js -new CopyWebpackPlugin([ - { from: "./node_modules/@deriv/deriv-chart/dist/*.smartcharts.*" }, - { from: "./node_modules/@deriv/deriv-chart/dist/smartcharts.css" }, -]); -``` -### API - -> Note: Props will take precedence over values set by the library. - -Props marked with `*` are **mandatory**: - -| Props | Description | -| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| requestAPI\* | SmartCharts will make single API calls by passing the request input directly to this method, and expects a `Promise` to be returned. | -| requestSubscribe\* | SmartCharts will make streaming calls via this method. `requestSubscribe` expects 2 parameters `(request, callback) => {}`: the `request` input and a `callback` in which response will be passed to for each time a response is available. Keep track of this `callback` as SmartCharts will pass this to you to forget the subscription (via `requestForget`). | -| requestForget\* | When SmartCharts no longer needs a subscription (made via `requestSubscribe`), it will call this method (passing in `request` and `callback` passed from `requestSubscribe`) to halt the subscription. | -| id | Uniquely identifies a chart's indicators, symbol and layout; saving them to local storage and loading them when page refresh. If not set, SmartCharts renders a fresh chart with default values on each refresh. Defaults to `undefined`. | -| getMarketsOrder | Callback function to set/order the active symbols category. `active_symbols` is passed to the callback and an array of markets is expected in return. Allowed values are `forex`, `basket_index`, `indices`, `stocks`, `commodities`, `synthetic_index` and `cryptocurrency`. Defaults to `undefined` | -| getIndicatorHeightRatio | Callback function to set/order the height of the active indicators that attach to the bottom of the chart. The chart pass two parameters, `chart_height` and `indicator_count` and the callback should return an object that contains two parameters, `height` and `percent` which `height` present the height of each indicator in pixel and the `percent` present the percentage of height compare to chart height. Example: `getIndicatorHeightRatio: (chart_height, indicator_count) => ({height, percent})` . Defaults to `undefined` | -| symbol | Sets the main chart symbol. Defaults to `R_100`. Refer [Props vs UI](#props-vs-ui) for usage details. | -| initialData | Set initial data that the library requires for booting up. Refer [initialData](#initial-data) for usage details. | -| feedCall | Enable/Disable the feed call for getting requirement resources. Default is `{activeSymbols: true,tradingTimes: true}` | -| granularity | Sets the granularity of the chart. Allowed values are 60, 120, 180, 300, 600, 900, 1800, 3600, 7200, 14400, 28800, 86400. Defaults to 0. Refer [Props vs UI](#props-vs-ui) for usage details. | -| chartType | Sets the chartType. Choose between `mountain` (Line), `line` (Dot), `colored_line` (Colored Dot), `spline`, `baseline`, `candle`, `colored_bar` (OHLC), `hollow_candle`, `heikinashi`, `kagi`, `linebreak`, `renko`, `rangebars`, and `pandf` (Point & Figure). Defaults to `mountain`. Refer [Props vs UI](#props-vs-ui) for usage details. | -| contractInfo | An object of `ProposalOpenContract` type. Includes data of a contract for which ticks are currently being drawn. Includes such data as `tick_stream` array, `tick_count` number, `underlying` string, etc. Required for `shouldDrawTicksFromContractInfo` prop to work. Defaults to an `{}` empty object. | -| startEpoch | Set the start epoch of the chart | -| endEpoch | Set the end epoch of the chart | -| chartControlsWidgets | Render function for chart control widgets. Set to `null` if you want to hide chart controls. Refer to [Customising Components](#customising-components). | -| topWidgets | Render function for top widgets. Refer to [Customising Components](#customising-components). | -| bottomWidgets | Render function for bottom widgets. Refer to [Customising Components](#customising-components). | -| toolbarWidget | Render function for floating toolbar widgets. Refer to [Customising Components](#customising-components). | -| isMobile | Switch between mobile or desktop view. Defaults to `false`. | -| onSettingsChange | Callback that will be fired each time a setting is changed. | -| stateChangeListener | Callback that will be fired on chart state change, It will return two parameters `(state, option)`. An state, and an option that is related to desire state. Chart has three states that are: `INITIAL` , `READY` and `SCROLL_TO_LEFT`. | -| settings | Sets the chart settings. Refer to [Chart Settings](#chart-settings) | -| barriers | Draw chart barriers. Refer to [Barriers API](#barriers-api) for usage details | -| enableRouting | Enable routing for dialogs. Defaults to `false` | -| isConnectionOpened | Sets the connection status. If set, upon reconnection smartcharts will either patch missing tick data or refresh the chart, depending on granularity; if not set, it is assumed that connection is always opened. Defaults to `undefined`. | -| onMessage | SmartCharts will send notifications via this callback, should it be provided. Each notification will have the following structure: `{ text, type, category }`. | -| isAnimationEnabled | Determine whether chart animation is enabled or disabled. It may needs to be disabled for better performance. Defaults to `true`. | -| showLastDigitStats | Shows last digits stats. Defaults to `false`. | -| scrollToEpoch | Scrolls the chart to the leftmost side and sets the last spot/bar as the first visible spot/bar in the chart. Also, it disables scrolling until the chart reaches the 3/4 of the width of the main pane of the chart. Defaults to `null`. | - | -| clearChart | Clear the chart. | -| onExportLayout | Export the layout and send it back using this callback. | -| importedLayout | The layout to be imported to chart. It should be the layout that was exported in onExportLayout; | -| shouldDrawTicksFromContractInfo | Determine whether SmartCharts should draw ticks on the chart based on `contractInfo` object, which contains data from `proposal_open_contract` API response, instead of ticks from `ticks_history` API response. Should be used together with `contractInfo` prop described above, otherwise `ticks_history` API response will be used for drawing ticks as usual. Defaults to `false`. | -| shouldFetchTradingTimes | Determine whether an API call for fetching trading times is necessary for the new chart or not. Defaults to `true` | -| should_zoom_out_on_yaxis | Forces y-axis to zoom out. Overrides `top` and `bottom` values of `yAxisMargin` prop. Defaults to `undefined`. | -| shouldFetchTickHistory | Determine whether an API call for fetching tick history is necessary for the new chart or not. Defaults to `true` | -| allTicks | Provides all_ticks contract data for chart rendering when contract with duration = 'ticks' . Defaults to `undefined` | -| maxTick | Set the max number of first points/candles in the visible chart area. The value should be number greater than zero. Defaults to `undefined` | -| crosshair | Set state of Crosshair Component. Allowed values are undefined, 0,1,2. Defaults to `undefined` | -| crosshairTooltipLeftAllow | Set max left position which chart allow to render left side tooltip of crosshair, if mouse position before this size, the crosshair tooltip move to right side of mouse, if set `null` then chart specify `315px` as default value. Defaults to `null` | -| zoom | Zoom in and Zoom out the chart. the value should be `1` or `-1`. If the value is `1` the chart will be zoomed in, and if the value is `-1` it zoomed out. | -| yAxisMargin | Set the margins of chart yAxis. It's an object that takes two parameters, `bottom` for margin bottom of chart, and `top` for the top margin of chart. | -| enableScroll | Enable/disable scroll feature in chart. Scroll gets disable on chart scale `1:1` and enable whenever user zoom in/out. This property override that feature . Defaults to `true` | -| enableZoom | Enable/disable zoom feature in chart. Defaults to `true` | - -### Chart Settings - -| Attribute | Description | -| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| countdown | Show Countdown. Defaults to `false`. | -| theme | Sets the chart theme. themes are (`dark\|light`), and default is `light`. | -| lang | Sets the language. Defaults to `en`. | -| minimumLeftBars | The default number of bars to display on the chart. It's used in combination with `whitespace` setting in order to adjust white space width. Please refer to `whitespace` below for more details. Defaults to `undefined`. | -| position | Sets the position of the chart controls. Choose between `left` and `bottom`. In mobile this is always `bottom`. Defaults to `bottom`. | -| enabledNavigationWidget | Show or hide navigation widget. Defaults to `false` | -| isHighestLowestMarkerEnabled | Show or hide the highest and lowest tick on the chart. Defaults to `false`. | -| whitespace | The default width of whitespace between the right edge of the chart and the y-axis. It should be used in combination with `minimumLeftBars` setting value. For more details, please refer to stxx.preferences.whitespace in CIQ documentation. Defaults to `undefined`. | - -#### InitialData - -Initial data property designed to pass prepared chart data in case you don't want to wait for Feed data or if you simply want to make the chart render quicker on its initial load. It gets the properties below and all of them are optional, so if you pass the data, the chart will use that data, but if you pass `null` instead, the chart will default to the Feed call and get the data from API. -**notice:** these data are only use for initialing sequence and after that, chart request on Feed to get data. -| Attribute | Description | Sample Data | -| --- | --- | --- | -| activeSymbols | An array of active symbols (available markets) is used to load the market selector. Default is `null`. This value would update in the chart is user toggle property of `refreshActiveSymbols` that cause the chart to request for activeSymbols on the Feed | `[{ allow_forward_starting: 0, display_name: 'AUD Basket', exchange_is_open: 1, is_trading_suspended: 0, market: 'basket_index', market_display_name: 'Basket Indices', pip: 0.001, submarket: 'forex_basket', submarket_display_name: 'Forex Basket', symbol: 'WLDAUD', symbol_type: 'forex_basket' }, ...]` -|tradingTimes | An array of markets trading time is used to determine close/open markets. Default is `null`. The chart will request new data via Feed in a sequence that is calculated regards markets trading time. | `{trading_times: {markets: [{ name: 'Forex', submarkets: [{ name: 'Major Pairs', symbols: [{name: 'AUD/JPY', symbol: 'frxAUDJPY', times: { close: ['23:59:59'], open: ['00:00:00'], settlement: '23:59:59' }, trading_days: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],events: [{ dates: 'Fridays', descrip: 'Closes early (at 20:55)' },{ dates: '2020-12-25', descrip: 'Christmas Day' },{ dates: '2021-01-01', descrip: "New Year's Day" }], ...}, ]},...]...],}}` -| masterData | An array of ticks that are used to load the graph (candles). Default is `null`. If the Feed is available, the chart will call `fetchInitialData` via Feed to get the initial ticks, for old data it calls `fetchPaginationData` and receives new ticks constantly. If this property is filled, chart user `symbol` property and `setting` property (to extract chart type and interval) and the masterData to load the graph. **Notice:** chart interval in the setting property should be the same as masterData epoch/Date property. If the symbol property does not fill, the chart uses the `symbol` property that exists in the localStorage with the key of `layout-*`, and if that property also does not fill, the chart throws a console error. **(if the desired symbol does not fill in the `symbol` property or `layout-*` localStorage, it caused the chart to just load the given masterData and does not call for the `fetchInitialData` API)**. | `[{"Date":"2020-11-16T04:28:00", "Close":8287.85}, {"Date":"2020-11-16T04:26:00", "Open":8283.25,"High":8293.750015,"Low":8278.75,"Close":8293.75},...]` - -#### Barriers API - -`barriers` props accepts an array of barrier configurations: - -```jsx - -``` - -Attributes marked with `*` are **mandatory**: - -| Attribute | Description | -| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| shadeColor | Barrier shade color. Defaults to `green`. | -| color | Price line color. Defaults to `#000`. | -| shade | Shade type; choose between `NONE_SINGLE`, `NONE_DOUBLE`, `ABOVE`, `BELOW`, `OUTSIDE` or `BETWEEN`. Defaults to `NONE_SINGLE`. | -| hideBarrierLine | hide/show the barrier line. Can be used to show only the title. Defaults to `false`. | -| hideOffscreenLine | hide/show the barrier line when it is offscreen. Defaults to `false`. | -| hideOffscreenBarrier | hide/show the barrier line & title when it is offscreen. Defaults to `false`. | -| hidePriceLines | hide/show the price lines. Defaults to `false`. | -| lineStyle | Sets the style of the price lines; choose between `dotted`, `dashed`, or `solid`. Defaults to `dashed`. | -| onChange | When price of high or low barrier changes (including when switched toggling `relative` or setting `high\|low`), `onChange` will pass the high and low barriers as `{ high, low }`. | -| relative | Toggle between relative and absolute barriers. Defaults to `false`. | -| draggable | Toggles whether users can drag the price lines and change the barrier directly from the chart. Defaults to `true`. | -| title | Title text of the barrier | -| isSingleBarrier | Shows only High barrier, stops low barrier & shades from rendering when the flag is true. Defaults to `false`. | -| showOffscreenArrows | hide/show arrows with direction when the barrier is offscreen. Defaults to `false`. | -| opacityOnOverlap | Sets the opacity of the barrier when it is overlapping with other barrier. | -| high\* | Sets the price of the high barrier. | -| low\* | Sets the price of the low barrier. | -#### ~~Marker API~~ (Depricated) - -Markers provide a way for developers to place DOM elements inside the chart that are positioned based on date, values or tick location. Unlike [CharIQ's Markers](http://documentation.chartiq.com/tutorial-Markers.html#main), we only allow markers to be placed on the main chart. Also note that this Marker implementation does not factor the width and height of the marker; this is expensive to calculate, so we expect you to offset this in CSS. - -```jsx - - - {/* Place marker content here */} -
-
Trade Start
- - -``` - -| Attribute | Description | -| ----------- | ----------------------------------------------------------------------------- | -| className | Adds custom class name to marker. All markers have class name `stx-marker`. | -| x | x position of the chart; depends on `xPositioner`. | -| xPositioner | Determines x position. Choose between `epoch` or `none`. Defaults to `epoch`. | -| y | y position of the chart; depends on `yPositioner`. | -| yPositioner | Determines y position. Choose between `value` or `none`. Defaults to `value`. | - -There are more options for `xPositioner` and `yPositioner` in [ChartIQ docs](http://documentation.chartiq.com/CIQ.Marker.html#main). What we document here is the most common use case. - -#### Marker API - -Use `FastMarker` to render given Components under stx-subholder. -It will keep the marker position on the chart. - -```jsx - - - - -``` - -USAGE: - -- `setRef({setPosition, div})` will be called onMount. -- `setRef(null)` will be called when the marker unmounts. -- `div` is the dom element containing the marker with `your-css-class` - - any content update should be done using `div` and vanilla js - - use `div.querySelector('...')` to get a dom reference in order to update your content. - - avoid doning expensive DOM operations on `div` such as style changes. -- `setPosition({epoch, price})` is a function that you will use to update the `div` position. - - epoch is the tick unix epoch from api - - price is the tick price, it could be `null` if you want to draw a vertical line. -- call `setPosition({epoch: null, price: null})` to hide the marker. - -PROPS: - -- `threshold` (optional): the chart has a zoom level, the marker will be only shown within that threshold. -- `markerRef` (required): pass the `setRef` callback using this property -- `className` (optional): avoid expoensive css transition or keyframe animations on this class. - -### Raw Marker API - -Get a raw callback with underlying canvas2dcontext. -This component is used to render directly into the chart canvas. - -PROPS: - -- `epoch_array`: array of epoch values to get coordinates for. -- `draw_callback`: called on every frame with ({ctx, points}). - - `points` will be an array of [{left, top, epoch}] in pixels. - - `ctx` is the Context2dDrawingContext - -### Customising Components - -We offer library users full control on deciding which of the top widgets and chart control buttons to be displayed by overriding the render methods themselves. To do this you pass in a function to `chartControlsWidgets` or `topWidgets`. - -For example, we want to remove all the chart control buttons, and for top widgets to just show the comparison list (refer `app/index.jsx`): - -```jsx -import { ChartMode, ToolbarWidget } from "@deriv/deriv-chart"; - -const renderTopWidgets = () => ( - -
Hi I just replaced the top widgets!
- -
-); - -const renderBottomWidgets = () => ( - -
Hi, I am a bottom widget!
-
-); - -const renderToolbarWidgets = () => ( - -
Hi I just replaced the top widgets!
- -
-); - -const App = () => ( - {}} - > -); -``` - -Here are the following components you can import: - -- Top widgets: - - ` {}} open_market={null} />` -- Chart controls: - - `` - - ` {}} />` - - `` - - `` - - `` - - `` - - ` {}} />` - - `` - - `` -- Toolbar Widget - - `` - -### Props vs UI - -Certain chart parameters can be set either by props or from the chart UI: - -- `symbol` - set by `` -- `granularity` - set by `` -- `chartType` - set by `` - -This creates conflicts in deciding which is the single source of truth. To circumvent this, if these props are set (not `undefined`), selecting options in its corresponding components will not have any affect on the chart; the prop values take precedence. To have control over both the UI and the props, we provide library users the option to _override_ component behaviour via `onChange` prop. For example, to retrieve the symbol a client chooses: - -```jsx - { - /* ...Pass to symbol prop in */ - }} -/> -``` - -See available components and their props in [Customising Components](#customising-components). - -#### ChartTitle - -| Attribute | Description | -| ------------ | --------------------------------------------------------------------------------------------------- | -| onChange | When symbol/market changes, this method call. `(symbol) => { }` | -| isNestedList | Change the theme of Dropdown, if set to `true` it shows a dropdown nested style. Default is `false` | -| open_market | Sepecify the visible market on the market selector scroll. it accept `{category: '', subcategory: '', market: ''}` . Default is `null` | - - -#### ToolbarWidget - -| Attribute | Description | -| --------- | ------------------------------------------------------------------------------- | -| position | determine the position of toolbar, which can be `top, bottom`. Default is `top` | - - -## How to contribute - - -1. Create branch from the latest `master` branch - - ```sh - git checkout master - git pull upstream master - git checkout -b [_your_branch_name] - ``` - -2. Make your changes - -3. Make pull request - -- Push your changes to your origin - - ```sh - git push -u origin [_your_branch_name] - ``` - -**Important Note:** Prior to sending pull requests, make sure all unit tests passed: - - ```sh - npm run test - ``` - -- Once your changes have been merged to `master`, it will immediately deployed to [charts.binary.com/beta](https://charts.binary.com/beta/). - -- Make sure to change the PR base to `master` branch - -- Click on the autogenerated link from terminal to open the PR - - -## Manage releases / deployment process -### Library deployment / publishing to NPM - -To publish to production: - - ```sh - npm run build && npm publish - ``` - -To publish to beta: - - ```sh - npm run build && npm publish --tag beta - ``` -### Staging / Production deployment -#### 1) Staging deployment: - -- Any pull request merged to `master` branch will be automatically deployed to charts.binary.com/beta. - -#### 2) Production deployment: - -- Production deployment is handled with tagging, ideally, we will create the tag with the prefix `production_v{{version_number}}` from `master` branch and push the tag to initiate the production release pipeline. - -NOTE: _Write access is required for this action_ - -Example: - -i) `git tag production_v20180901 -m 'release production'` - -ii) `git push origin production_v20180901` - -### Deploy to Github Pages - -As ChartIQ license is tied to the `binary.com` domain name, we provide developers with a `binary.sx` to test out the library on their Github Pages. - -For each feature/fix you want to add we recommend you deploy an instance of SmartCharts for it (e.g. `brucebinary.binary.sx/featureA`, `brucebinary.binary.sx/featureB`). To deploy SmartCharts to your github pages, you first need to setup your `gh-pages` branch: - -1. Make sure you have a `binary.sx` subdomain pointed to your `github.io` page first (e.g. `brucebinary.binary.sx -> brucebinary.github.io`). -2. In your `gh-pages` branch, add a `CNAME` in your project root folder, and push that file to your branch, for example: - -```bash -git checkout -b gh-pages origin/gh-pages # if you already checkout from remote execute: git checkout gh-pages -echo 'brucebinary.binary.sx' > CNAME # substitute with your domain -git add --all -git commit -m 'add CNAME' -git push origin gh-pages -``` - -Here on, to deploy a folder (e.g. `folder_name`): - - npm run build-travis && npm run gh-pages:folder 'myfoldername' - -Now you should be able to see your SmartCharts app on `brucebinary.binary.sx/myfoldername`. - -Alternatively you can deploy directly to the domain itself (note that this **erases all folders**; could be useful for cleanup). In our example, the following command will deploy to `brucebinary.binary.sx`: - - npm run build-travis && echo 'brucebinary.binary.sx' > CNAME && npm run gh-pages - -> Note: `npm run build-travis` will add hashing inside `index.html`; **do not push those changes to git!** - -There may be occasions where you would want to deploy development versions of the webpack bundles. Quick way to do this is to change the [`--mode` parameter](https://webpack.js.org/concepts/mode/) in `build` npm command in `package.json` to from `production` to `development`. - -## Manage translations - -All strings that need to be translated must be inside `t.translate()`: - -```js -t.translate("[currency] [amount] payout if the last tick.", { - currency: "USD", - amount: 43.12, -}); -t.setLanguage("fr", callback_function); // components need to be rerendered for changes to take affect -``` - -Each time a new translation string is added to the code, you need to update the `messages.pot` via: - - npm run translations - -Once the new `messages.pot` is merged into the `master` branch, it will automatically be updated in [CrowdIn](https://crowdin.com/project/smartcharts/settings#files). You should expect to see a PR with the title - -**New Crowdin translations** -in a few minutes; this PR will update the `*.po` files. - -## Developer Notes - -### Developer Workflow - -We organise the development in Trello. Here is the standard workflow of how a feature/bug fix is added: - -1. When an issue/feature is raised, it is added to `Backlog` list. For each card added, it should have a "QA Checklist" (Add checklist to card) for QA to verify that the feature/bug fix has been successfully implemented. -2. In a meeting, if feature/bug fix is set to be completed for next release, it will be labeled as `Next Release` and placed in `Bugs/Todo` list. -3. Cards are assigned to developers by adding them to the card; manager gets added to every card. -4. If a developer is actively working on a card, he places the card in `In Development`; otherwise it should be placed back into `Bugs/Todo` list. -5. Once the feature/bug fix is implemented, the developer needs put 2 things in the card before placing his card in `Review` list.: - - **PR**: Link to the PR. - - **Test Link**: Link to github pages that has the changes; this is for QA to verify. Refer to [this section](#deploy-to-github-pages) for instructions on how to deploy. -6. If reviewer requests changes, he will place the card back to the `In Development` list. This back and forth continues until the reviewer passes the PR by marking it as `approved` in Github. -7. Reviewer places the reviewed card into `QA` list. -8. If the card fails QA check, QA can comment on the card on what failed, and place the card back to `In Development` list. If QA passes the changes, QA will place the card from `QA` to `Ready`; this card is now ready to be merged to `master`. -9. Once the card is merged to `master`, it is placed in `Deployed to BETA` list. -10. When it is time to take all changes in `beta` and deploy in production, manager will merge `master` into `master`, and place all cards in `Deployed to BETA` to `Released`. - -### Debugging NPM Package - -Some issues only show up for library users, so it is helpful to test the NPM package before deploying it to library users. You can do this by building the library directly into the node_modules directory of an app that uses the SmartCharts library. For example to test the library build on binary-static you can execute: - - npm run watch '../binary-static/node_modules/@deriv/deriv-chart/dist' - -Now each time you make any change, it will overwrite the SmartCharts library inside the `node_modules` folder. - -### Separation of App and Library - -There should be a clear distinction between developing for app and developing for library. Library source code is all inside `src` folder, whereas app source code is inside `app`. - -Webpack determines whether to build an app or library depending on whether an environment variable `BUILD_MODE` is set to `app`. Setting this variable switches the entry point of the project (app build mode uses `app/index.jsx` while library uses `src/index.js`). We do it this way to develop the app to have hot reload available when we modify library files. - -### Dealing With SVGs - -SmartCharts has 2 ways of utilizing SVG files: as CSS background image and as external SVG. - -##### CSS Background Image SVG - -These SVG are added inline into the CSS via [postcss-inline-svg](https://github.com/TrySound/postcss-inline-svg). Currently the only place where this is used is the loader, because if the external SVG is not loaded yet we would at least want a loading screen to be present. - -##### External SVG - -The SVG files included in the `js` and `jsx` files are automatically put together into a sprite sheet. Manipulating external SVG can be tricky - developers can only control stroke and fill color of the whole SVG file via CSS: - -```scss -.ic-icon.active { - svg { - stroke: #2e8836; - fill: #ff3d38; - } -} -``` - -**Important Note:** These stroke and fill colors will not be affected by CSS if the corresponding attributes are declared in the SVG file. Therefore, it is not uncommon SmartCharts developers would need to tweak the SVG files by hand to be able to manipulate its color. - -This has much less freedom compared to [inline SVG](https://github.com/MoOx/react-svg-inline) where a developer can control individual parts of the SVG, but having external SVG results in a much smaller library, and allows parts of the code not rendered by React to use them. External SVG is also cached by the browser (using shadow DOM), so though the same SVG may be used multiple times, only one copy exists in the DOM. - -### State Management and the `connect` Method - -SmartCharts uses a variation of [Mobdux](https://medium.com/@cameronfletcher92/mobdux-combining-the-good-parts-of-mobx-and-redux-61bac90ee448) to assist with state management using Mobx. - -Each component consists of 2 parts: a **template** (`*.jsx` file), and a **store** (`*Store.js` file). There are 3 scenarios in which the [`connect`](https://github.com/binary-com/SmartCharts/blob/dev/src/store/Connect.js) method is used: - -##### 1. Main Components: The component is tied directly to the main store. - -Examples: ``, ``, ``... - -Each component here is mapped to a corresponding store in the main store. **Only one copy of this component may exist per `` instance**, and its state is managed by the main store tree (defined as `mainStore` in SmartCharts). Here you pass a `mapperFunction` that would be applied directly to the main store: - -```jsx -function mapperFunction(mainStore) { - return { - value: mainStore.subStore.value, - }; -} - -export default connect(mapperFunction)(MyComponent); -``` - -Connections in the scenario #1 should be done in the `jsx` file, to keep consistent with other components. Except for the component tied to the main store (`Chart.jsx`), all components using this method should be SFC (Stateless Functional Components), and have the lifecycle managed by the main store. - -##### 2. Subcomponents: Component is connected inside a store - -Examples: ``, ``, ``... - -This is used when multiple copies of a store needs to exist in the same state tree. Here we do the connection inside the constructor of a child of the main store and pass it as a prop to the template. For example `` needs a ``, so in `ChartTitleStore` we create an instance of `MenuStore` and connect it: - -```js -export default class ChartTitleStore { - constructor(mainStore) { - this.menu = new MenuStore(mainStore); - this.ChartTitleMenu = this.menu.connect(Menu); - // ... - } - // ... -} -``` - -The `connect` method for subcomponents are defined in its store (instead of the template file) that contains its own `mapperFunction`: - -```js -export default class MenuStore { - // ... - connect = connect(() => ({ - setOpen: this.setOpen, - open: this.open, - })); -} -``` - -We then pass the connected component in `ChartTitle.jsx`: - -```js -export default connect(({ chartTitle: c }) => ({ - ChartTitleMenu: c.ChartTitleMenu, -}))(ChartTitle); -``` - -> **Note**: Do NOT connect subcomponents in another connect method; `connect` creates a new component each time it is called, and a `mapperFunction` is called every time a mobx reaction or prop update is triggered. - -##### 3. Independent Components: components that are not managed by the main store - -Examples: ``, `` - -Independent components is able to access the main store, but the main store has no control over independent components. As such, each independent component manages its own life cycle. Here is the interface for its store: - -```js -class IndependentStore { - constructor(mainStore) {} - updateProps(nextProps) {} // intercept the props from the component - destructor() {} // called on componentWillUnmount -} -``` - -This enables library users to use multiple copies of a component without connecting it, because mounting an independent component will also create its own store (refer to [`Marker API`](#marker-api) to see usage example of such a component). Therefore, for each independent component you connect you will also need to pass its store class (not an instance but the class itself) as a second parameter to the `connect` function: - -```jsx -function mapperFunction(customStore) { - return { - value: customStore.value, - }; -} - -export default connect( - mapperFunction, - MyStoreClass // Required argument for independent components -)(MyIndependentComponent); -``` - -Note that **for independent components, the `mapperFunction` is applied to the store instance**, not the main store. Should you need to access any value from the main store, you can do this via the `mainStore` passed to the constructor of each independent store class. - - From 0b257779b60fadb020c3825140cee844ba6a7190 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:37:03 +0800 Subject: [PATCH 10/25] test link --- .github/workflows/generate_preview_link.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index e758fe850a..8af327f575 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -37,7 +37,7 @@ jobs: issue_number: ${{steps.pr_information.outputs.issue_number}} head_sha: ${{github.event.pull_request.head.sha}} - name: Checkout SmartCharts - uses: './.github/actions/checkout' + uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: repository: ${{steps.pr_information.outputs.username}}/SmartCharts path: SmartCharts @@ -45,7 +45,7 @@ jobs: alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app - uses: './.github/actions/checkout' + uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: repository: ${{steps.pr_information.outputs.username}}/deriv-app path: deriv-app @@ -53,7 +53,7 @@ jobs: alternate_repository: 'binary-com/deriv-app' alternate_ref: master - name: Custom flutter-chart - uses: './.github/actions/checkout' + uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: repository: ${{steps.pr_information.outputs.username}}/flutter-chart path: flutter-chart From 79fb53f2b04b1d2b6f69d58bca174525fc773c01 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:43:27 +0800 Subject: [PATCH 11/25] test link --- .github/actions/checkout/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/actions/checkout/action.yml b/.github/actions/checkout/action.yml index d4017bbf09..ddccf418bc 100644 --- a/.github/actions/checkout/action.yml +++ b/.github/actions/checkout/action.yml @@ -6,7 +6,6 @@ inputs: required: false type: number path: - default: '' required: false type: string repository: @@ -14,15 +13,12 @@ inputs: required: false type: string ref: - default: '' required: false type: string alternate_repository: - default: '' required: false type: string alternate_ref: - default: '' required: false type: string token: From 3ac4481c94120d5baf34caca23d32981c54d0bef Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:53:01 +0800 Subject: [PATCH 12/25] testing link --- .github/workflows/generate_preview_link.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 8af327f575..57d87f9db2 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -45,7 +45,7 @@ jobs: alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app - uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' + uses: 'ahmadtaimoor-deriv/deriv-app/.github/actions/build@master' with: repository: ${{steps.pr_information.outputs.username}}/deriv-app path: deriv-app From 8d1926a0678878dee826e01b380ba5f1b6285555 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 14:49:30 +0800 Subject: [PATCH 13/25] testing link --- .github/workflows/generate_preview_link.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 57d87f9db2..8af327f575 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -45,7 +45,7 @@ jobs: alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app - uses: 'ahmadtaimoor-deriv/deriv-app/.github/actions/build@master' + uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: repository: ${{steps.pr_information.outputs.username}}/deriv-app path: deriv-app From b9a0c1e937db9729ef76367a8633bc09a891c750 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:04:21 +0800 Subject: [PATCH 14/25] testing link --- .github/workflows/generate_preview_link.yml | 40 +++++++++------------ 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 8af327f575..c31ea6493c 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -1,13 +1,5 @@ name: Generate preview link -permissions: - actions: write - checks: write - contents: write - deployments: write - pull-requests: write - statuses: write - on: pull_request_target: types: [opened, synchronize] @@ -22,44 +14,46 @@ concurrency: jobs: build_and_deploy_preview_link: runs-on: Ubuntu-latest + permissions: + checks: write + pull-requests: write steps: - - name: Retrieve pull request - id: pr_information - run: | - echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT - echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT - echo "branch_name=$(cat .pr/BRANCHNAME)" >> $GITHUB_OUTPUT - + # - name: Verify user + # uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1" + # with: + # username: ${{github.event.pull_request.user.login}} + # token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - name: Post preview build comment id: post_preview_build_comment uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1' with: - issue_number: ${{steps.pr_information.outputs.issue_number}} + issue_number: ${{github.event.number}} head_sha: ${{github.event.pull_request.head.sha}} - name: Checkout SmartCharts uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: - repository: ${{steps.pr_information.outputs.username}}/SmartCharts + repository: ${{github.event.pull_request.user.login}}/SmartCharts path: SmartCharts - ref: ${{steps.pr_information.outputs.branch_name}} + ref: ${{github.event.number}} alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: - repository: ${{steps.pr_information.outputs.username}}/deriv-app + repository: ${{github.event.pull_request.user.login}}/deriv-app path: deriv-app - ref: ${{steps.pr_information.outputs.branch_name}} + ref: ${{github.event.number}} alternate_repository: 'binary-com/deriv-app' alternate_ref: master - name: Custom flutter-chart uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: - repository: ${{steps.pr_information.outputs.username}}/flutter-chart + repository: ${{github.event.pull_request.user.login}}/flutter-chart path: flutter-chart - ref: ${{steps.pr_information.outputs.branch_name}} + ref: ${{github.event.number}} alternate_repository: 'regentmarkets/flutter-chart' alternate_ref: fe-changes + token: ${{ secrets.REPO_READ_TOKEN }} - name: Setup Node uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4 @@ -87,7 +81,7 @@ jobs: flutter pub get flutter build web --web-renderer html --release env: - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.REPO_READ_TOKEN }} - name: Build SmartCharts run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist From d942f70e331a32a4f7c253036858101419476406 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:10:22 +0800 Subject: [PATCH 15/25] testing link --- .github/workflows/generate_preview_link.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index c31ea6493c..c41dcca337 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -34,7 +34,7 @@ jobs: with: repository: ${{github.event.pull_request.user.login}}/SmartCharts path: SmartCharts - ref: ${{github.event.number}} + ref: ${{github.head_ref}} alternate_repository: 'binary-com/SmartCharts' alternate_ref: master - name: Checkout deriv-app @@ -42,7 +42,7 @@ jobs: with: repository: ${{github.event.pull_request.user.login}}/deriv-app path: deriv-app - ref: ${{github.event.number}} + ref: ${{github.head_ref}} alternate_repository: 'binary-com/deriv-app' alternate_ref: master - name: Custom flutter-chart @@ -50,7 +50,7 @@ jobs: with: repository: ${{github.event.pull_request.user.login}}/flutter-chart path: flutter-chart - ref: ${{github.event.number}} + ref: ${{github.head_ref}} alternate_repository: 'regentmarkets/flutter-chart' alternate_ref: fe-changes token: ${{ secrets.REPO_READ_TOKEN }} From 895fed1034679fb4bb951c98fa1e7684ce058fe4 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:23:55 +0800 Subject: [PATCH 16/25] testing link --- .github/workflows/generate_preview_link.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index c41dcca337..2f8a25d1c8 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -48,7 +48,7 @@ jobs: - name: Custom flutter-chart uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: - repository: ${{github.event.pull_request.user.login}}/flutter-chart + repository: ${{github.event.pull_request.user.login}}/flutter-chartz path: flutter-chart ref: ${{github.head_ref}} alternate_repository: 'regentmarkets/flutter-chart' @@ -56,7 +56,7 @@ jobs: token: ${{ secrets.REPO_READ_TOKEN }} - name: Setup Node - uses: actions/setup-node@44c9c187283081e4e88b54b0efad9e9d468165a4 + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 with: node-version: 18.x From 69a8e60d9b50ab814d80ad299bb7f476df3e6e5a Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:42:45 +0800 Subject: [PATCH 17/25] testing link --- .github/workflows/generate_preview_link.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 2f8a25d1c8..b38ca6708c 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -78,6 +78,7 @@ jobs: - name: Build flutter run: | cd SmartCharts/chart_app + git config --global url.https://${{ secrets.ACESS_TOKEN }}@github.com/.insteadOf git@github.com: flutter pub get flutter build web --web-renderer html --release env: From d22668738e39a72562f445cf1223ca56aac96545 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:56:19 +0800 Subject: [PATCH 18/25] testing link --- .github/workflows/generate_preview_link.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index b38ca6708c..a0aed018e5 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -78,7 +78,7 @@ jobs: - name: Build flutter run: | cd SmartCharts/chart_app - git config --global url.https://${{ secrets.ACESS_TOKEN }}@github.com/.insteadOf git@github.com: + git config --global url.https://${{ secrets.REPO_READ_TOKEN }}@github.com/.insteadOf git@github.com: flutter pub get flutter build web --web-renderer html --release env: From 1bf3f5ea76bc779114e20916ae3b941dfcb81285 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:57:20 +0800 Subject: [PATCH 19/25] testing link --- .github/workflows/generate_preview_link.yml | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index a0aed018e5..0b130e50bb 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -60,20 +60,20 @@ jobs: with: node-version: 18.x - - name: Setup deriv-app - run: cd deriv-app && npm install && npm run bootstrap + # - name: Setup deriv-app + # run: cd deriv-app && npm install && npm run bootstrap - - name: Remove @deriv-charts in deriv-app - run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist + # - name: Remove @deriv-charts in deriv-app + # run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist - - name: Setup SmartCharts - run: cd SmartCharts && npm install + # - name: Setup SmartCharts + # run: cd SmartCharts && npm install - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.6' - channel: 'stable' - cache: true + # - uses: subosito/flutter-action@v2 + # with: + # flutter-version: '3.10.6' + # channel: 'stable' + # cache: true - name: Build flutter run: | From f9c8f4b24595e8b57cd88af2b1579bf8d5e05b1c Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:58:52 +0800 Subject: [PATCH 20/25] testing link --- .github/workflows/generate_preview_link.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 0b130e50bb..72ee7f55d4 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -69,11 +69,11 @@ jobs: # - name: Setup SmartCharts # run: cd SmartCharts && npm install - # - uses: subosito/flutter-action@v2 - # with: - # flutter-version: '3.10.6' - # channel: 'stable' - # cache: true + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.10.6' + channel: 'stable' + cache: true - name: Build flutter run: | From ca7c9bf62a5cdff543d7fb1c97c85e2229616407 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:03:07 +0800 Subject: [PATCH 21/25] testing link --- .github/workflows/generate_preview_link.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 72ee7f55d4..405adaf099 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -60,14 +60,14 @@ jobs: with: node-version: 18.x - # - name: Setup deriv-app - # run: cd deriv-app && npm install && npm run bootstrap + - name: Setup deriv-app + run: cd deriv-app && npm install && npm run bootstrap - # - name: Remove @deriv-charts in deriv-app - # run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist + - name: Remove @deriv-charts in deriv-app + run: rm -rf deriv-app/node_modules/@deriv/deriv-charts/dist - # - name: Setup SmartCharts - # run: cd SmartCharts && npm install + - name: Setup SmartCharts + run: cd SmartCharts && npm install - uses: subosito/flutter-action@v2 with: @@ -76,13 +76,12 @@ jobs: cache: true - name: Build flutter + env: + GIT_SSH_COMMAND: 'ssh -i ${{ secrets.SSH_KEY }}' run: | cd SmartCharts/chart_app - git config --global url.https://${{ secrets.REPO_READ_TOKEN }}@github.com/.insteadOf git@github.com: flutter pub get flutter build web --web-renderer html --release - env: - GITHUB_TOKEN: ${{ secrets.REPO_READ_TOKEN }} - name: Build SmartCharts run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist From 4f5e2821b376e13215e3390448b8f970bf08e2b6 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:15:39 +0800 Subject: [PATCH 22/25] testing link --- .github/workflows/generate_preview_link.yml | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 405adaf099..c5c55e880d 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -55,6 +55,20 @@ jobs: alternate_ref: fe-changes token: ${{ secrets.REPO_READ_TOKEN }} + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.10.6' + channel: 'stable' + cache: true + + - name: Build flutter + env: + GIT_SSH_COMMAND: 'ssh -i ${{ secrets.SSH_KEY }}' + run: | + cd SmartCharts/chart_app + flutter pub get + flutter build web --web-renderer html --release + - name: Setup Node uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 with: @@ -69,19 +83,7 @@ jobs: - name: Setup SmartCharts run: cd SmartCharts && npm install - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.10.6' - channel: 'stable' - cache: true - - name: Build flutter - env: - GIT_SSH_COMMAND: 'ssh -i ${{ secrets.SSH_KEY }}' - run: | - cd SmartCharts/chart_app - flutter pub get - flutter build web --web-renderer html --release - name: Build SmartCharts run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist From 27a53bb1d06448004db211f1428fcdde826ad43e Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:33:19 +0800 Subject: [PATCH 23/25] testing link --- .github/workflows/generate_preview_link.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index c5c55e880d..5ba7031031 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -13,6 +13,7 @@ concurrency: jobs: build_and_deploy_preview_link: + if: github.event.pull_request.user.login == 'ahmadtaimoor-deriv' runs-on: Ubuntu-latest permissions: checks: write @@ -61,9 +62,15 @@ jobs: channel: 'stable' cache: true + - name: Add SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/github_action_key + chmod 600 ~/.ssh/github_action_key + - name: Build flutter env: - GIT_SSH_COMMAND: 'ssh -i ${{ secrets.SSH_KEY }}' + GIT_SSH_COMMAND: 'ssh -i ~/.ssh/github_action_key' run: | cd SmartCharts/chart_app flutter pub get From 1bd0399791e0a11e4d10c5c1d82a34f677c6d941 Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:05:24 +0800 Subject: [PATCH 24/25] testing link --- .github/workflows/generate_preview_link.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index 5ba7031031..dda68358a6 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -6,6 +6,7 @@ on: env: HEAD_REF: ${{ github.head_ref }} + NODE_ENV: 'production' concurrency: group: cloudflare-pages-build-"$HEAD_REF" @@ -30,6 +31,7 @@ jobs: with: issue_number: ${{github.event.number}} head_sha: ${{github.event.pull_request.head.sha}} + - name: Checkout SmartCharts uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: @@ -38,6 +40,7 @@ jobs: ref: ${{github.head_ref}} alternate_repository: 'binary-com/SmartCharts' alternate_ref: master + - name: Checkout deriv-app uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: @@ -46,6 +49,7 @@ jobs: ref: ${{github.head_ref}} alternate_repository: 'binary-com/deriv-app' alternate_ref: master + - name: Custom flutter-chart uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master' with: @@ -90,8 +94,6 @@ jobs: - name: Setup SmartCharts run: cd SmartCharts && npm install - - - name: Build SmartCharts run: cd SmartCharts && npm run build -- --output-path ../deriv-app/node_modules/@deriv/deriv-charts/dist From fd63af651a16f01114640f278cde52af9dc9e27e Mon Sep 17 00:00:00 2001 From: ahmadtaimoor-deriv <129935294+ahmadtaimoor-deriv@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:19:00 +0800 Subject: [PATCH 25/25] testing link --- .github/workflows/generate_preview_link.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate_preview_link.yml b/.github/workflows/generate_preview_link.yml index dda68358a6..3c108eaad5 100644 --- a/.github/workflows/generate_preview_link.yml +++ b/.github/workflows/generate_preview_link.yml @@ -6,7 +6,6 @@ on: env: HEAD_REF: ${{ github.head_ref }} - NODE_ENV: 'production' concurrency: group: cloudflare-pages-build-"$HEAD_REF" @@ -101,6 +100,8 @@ jobs: run: cd SmartCharts && npm run test - name: Build deriv-app + env: + NODE_ENV: 'production' run: cd deriv-app && npm run build:all - name: Setup Node