Skip to content

Commit

Permalink
add the poc
Browse files Browse the repository at this point in the history
  • Loading branch information
timur27 committed Feb 27, 2025
1 parent 03f6b03 commit a78de27
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/feature-pairs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pairs": [
{
"name": "Express Checkout Implementation",
"paths": [
"client/express-checkout",
"client/tokenized-express-checkout"
],
"description": "These are parallel implementations of Express Checkout. The tokenized version will eventually replace the original version, so changes should typically be applied to both."
}
]
}
105 changes: 105 additions & 0 deletions .github/workflows/feature-pair-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Feature Pair Check

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-feature-pairs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies
run: npm install @actions/core @actions/github

- name: Check feature pairs
id: check-pairs
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
// Load feature pairs configuration
const pairsConfig = JSON.parse(fs.readFileSync('.github/feature-pairs.json', 'utf8'));
// Get the list of files changed in this PR
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const changedFiles = files.map(file => file.filename);
// Check each pair of features
let commentBody = '';
for (const pair of pairsConfig.pairs) {
const pathsWithChanges = [];
const pathsWithoutChanges = [];
// Check which paths in the pair have changes
for (const featurePath of pair.paths) {
const hasChanges = changedFiles.some(file => file.startsWith(featurePath));
if (hasChanges) {
pathsWithChanges.push(featurePath);
} else {
pathsWithoutChanges.push(featurePath);
}
}
// If some paths have changes but others don't, add to the comment
if (pathsWithChanges.length > 0 && pathsWithoutChanges.length > 0) {
commentBody += `## ${pair.name}\n\n`;
commentBody += `${pair.description}\n\n`;
commentBody += `- ✅ Changes detected in: \`${pathsWithChanges.join('`, `')}\`\n`;
commentBody += `- ❓ No changes detected in: \`${pathsWithoutChanges.join('`, `')}\`\n\n`;
commentBody += `Please verify if the changes in \`${pathsWithChanges.join('`, `')}\` should also be applied to \`${pathsWithoutChanges.join('`, `')}\`.\n\n`;
}
}
// If we have something to comment about, post a comment on the PR
if (commentBody) {
commentBody = `# Feature Pair Check\n\nThis PR contains changes to one part of a feature pair but not to its counterpart(s).\n\n${commentBody}`;
// Check if we've already commented on this PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const botComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('Feature Pair Check')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
}
12 changes: 12 additions & 0 deletions assets/css/admin.rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
background-image: url( '../images/cards/visa.svg' );
}

.payment-method__brand--alipay {
background-image: url( '../images/payment-methods/alipay-logo.svg' );
}

.payment-method__brand--cartes_bancaires {
background-image: url( '../images/cards/cartes_bancaires.svg' );
}
Expand Down Expand Up @@ -135,6 +139,14 @@
background-image: url( '../images/payment-methods/klarna.svg' );
}

.payment-method__brand--grabpay {
background-image: url( '../images/payment-methods/grabpay.svg' );
}

.payment-method__brand--wechat_pay {
background-image: url( '../images/payment-methods/wechat-pay.svg' );
}

.wc_gateways tr[data-gateway_id='woocommerce_payments'] .payment-method__icon {
border: 1px solid #ddd;
border-radius: 2px;
Expand Down
3 changes: 3 additions & 0 deletions client/tokenized-express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ const fetchNewCartData = async () => {
};

const getTotalAmount = () => {
if ( false ) {
return;
}
if ( cachedCartData ) {
return transformPrice(
parseInt( cachedCartData.totals.total_price, 10 ) -
Expand Down

0 comments on commit a78de27

Please sign in to comment.