@terrenceaa/smartcharts-champion 0.0.0-stage → 1.9.3-dtx.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.browserslistrc +6 -0
  2. package/.dockerignore +2 -0
  3. package/.github/CODEOWNERS +6 -0
  4. package/.github/actions/build-and-deploy/action.yml +116 -0
  5. package/.github/actions/checkout/action.yml +83 -0
  6. package/.github/dependabot.yml +10 -0
  7. package/.github/workflows/README.md +166 -0
  8. package/.github/workflows/claude.yml +21 -0
  9. package/.github/workflows/deploy-preview.yml +199 -0
  10. package/.github/workflows/deploy-production.yml +40 -0
  11. package/.github/workflows/publish-smart-charts.yml +65 -0
  12. package/.github/workflows/qa-checklist.yml +20 -0
  13. package/.github/workflows/security-nclc-review.yml +207 -0
  14. package/.github/workflows/sync_translations.yml +88 -0
  15. package/.github/workflows/weekly-workflow-collector.yml +252 -0
  16. package/.husky/commit-msg +4 -0
  17. package/.lintstagedrc.yml +2 -0
  18. package/.prettierrc +11 -0
  19. package/.stylelintignore +4 -0
  20. package/.stylelintrc +142 -0
  21. package/CLAUDE.md +240 -0
  22. package/README.md +801 -3
  23. package/app/ChartHistory.tsx +78 -0
  24. package/app/ChartNotifier.ts +28 -0
  25. package/app/DateTimePicker/Calendar.tsx +405 -0
  26. package/app/DateTimePicker/DatePicker.tsx +222 -0
  27. package/app/DateTimePicker/TimePicker.tsx +272 -0
  28. package/app/DateTimePicker/calendar.props.ts +14 -0
  29. package/app/DateTimePicker/date-picker.scss +370 -0
  30. package/app/DateTimePicker/panels/CalendarDays.tsx +116 -0
  31. package/app/DateTimePicker/panels/calendar_decades.tsx +40 -0
  32. package/app/DateTimePicker/panels/calendar_months.tsx +42 -0
  33. package/app/DateTimePicker/panels/calendar_years.tsx +29 -0
  34. package/app/DateTimePicker/panels/index.ts +4 -0
  35. package/app/DateTimePicker/time-picker.scss +157 -0
  36. package/app/Notification.tsx +72 -0
  37. package/app/_ciq-notification.scss +94 -0
  38. package/app/app.scss +84 -0
  39. package/app/assets/bg-not-supported.svg +23 -0
  40. package/app/assets/binary-logo.svg +16 -0
  41. package/app/assets/icon-not-supported.svg +14 -0
  42. package/app/browser-detection.js +217 -0
  43. package/app/chart-history.scss +178 -0
  44. package/app/connection/ConnectionManager.ts +164 -0
  45. package/app/connection/NetworkMonitor.ts +88 -0
  46. package/app/connection/Stream.ts +48 -0
  47. package/app/connection/StreamManager.ts +197 -0
  48. package/app/connection/__tests__/DummyConnectionManager.ts +48 -0
  49. package/app/connection/__tests__/dummyData.ts +620 -0
  50. package/app/connection/getQuotes.ts +99 -0
  51. package/app/connection/index.ts +5 -0
  52. package/app/connection/tickUtils.ts +104 -0
  53. package/app/icons/error.svg +13 -0
  54. package/app/icons/ic-calendar-info.svg +1 -0
  55. package/app/icons/ic-calendar.svg +3 -0
  56. package/app/icons/ic-close-circle.svg +3 -0
  57. package/app/icons/ic-close.svg +10 -0
  58. package/app/icons/ic-dropdown.svg +12 -0
  59. package/app/icons/ic-time.svg +1 -0
  60. package/app/icons/info.svg +16 -0
  61. package/app/icons/success.svg +13 -0
  62. package/app/icons/warning.svg +11 -0
  63. package/app/index.tsx +658 -0
  64. package/app/initialData.ts +28 -0
  65. package/app/test.scss +108 -0
  66. package/commitlint.config.js +134 -0
  67. package/declarations.d.ts +40 -0
  68. package/default.conf +22 -0
  69. package/dist/assets/AssetManifest.bin +6 -0
  70. package/dist/assets/AssetManifest.bin.json +1 -0
  71. package/dist/assets/FontManifest.json +1 -0
  72. package/dist/assets/NOTICES +32218 -0
  73. package/dist/assets/fonts/IBMPlexSans-Bold.ttf +0 -0
  74. package/dist/assets/fonts/IBMPlexSans-Regular.ttf +0 -0
  75. package/dist/assets/fonts/MaterialIcons-Regular.otf +0 -0
  76. package/dist/assets/fonts/QuillChartIcons.otf +0 -0
  77. package/dist/assets/packages/deriv_chart/assets/fonts/quill_icons.ttf +0 -0
  78. package/dist/assets/shaders/ink_sparkle.frag +127 -0
  79. package/dist/assets/shaders/stretch_effect.frag +64 -0
  80. package/dist/chart/.last_build_id +1 -0
  81. package/dist/chart/canvaskit/canvaskit.js +1 -0
  82. package/dist/chart/canvaskit/canvaskit.js.symbols +12234 -0
  83. package/dist/chart/canvaskit/canvaskit.wasm +0 -0
  84. package/dist/chart/canvaskit/chromium/canvaskit.js +1 -0
  85. package/dist/chart/canvaskit/chromium/canvaskit.js.symbols +10516 -0
  86. package/dist/chart/canvaskit/chromium/canvaskit.wasm +0 -0
  87. package/dist/chart/canvaskit/skwasm.js +1 -0
  88. package/dist/chart/canvaskit/skwasm.js.symbols +12992 -0
  89. package/dist/chart/canvaskit/skwasm.wasm +0 -0
  90. package/dist/chart/canvaskit/skwasm_heavy.js +1 -0
  91. package/dist/chart/canvaskit/skwasm_heavy.js.symbols +14629 -0
  92. package/dist/chart/canvaskit/skwasm_heavy.wasm +0 -0
  93. package/dist/chart/canvaskit/webparagraph/canvaskit.js +1 -0
  94. package/dist/chart/canvaskit/webparagraph/canvaskit.js.symbols +8407 -0
  95. package/dist/chart/canvaskit/webparagraph/canvaskit.wasm +0 -0
  96. package/dist/chart/canvaskit/wimp.js +1 -0
  97. package/dist/chart/canvaskit/wimp.js.symbols +11672 -0
  98. package/dist/chart/canvaskit/wimp.wasm +0 -0
  99. package/dist/chart/favicon.png +0 -0
  100. package/dist/chart/flutter.js +1 -0
  101. package/dist/chart/flutter.js.map +7 -0
  102. package/dist/chart/flutter_bootstrap.js +1 -0
  103. package/dist/chart/flutter_service_worker.js +1 -0
  104. package/dist/chart/main.dart.js +1 -0
  105. package/dist/chart/main.dart.mjs +1 -0
  106. package/dist/chart/main.dart.wasm +0 -0
  107. package/dist/chart/manifest.json +12 -0
  108. package/dist/chart/version.json +1 -0
  109. package/dist/empty-state-magnifier-4b0846.smartcharts.webp +0 -0
  110. package/dist/flutter-chart-loader-a6716d.smartcharts.js +1 -0
  111. package/dist/flutter-chart-loader-a6716d.smartcharts.js.map +1 -0
  112. package/dist/html2canvas-41178d.smartcharts.js +1 -0
  113. package/dist/html2canvas-41178d.smartcharts.js.map +1 -0
  114. package/dist/lz-string-3f47d0.smartcharts.js +1 -0
  115. package/dist/lz-string-3f47d0.smartcharts.js.map +1 -0
  116. package/dist/resize-observer-polyfill-c48cca.smartcharts.js +1 -0
  117. package/dist/resize-observer-polyfill-c48cca.smartcharts.js.map +1 -0
  118. package/dist/smartcharts.css +4 -0
  119. package/dist/smartcharts.css.map +1 -0
  120. package/dist/smartcharts.js +1 -0
  121. package/dist/smartcharts.js.map +1 -0
  122. package/dist/sprite-de173e.smartcharts.svg +4 -0
  123. package/loaders/exclude-block-loader.js +16 -0
  124. package/login-0.8.0.tgz +0 -0
  125. package/manifest.json +26 -0
  126. package/nojs-smartcharts.css +3 -0
  127. package/package.json +258 -5
  128. package/release.config.cjs +80 -0
  129. package/release.utils.cjs +217 -0
  130. package/sw.js +35 -0
  131. package/tsconfig.json +36 -0
  132. package/vercel.json +3 -0
