Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the poc #10467

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
}
]
}
129 changes: 129 additions & 0 deletions .github/workflows/feature-pair-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
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@v4
with:
fetch-depth: 0

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

- name: Install dependencies
run: |
npm install @octokit/rest
echo '{"type": "module"}' > package.json

- name: Create script
run: |
cat > check-feature-pairs.js << 'EOL'
import fs from 'fs';
import { Octokit } from '@octokit/rest';

async function run() {
try {
// Initialize Octokit
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN
});

// Parse GitHub context from environment variables
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
const pullNumber = parseInt(process.env.PR_NUMBER, 10);

// 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 octokit.pulls.listFiles({
owner,
repo,
pull_number: pullNumber
});

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 octokit.issues.listComments({
owner,
repo,
issue_number: pullNumber
});

const botComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('Feature Pair Check')
);

if (botComment) {
// Update existing comment
await octokit.issues.updateComment({
owner,
repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment
await octokit.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody
});
}
}
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}

run();
EOL

- name: Run feature pair check
run: node check-feature-pairs.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
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
Loading