Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
Browse files Browse the repository at this point in the history
…49/wallets-initial-translations-setup
  • Loading branch information
lubega-deriv committed Jul 30, 2024
2 parents 138e175 + 1486143 commit a84b3a7
Show file tree
Hide file tree
Showing 131 changed files with 2,601 additions and 1,056 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build Docker image and push to dockerhub
on:
workflow_dispatch:
inputs:
docker_image_tag_name:
type: string
description: Docker image tag name
required: true
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
env:
tag_name: ${{ github.event.inputs.docker_image_tag_name }}
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}
password: ${{ secrets.WEB_ACCESS_DOCKERHUB_PASSWORD }}

- name: Run Bootstrap
run: npm run bootstrap

- name: Run Build:prod
run: npm run build:prod

- name: Run Build Docker
run: docker build -t ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }} . --platform=linux/amd64

- name: Run Tag Docker
run: docker tag ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }} ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }}

- name: Run Push Docker
run: docker push ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }}
21 changes: 19 additions & 2 deletions .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Versioning
uses: "./.github/actions/versioning"
with:
RELEASE_TYPE: $RELEASE_TYPE
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
- name: Extract version
id: extract_version
run: echo "RELEASE_VERSION=${version}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: "${{ env.RELEASE_TYPE }} Release succeeded for app.deriv.com with version ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION }}"

build_and_publish_to_docker_k8s:
build_and_publish_to_DR_solution:
name: Build Docker image and push to Docker hub and K8S
runs-on: Runner_8cores_Deriv-app
environment: Production
Expand Down Expand Up @@ -121,3 +121,20 @@ jobs:
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: "${{ env.RELEASE_TYPE }} Docker Publish and Kubernetes Deployment for app.deriv.com with version ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION }} has Failed"
- name: Upload to vercel
id: vercel-upload
uses: 'deriv-com/shared-actions/.github/actions/vercel_DR_publish@master'
with:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
ENVIRONMENT: Production
VERCEL_SCOPE: deriv
ALIAS_DOMAIN_URL: 'app-dr.binary.sx'

- name: Send DR Slack Notification
uses: "deriv-com/shared-actions/.github/actions/send_slack_notification@master"
if: ${{ steps.vercel-upload.outcome != 'success' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: Disaster Recovery Release to vercel failed for app.deriv.com with version ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION }}
19 changes: 9 additions & 10 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

- name: Build Docker image and push to Docker hub and K8S
uses: "./.github/actions/build_and_push_docker_image"
- name: Upload to vercel
id: vercel-upload
uses: 'deriv-com/shared-actions/.github/actions/vercel_DR_publish@master'
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
KUBE_SERVER: ${{ secrets.KUBE_SERVER }}
SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }}
CA_CRT: ${{ secrets.CA_CRT }}
APP_VERSION: latest-staging
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
ENVIRONMENT: Production
VERCEL_SCOPE: deriv
ALIAS_DOMAIN_URL: 'staging-app-dr.binary.sx'
20 changes: 15 additions & 5 deletions __mocks__/translation.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ const Localize = ({ i18n_default_text, components = [], values = {} }) => {
// Split text into parts, extracting placeholders for components and values
const parts = i18n_default_text.split(/(<\d+>.*?<\/\d+>|{{\w+}})/g);

const replaceValues = text => {
return text.replace(/{{(\w+)}}/g, (match, key) => values[key] || match);
};

return (
<>
{parts.map((part, index) => {
// Replace component placeholders with actual components
const componentMatch = part.match(/<(\d+)>(.*?)<\/\1>/);

if (componentMatch) {
const componentIndex = parseInt(componentMatch[1]);
const content = componentMatch[2];

// Replace values wrapped in components with actual values
const content = replaceValues(componentMatch[2]);
const Component = components[componentIndex];
return Component ? React.cloneElement(Component, { key: index, children: content }) : content;
}

// Replace value placeholders with actual values
const valueMatch = part.match(/{{(\w+)}}/);
if (valueMatch) {
Expand All @@ -27,15 +35,17 @@ const Localize = ({ i18n_default_text, components = [], values = {} }) => {
);
};

const mockFn = jest.fn((text, args) => {
return text.replace(/{{(.*?)}}/g, (_, match) => args[match.trim()]);
});

// Mock for useTranslations hook
const useTranslations = () => ({
localize: jest.fn((text, args) => {
return text.replace(/{{(.*?)}}/g, (_, match) => args[match.trim()]);
}),
localize: mockFn,
currentLang: 'EN',
});

const localize = jest.fn(text => text);
const localize = mockFn;

const getAllowedLanguages = jest.fn(() => ({ EN: 'English', VI: 'Tiếng Việt' }));

Expand Down
Loading

0 comments on commit a84b3a7

Please sign in to comment.