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

Shopping: Products JSON Schema Validation #11250

Merged
merged 17 commits into from
Apr 30, 2022
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/update-browserslist.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Update browserslist db

on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 1'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-google-fonts.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Update Google Fonts

on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 1'

Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/update-product-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update Product Schema

on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 1'

env:
GIT_AUTHOR_EMAIL: 94923726+googleforcreators-bot@users.noreply.github.com
GIT_AUTHOR_NAME: googleforcreators-bot
GIT_COMMITTER_EMAIL: 94923726+googleforcreators-bot@users.noreply.github.com
GIT_COMMITTER_NAME: googleforcreators-bot
swissspidy marked this conversation as resolved.
Show resolved Hide resolved

jobs:
update-fonts:
name: Update Product Schema
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GOOGLEFORCREATORS_BOT_TOKEN }}

- name: Update Product Schema
run: |
curl -O -f https://raw.githubusercontent.com/ampproject/amphtml/main/examples/amp-story/shopping/product.schema.json
mv product.schema.json packages/e2e-tests/src/specs/editor/shopping/schema.json

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GOOGLEFORCREATORS_BOT_TOKEN }}
commit-message: Update Product Schema
title: Update Product Schema
body: |
Fetched the current [product JSON schema](https://github.com/ampproject/amphtml/blob/main/examples/amp-story/shopping/product.schema.json) for `<amp-story-shopping>` to update it in the project.
branch: update/product-schema
labels: Dependencies
1 change: 1 addition & 0 deletions .github/workflows/update-templates.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Migrate Templates

on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 1'

Expand Down
17 changes: 17 additions & 0 deletions bin/local-env/install-wordpress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ fi
echo -e $(status_message "Installing and activating RTL Tester plugin...")
wp plugin install rtl-tester --activate --force --quiet

echo -e $(status_message "Installing WordPress importer...")
wp plugin install wordpress-importer --activate --force --quiet

# Only install woocommerce on latest version of WordPress.
timarney marked this conversation as resolved.
Show resolved Hide resolved
if [ "$WP_VERSION" == "latest" ]; then
echo -e $(status_message "Installing WooCommerce plugin...")
wp plugin install woocommerce --activate --force --quiet
fi

echo -e $(status_message "Installing AMP plugin...")
wp plugin install amp --force --quiet

Expand Down Expand Up @@ -219,3 +228,11 @@ wp option patch insert web_stories_experiments enableSVG 0
wp user list --format=yaml
wp post list --post_type=attachment --format=yaml
wp plugin list --format=yaml

# Only install woocommerce on latest version of WordPress.
if [ "$WP_VERSION" == "latest" ]; then
echo -e $(status_message "Import sample woocommerce products...")
wp import /var/www/html/wp-content/plugins/woocommerce/sample-data/sample_products.xml --authors=skip --quiet
# deactivate test etc... can activate as needed
wp plugin deactivate woocommerce
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
fi
6 changes: 3 additions & 3 deletions includes/REST_API/Products_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ protected function get_items_shopify( $request ) {
'productBrand' => $product['vendor'],
// TODO: Maybe eventually provide full price range.
// See https://github.com/ampproject/amphtml/issues/37957.
'productPrice' => $product['priceRange']['minVariantPrice']['amount'],
'productPrice' => (float) $product['priceRange']['minVariantPrice']['amount'],
'productPriceCurrency' => $product['priceRange']['minVariantPrice']['currencyCode'],
'productImages' => $images,
'productDetails' => $product['description'],
Expand Down Expand Up @@ -382,11 +382,11 @@ static function( $image_id ) {
'productId' => 'wc-' . $product->get_id(),
'productTitle' => $product->get_title(),
'productBrand' => '', // TODO: Figure out how to best provide that.
'productPrice' => $product->get_price(),
'productPrice' => (float) $product->get_price(),
'productPriceCurrency' => get_woocommerce_currency(),
'productImages' => $images,
'aggregateRating' => [
'ratingValue' => $product->get_average_rating(),
'ratingValue' => (float) $product->get_average_rating(),
'reviewCount' => $product->get_rating_count(),
'reviewUrl' => $product->get_permalink(),
],
Expand Down
186 changes: 175 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"babel-jest": "^27.4.6",
"expect-puppeteer": "^6.0.2",
"jest-extended": "^2.0.0",
"jest-json-schema": "^6.1.0",
"jest-puppeteer": "^6.1.0"
},
"peerDependencies": {
Expand Down
Loading