@@ -0,0 +1,6 @@
1
+ defaults
2
+ not op_mini all
3
+ not OperaMobile < 46
4
+ not ie <= 11
5
+ not IE_Mob <= 11
6
+ not Samsung <= 4
package/.dockerignore ADDED
@@ -0,0 +1,2 @@
1
+ .git
2
+ Dockerfile
@@ -0,0 +1,6 @@
1
+ # Configuration of code ownership and review approvals for the binary-com/deriv-app repo.
2
+ #
3
+ # More info: https://help.github.com/articles/about-codeowners/
4
+ #
5
+
6
+ * @binary-com/write-admin-smartcharts
@@ -0,0 +1,116 @@
1
+ # Reusable action for building and deploying to Cloudflare Pages
2
+ # Handles both Flutter chart component and main application builds
3
+ name: "Build and Deploy to Cloudflare Pages"
4
+ description: "Reusable action to build and deploy the application to Cloudflare Pages"
5
+
6
+ inputs:
7
+ cloudflare_api_token:
8
+ description: "Cloudflare API Token"
9
+ required: true
10
+ cloudflare_account_id:
11
+ description: "Cloudflare Account ID"
12
+ required: true
13
+ project_name:
14
+ description: "Cloudflare Pages project name"
15
+ required: true
16
+ branch_name:
17
+ description: "Branch name for deployment"
18
+ required: true
19
+ node_version:
20
+ description: "Node.js version"
21
+ required: false
22
+ default: "24.x"
23
+ flutter_version:
24
+ description: "Flutter version"
25
+ required: false
26
+ default: "3.24.1"
27
+ environment:
28
+ description: "Deployment environment (production/preview)"
29
+ required: false
30
+ default: "preview"
31
+ commit_hash:
32
+ description: "Commit hash for deployment"
33
+ required: true
34
+
35
+
36
+ runs:
37
+ using: "composite"
38
+ steps:
39
+ - name: Setup Node.js
40
+ uses: actions/setup-node@v4
41
+ with:
42
+ node-version: ${{ inputs.node_version }}
43
+ cache: "npm"
44
+
45
+ - name: Setup Flutter
46
+ uses: subosito/flutter-action@v2
47
+ with:
48
+ flutter-version: ${{ inputs.flutter_version }}
49
+ channel: stable
50
+
51
+ - name: Install dependencies
52
+ shell: bash
53
+ run: npm ci
54
+
55
+ - name: Build Flutter chart component
56
+ shell: bash
57
+ run: |
58
+ cd chart_app
59
+ flutter pub get
60
+ flutter build web --wasm --release
61
+ cd ..
62
+
63
+ - name: Build application
64
+ shell: bash
65
+ run: npm run build:app
66
+
67
+ - name: Validate build output
68
+ shell: bash
69
+ run: |
70
+ if [ ! -d "dist" ]; then
71
+ echo "Error: dist directory not found. Build may have failed."
72
+ exit 1
73
+ fi
74
+ if [ ! -f "index.html" ]; then
75
+ echo "Error: index.html not found."
76
+ exit 1
77
+ fi
78
+ echo "Build validation passed"
79
+
80
+ - name: Prepare deployment files
81
+ shell: bash
82
+ run: |
83
+ mkdir -p deploy
84
+ cp index.html manifest.json sw.js nojs-smartcharts.css deploy/
85
+ cp -r dist deploy/ # This is intentional, because of the way the paths are structured
86
+ cp -r dist/* deploy/
87
+ if [ -d "sass/favicons" ]; then
88
+ mkdir -p deploy/sass
89
+ cp -r sass/favicons deploy/sass/
90
+ fi
91
+ echo "Deployment files prepared successfully"
92
+
93
+ - name: Install Wrangler
94
+ shell: bash
95
+ run: npm install -g wrangler@latest
96
+
97
+ - name: Deploy to Cloudflare Pages
98
+ id: deploy
99
+ shell: bash
100
+ env:
101
+ CLOUDFLARE_API_TOKEN: ${{ inputs.cloudflare_api_token }}
102
+ CLOUDFLARE_ACCOUNT_ID: ${{ inputs.cloudflare_account_id }}
103
+ PROJECT_NAME: ${{ inputs.project_name }}
104
+ BRANCH_NAME: ${{ inputs.branch_name }}
105
+ COMMIT_HASH: ${{ inputs.commit_hash }}
106
+ run: |
107
+ set -e
108
+ echo "Starting deployment to Cloudflare Pages..."
109
+
110
+ # Run the deployment
111
+ wrangler pages deploy deploy \
112
+ --project-name="$PROJECT_NAME" \
113
+ --branch "$BRANCH_NAME" \
114
+ --commit-hash="$COMMIT_HASH"
115
+
116
+ echo "Deployment completed successfully"
@@ -0,0 +1,83 @@
1
+ name: Checkout
2
+
3
+ inputs:
4
+ fetch-depth:
5
+ default: 1
6
+ required: false
7
+ type: number
8
+ path:
9
+ required: false
10
+ type: string
11
+ repository:
12
+ default: ${{ github.repository }}
13
+ required: false
14
+ type: string
15
+ ref:
16
+ required: false
17
+ type: string
18
+ alternate_repository:
19
+ required: false
20
+ type: string
21
+ alternate_ref:
22
+ required: false
23
+ type: string
24
+ token:
25
+ default: ${{ github.token }}
26
+ required: false
27
+ type: string
28
+
29
+ outputs:
30
+ ref_exists:
31
+ description: 'Specifies whether the ref exists or not'
32
+ value: ${{ steps.repo.outputs.ref-exists }}
33
+
34
+ runs:
35
+ using: composite
36
+
37
+ steps:
38
+ - id: repo
39
+ shell: bash
40
+ env:
41
+ GH_TOKEN: ${{ inputs.token }}
42
+ ALTERNATE_REF: ${{ inputs.alternate_ref }}
43
+ REPOSITORY: ${{ inputs.repository }}
44
+ REF: ${{ inputs.ref }}
45
+ run: |
46
+ if git ls-remote --heads --quiet --exit-code https://$GH_TOKEN@github.com/$REPOSITORY.git $REF
47
+ then
48
+ echo "::notice::Checkout: $REPOSITORY using $REF"
49
+ echo "ref-exists=true" >> $GITHUB_OUTPUT
50
+ else
51
+ echo "::notice::Checkout: $REPOSITORY does not have ref $REF (fallback to $ALTERNATE_REF)"
52
+ echo "ref-exists=false" >> $GITHUB_OUTPUT
53
+ fi
54
+
55
+ - if: steps.repo.outputs.ref-exists == 'true'
56
+ uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
57
+ env:
58
+ REPO_PATH: ${{ inputs.path }}
59
+ GH_TOKEN: ${{ inputs.token }}
60
+ REPOSITORY: ${{ inputs.repository }}
61
+ FETCH_DEPTH: ${{ inputs.fetch-depth }}
62
+ REF: ${{ inputs.ref }}
63
+ with:
64
+ fetch-depth: ${{ env.FETCH_DEPTH }}
65
+ path: ${{ env.REPO_PATH }}
66
+ repository: ${{ env.REPOSITORY }}
67
+ ref: ${{ env.REF }}
68
+ token: ${{ env.GH_TOKEN }}
69
+
70
+ - if: steps.repo.outputs.ref-exists == 'false'
71
+ uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
72
+ env:
73
+ REPO_PATH: ${{ inputs.path }}
74
+ GH_TOKEN: ${{ inputs.token }}
75
+ ALTERNATE_REF: ${{ inputs.alternate_ref }}
76
+ ALTERNATE_REPOSITORY: ${{ inputs.alternate_repository }}
77
+ FETCH_DEPTH: ${{ inputs.fetch-depth }}
78
+ with:
79
+ fetch-depth: ${{ env.FETCH_DEPTH }}
80
+ path: ${{ env.REPO_PATH }}
81
+ repository: ${{ env.ALTERNATE_REPOSITORY }}
82
+ ref: ${{ env.ALTERNATE_REF }}
83
+ token: ${{ env.GH_TOKEN }}
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: '/'
5
+ schedule:
6
+ interval: daily
7
+ - package-ecosystem: 'github-actions'
8
+ directory: '/'
9
+ schedule:
10
+ interval: 'daily'
@@ -0,0 +1,166 @@
1
+ # Deployment Workflows Documentation
2
+
3
+ This directory contains GitHub Actions workflows for deploying the SmartCharts application to Cloudflare Pages.
4
+
5
+ ## Overview
6
+
7
+ The deployment system consists of two main workflows and one reusable action:
8
+
9
+ - **`deploy-production.yml`** - Deploys to production on master branch pushes
10
+ - **`deploy-preview.yml`** - Creates preview deployments for pull requests
11
+ - **`../actions/build-and-deploy/action.yml`** - Reusable action for building and deploying
12
+
13
+ ## Workflows
14
+
15
+ ### Production Deployment (`deploy-production.yml`)
16
+
17
+ **Triggers:**
18
+ - Push to `master` branch (automatic)
19
+ - Manual trigger via GitHub UI (`workflow_dispatch`)
20
+
21
+ **Features:**
22
+ - Deploys to production Cloudflare Pages environment
23
+ - Uses concurrency control to prevent overlapping deployments
24
+ - Queues deployments when multiple are triggered simultaneously
25
+ - Uses repository secrets for credential management
26
+
27
+ **Environment Variables:**
28
+ - `FLUTTER_VERSION`: Flutter SDK version (default: 3.24.1)
29
+ - `FLUTTER_WEB_RENDERER`: Flutter web renderer (default: html)
30
+ - `NODE_VERSION`: Node.js version (default: 24.x)
31
+
32
+ **Required Secrets:**
33
+ - `CLOUDFLARE_API_TOKEN`: Cloudflare API token with Pages permissions
34
+ - `CLOUDFLARE_ACCOUNT_ID`: Cloudflare account identifier
35
+
36
+ ### Preview Deployment (`deploy-preview.yml`)
37
+
38
+ **Triggers:**
39
+ - Pull request events: `opened`, `synchronize`, `reopened`
40
+ - Triggers on PRs targeting any branch (`"**"`)
41
+
42
+ **Features:**
43
+ - Creates preview deployments for each PR
44
+ - Automatically cancels outdated deployments when new commits are pushed
45
+ - Generates safe branch slugs for Cloudflare Pages compatibility
46
+ - Handles complex branch names with special characters
47
+
48
+ **Branch Slug Generation:**
49
+ - Converts to lowercase
50
+ - Replaces `/` with `-`
51
+ - Removes special characters (keeps only alphanumeric, `_`, `-`)
52
+ - Limits to 63 characters (Cloudflare requirement)
53
+ - Falls back to `pr-{number}` if branch name is empty
54
+
55
+ **Required Secrets:**
56
+ - Same as production deployment
57
+
58
+ ## Reusable Action (`../actions/build-and-deploy/action.yml`)
59
+
60
+ ### Purpose
61
+ Handles the complete build and deployment process for both production and preview environments.
62
+
63
+ ### Inputs
64
+
65
+ | Input | Required | Default | Description |
66
+ |-------|----------|---------|-------------|
67
+ | `cloudflare_api_token` | ✅ | - | Cloudflare API Token |
68
+ | `cloudflare_account_id` | ✅ | - | Cloudflare Account ID |
69
+ | `project_name` | ✅ | - | Cloudflare Pages project name |
70
+ | `branch_name` | ✅ | - | Branch name for deployment |
71
+ | `node_version` | ❌ | 24.x | Node.js version |
72
+ | `flutter_version` | ❌ | 3.24.1 | Flutter version |
73
+ | `flutter_web_renderer` | ❌ | html | Flutter web renderer |
74
+ | `environment` | ❌ | preview | Deployment environment |
75
+
76
+ ### Outputs
77
+
78
+ | Output | Description |
79
+ |--------|-------------|
80
+ | `deployment_url` | The URL of the deployed application |
81
+
82
+ ### Process Steps
83
+
84
+ 1. **Repository Checkout** - Fetches the complete repository
85
+ 2. **Environment Setup** - Configures Node.js and Flutter
86
+ 3. **Dependency Installation** - Installs npm packages
87
+ 4. **Flutter Build** - Builds the Flutter chart component
88
+ 5. **Application Build** - Builds the main application
89
+ 6. **Build Validation** - Verifies build artifacts exist
90
+ 7. **File Preparation** - Organizes files for deployment
91
+ 8. **Wrangler Installation** - Installs latest Cloudflare Wrangler CLI
92
+ 9. **Deployment** - Deploys to Cloudflare Pages with URL extraction
93
+
94
+ ## Security Considerations
95
+
96
+ ### Repository Secrets
97
+ Both workflows use repository-level secrets, allowing:
98
+ - Shared credentials between production and preview environments
99
+ - Centralized secret management
100
+ - No environment-specific secret duplication
101
+
102
+ ### Permissions
103
+ Workflows use minimal required permissions:
104
+ - `contents: read` - Read repository content
105
+ - `deployments: write` - Create deployment records
106
+ - `pull-requests: write` - Update PR status (preview only)
107
+ - `statuses: write` - Update commit status (preview only)
108
+ - `actions: read` - Read workflow information
109
+
110
+ ## Concurrency Control
111
+
112
+ ### Production
113
+ - **Group:** `deploy-production`
114
+ - **Cancel in Progress:** `false` (queues deployments)
115
+ - **Behavior:** Ensures deployments run sequentially
116
+
117
+ ### Preview
118
+ - **Group:** `deploy-preview-{pr-number}`
119
+ - **Cancel in Progress:** `true` (cancels outdated deployments)
120
+ - **Behavior:** Only latest commit deployment runs per PR
121
+
122
+ ## Troubleshooting
123
+
124
+ ### Common Issues
125
+
126
+ 1. **Build Failures**
127
+ - Check Node.js and Flutter versions match project requirements
128
+ - Verify all dependencies are properly declared in package.json
129
+ - Review build logs for specific error messages
130
+
131
+ 2. **Deployment Failures**
132
+ - Verify Cloudflare credentials are valid and have proper permissions
133
+ - Check project name matches Cloudflare Pages project
134
+ - Ensure account ID is correct
135
+
136
+ 3. **Branch Slug Issues**
137
+ - Branch names with special characters are automatically sanitized
138
+ - Very long branch names are truncated to 63 characters
139
+ - Empty or invalid branch names fall back to `pr-{number}`
140
+
141
+ ### Debugging
142
+
143
+ Enable debug logging by adding this to workflow environment:
144
+ ```yaml
145
+ env:
146
+ ACTIONS_STEP_DEBUG: true
147
+ ```
148
+
149
+ ## Maintenance
150
+
151
+ ### Updating Dependencies
152
+ - **Wrangler**: Automatically uses latest version
153
+ - **Actions**: Update version tags in workflow files
154
+ - **Flutter/Node**: Update version numbers in environment variables
155
+
156
+ ### Monitoring
157
+ - Check GitHub Actions tab for workflow status
158
+ - Monitor Cloudflare Pages dashboard for deployment health
159
+ - Review deployment URLs in workflow outputs
160
+
161
+ ## Best Practices
162
+
163
+ 1. **Testing**: Always test changes in preview deployments before merging
164
+ 2. **Secrets**: Rotate Cloudflare credentials periodically
165
+ 3. **Monitoring**: Set up alerts for deployment failures
166
+ 4. **Documentation**: Keep this documentation updated with changes
@@ -0,0 +1,21 @@
1
+ name: Claude PR Review
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, synchronize, reopened, ready_for_review]
6
+
7
+ jobs:
8
+ claude-review:
9
+ uses: deriv-com/shared-actions/.github/workflows/ai-pr-review.yml@master
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+ issues: write
14
+ id-token: write
15
+ actions: write
16
+ with:
17
+ engine: anthropic # must be explicit; the default is kimi
18
+ secrets:
19
+ LLM_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
20
+ AGENT_METRICS_API_URL: ${{ secrets.AGENT_METRICS_API_URL }}
21
+ AGENT_METRICS_API_KEY: ${{ secrets.AGENT_METRICS_API_KEY }}
@@ -0,0 +1,199 @@
1
+ # Preview deployment workflow
2
+ # Builds SmartCharts and integrates with derivatives-trader for preview
3
+
4
+ name: Deploy Preview
5
+
6
+ on:
7
+ pull_request:
8
+ branches:
9
+ - '**'
10
+ types: [opened, synchronize, reopened]
11
+ workflow_dispatch:
12
+ inputs:
13
+ smartcharts_ref:
14
+ description: 'deriv-smartcharts branch/tag/SHA to build'
15
+ required: true
16
+ default: 'master'
17
+ flutter_chart_ref:
18
+ description: 'flutter-chart branch/tag/SHA to use in chart_app'
19
+ required: true
20
+ default: 'master'
21
+ derivatives_trader_ref:
22
+ description: 'derivatives-trader branch/tag/SHA to build the preview from'
23
+ required: true
24
+ default: 'master'
25
+
26
+ # Cancel outdated deployments per PR, or per ref combination for manual triggers —
27
+ # all three refs, so two manual runs that differ only in one of them don't cancel
28
+ # each other.
29
+ concurrency:
30
+ group: >-
31
+ deploy-preview-${{ github.event.number ||
32
+ format('{0}-{1}-{2}', github.event.inputs.smartcharts_ref, github.event.inputs.flutter_chart_ref,
33
+ github.event.inputs.derivatives_trader_ref) }}
34
+ cancel-in-progress: true
35
+
36
+ jobs:
37
+ build_and_deploy_preview_link:
38
+ runs-on: ubuntu-latest
39
+ permissions:
40
+ contents: read
41
+ checks: write
42
+ pull-requests: write
43
+ steps:
44
+ - name: Mint GitHub App token
45
+ id: app-token
46
+ uses: actions/create-github-app-token@v1
47
+ with:
48
+ app-id: ${{ secrets.CLIENT_ID_GHAPP }}
49
+ private-key: ${{ secrets.PRIVATE_KEY_GHAPP }}
50
+ owner: deriv-com
51
+ repositories: derivatives-trader
52
+
53
+ - name: Verify user
54
+ if: github.event_name == 'pull_request'
55
+ uses: 'deriv-com/shared-actions/.github/actions/verify_user_in_organization@v3'
56
+ with:
57
+ username: ${{ github.event.pull_request.user.login }}
58
+ token: ${{ steps.app-token.outputs.token }}
59
+
60
+ - name: Post preview build comment
61
+ if: github.event_name == 'pull_request'
62
+ id: post_preview_build_comment
63
+ uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1'
64
+ with:
65
+ issue_number: ${{ github.event.number }}
66
+ head_sha: ${{ github.event.pull_request.head.sha }}
67
+
68
+ - name: Checkout repository
69
+ uses: actions/checkout@v4
70
+ with:
71
+ repository: deriv-com/deriv-smartcharts
72
+ path: deriv-smartcharts
73
+ ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.smartcharts_ref || github.event.pull_request.head.sha }}
74
+ persist-credentials: false
75
+
76
+ - name: Checkout derivatives-trader
77
+ uses: actions/checkout@v4
78
+ with:
79
+ repository: deriv-com/derivatives-trader
80
+ path: derivatives-trader
81
+ ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.derivatives_trader_ref || 'master' }}
82
+ token: ${{ steps.app-token.outputs.token }}
83
+ persist-credentials: false
84
+
85
+ - name: Setup Flutter
86
+ uses: subosito/flutter-action@62f096cacda5168a3bd7b95793373be14fa4fbaf
87
+ with:
88
+ flutter-version: '3.24.1'
89
+ channel: 'stable'
90
+ cache: true
91
+
92
+ - name: Update flutter-chart ref in pubspec.yaml
93
+ if: github.event_name == 'workflow_dispatch'
94
+ env:
95
+ FLUTTER_REF: ${{ github.event.inputs.flutter_chart_ref }}
96
+ run: |
97
+ cd deriv-smartcharts/chart_app
98
+ # Validate input format (alphanumeric, slashes, hyphens, underscores, dots only).
99
+ if ! [[ "${FLUTTER_REF}" =~ ^[a-zA-Z0-9/_.-]+$ ]]; then
100
+ echo "Error: Invalid flutter_chart_ref format. Only alphanumeric characters, slashes, hyphens, underscores, and dots are allowed."
101
+ exit 1
102
+ fi
103
+ # Rewrite only the 'ref:' belonging to the flutter-chart dependency. A blind
104
+ # 's/ref:/' would also clobber deriv_lint's, and anchoring on 'ref: master'
105
+ # would fail on any branch that already points chart_app somewhere else.
106
+ python3 - "${FLUTTER_REF}" <<'PY'
107
+ import re, sys
108
+
109
+ ref = sys.argv[1]
110
+ path = 'pubspec.yaml'
111
+ url = 'url: https://github.com/deriv-com/flutter-chart.git'
112
+
113
+ lines = open(path).read().splitlines(keepends=True)
114
+ for i, line in enumerate(lines):
115
+ if url in line:
116
+ break
117
+ else:
118
+ sys.exit(f'Error: flutter-chart git dependency not found in {path}')
119
+
120
+ for j in range(i + 1, min(i + 4, len(lines))):
121
+ indent = re.match(r'(\s*)ref:', lines[j])
122
+ if indent:
123
+ lines[j] = f'{indent.group(1)}ref: {ref}\n'
124
+ break
125
+ else:
126
+ sys.exit('Error: no ref: found under the flutter-chart dependency')
127
+
128
+ open(path, 'w').write(''.join(lines))
129
+ print(f'Updated {path} to use flutter-chart ref: {ref}')
130
+ PY
131
+ cat pubspec.yaml
132
+ if ! grep -A3 -F 'url: https://github.com/deriv-com/flutter-chart.git' pubspec.yaml | grep -qF "ref: ${FLUTTER_REF}"; then
133
+ echo "Error: Failed to update flutter-chart ref"
134
+ exit 1
135
+ fi
136
+
137
+ - name: Build Flutter chart component
138
+ run: |
139
+ cd deriv-smartcharts/chart_app
140
+ flutter pub get
141
+ flutter build web --wasm --release
142
+
143
+ - name: Setup Node
144
+ uses: actions/setup-node@v4
145
+ with:
146
+ node-version: 24.x
147
+
148
+ - name: Setup derivatives-trader
149
+ run: cd derivatives-trader && npm run bootstrap
150
+
151
+ - name: Remove existing @deriv-com/smartcharts-champion in derivatives-trader
152
+ run: rm -rf derivatives-trader/node_modules/@deriv-com/smartcharts-champion/dist
153
+
154
+ - name: Setup SmartCharts
155
+ run: cd deriv-smartcharts && npm install
156
+
157
+ - name: Build SmartCharts
158
+ run: cd deriv-smartcharts && npm run build -- --output-path ../derivatives-trader/node_modules/@deriv-com/smartcharts-champion/dist
159
+
160
+ - name: Build derivatives-trader
161
+ env:
162
+ NODE_ENV: 'test'
163
+ run: cd derivatives-trader && npm run build:all
164
+
165
+ - name: Setup Node for Cloudflare
166
+ uses: actions/setup-node@v4
167
+ with:
168
+ node-version: 24.x
169
+
170
+ - name: Publish to CF pages branch
171
+ id: publish_to_pages_branch
172
+ uses: 'deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1'
173
+ with:
174
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }}
175
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }}
176
+ project_name: 'derivatives-trader'
177
+ branch_name: ${{ github.head_ref || format('{0}-{1}-{2}', github.event.inputs.smartcharts_ref, github.event.inputs.flutter_chart_ref, github.event.inputs.derivatives_trader_ref) }}
178
+ output_dir: derivatives-trader/packages/app/dist
179
+
180
+ - name: Generate preview link comment
181
+ if: always() && github.event_name == 'pull_request' && steps.post_preview_build_comment.outcome == 'success'
182
+ uses: 'deriv-com/shared-actions/.github/actions/post_preview_link_comment@v1'
183
+ with:
184
+ issue_number: ${{ github.event.number }}
185
+ check_run_id: ${{ steps.post_preview_build_comment.outputs.check_run_id }}
186
+ preview_url: ${{ steps.publish_to_pages_branch.outputs.cf_pages_url }}
187
+ status: ${{ job.status }}
188
+
189
+ - name: Output preview URL for manual trigger
190
+ if: github.event_name == 'workflow_dispatch'
191
+ run: |
192
+ echo "## Preview Deployment Complete" >> $GITHUB_STEP_SUMMARY
193
+ echo "" >> $GITHUB_STEP_SUMMARY
194
+ echo "**Preview URL:** ${{ steps.publish_to_pages_branch.outputs.cf_pages_url }}" >> $GITHUB_STEP_SUMMARY
195
+ echo "" >> $GITHUB_STEP_SUMMARY
196
+ echo "**Configuration:**" >> $GITHUB_STEP_SUMMARY
197
+ echo "- deriv-smartcharts ref: \`${{ github.event.inputs.smartcharts_ref }}\`" >> $GITHUB_STEP_SUMMARY
198
+ echo "- flutter-chart ref: \`${{ github.event.inputs.flutter_chart_ref }}\`" >> $GITHUB_STEP_SUMMARY
199
+ echo "- derivatives-trader ref: \`${{ github.event.inputs.derivatives_trader_ref }}\`" >> $GITHUB_STEP_SUMMARY
@@ -0,0 +1,40 @@
1
+ # Production deployment workflow
2
+ # Requires CLOUDFLARE_TEST_LINKS_API_TOKEN and CLOUDFLARE_TEST_LINKS_ACCOUNT_ID repository secrets
3
+
4
+ name: Deploy to Production
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - master
10
+ workflow_dispatch:
11
+
12
+ # Queue deployments to prevent conflicts
13
+ concurrency:
14
+ group: deploy-production
15
+ cancel-in-progress: false
16
+
17
+ env:
18
+ FLUTTER_VERSION: '3.24.1'
19
+ NODE_VERSION: '24.x'
20
+ permissions:
21
+ contents: read
22
+ jobs:
23
+ deploy-production:
24
+ runs-on: ubuntu-latest
25
+
26
+ steps:
27
+ - name: Checkout repository
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Deploy to Cloudflare Pages
31
+ uses: "./.github/actions/build-and-deploy"
32
+ with:
33
+ cloudflare_api_token: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }}
34
+ cloudflare_account_id: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }}
35
+ project_name: 'smartcharts-champion'
36
+ branch_name: 'master'
37
+ node_version: ${{ env.NODE_VERSION }}
38
+ flutter_version: ${{ env.FLUTTER_VERSION }}
39
+ environment: 'production'
40
+ commit_hash: ${{ github.sha }}