Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request ampproject#5117 from xwp/add/spa-amp-shadow-dom
Browse files Browse the repository at this point in the history
Merge develop and resolve conflicts
  • Loading branch information
westonruter authored Jul 29, 2020
2 parents ca3c404 + 7b9077d commit 77fca7d
Show file tree
Hide file tree
Showing 1,373 changed files with 100,770 additions and 60,849 deletions.
27 changes: 22 additions & 5 deletions .dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,33 @@ DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
CHECK_SCOPE=all

function after_wp_install {
if [[ "$WP_VERSION" != "4.9" ]]; then
echo -n "Installing Gutenberg..."
gutenberg_plugin_svn_url=https://plugins.svn.wordpress.org/gutenberg/trunk/
case "$WP_VERSION" in
"4.9")
gb_version=""
;;
"5.0" | "5.1")
gb_version="6.9.0"
;;
"5.2")
gb_version="7.6.1"
;;
*)
# WP 5.3 onwards can use the latest version of Gutenberg.
gb_version="trunk"
esac

if [[ "$gb_version" != "" ]]; then
echo -n "Installing Gutenberg ${gb_version}..."

url_path=$([ $gb_version == "trunk" ] && echo "trunk" || echo "tags/${gb_version}")
gutenberg_plugin_svn_url="https://plugins.svn.wordpress.org/gutenberg/${url_path}/"
svn export -q "$gutenberg_plugin_svn_url" "$WP_CORE_DIR/src/wp-content/plugins/gutenberg"
echo "done"
fi

if [[ ! -z $INSTALL_PWA_PLUGIN ]]; then
echo -n "Installing PWA 0.2-alpha2..."
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://github.com/xwp/pwa-wp/releases/download/0.2-alpha2/pwa.zip
echo -n "Installing PWA plugin..."
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://downloads.wordpress.org/plugin/pwa.zip
unzip -d "$WP_CORE_DIR/src/wp-content/plugins/pwa/" "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip"
echo "done"
fi
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/assets/js/*.js
!assets/js/amp-service-worker-runtime-precaching.js
build/*
lib/*
15 changes: 13 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"extends": [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:@wordpress/eslint-plugin/recommended-with-formatting",
"plugin:import/recommended",
"plugin:eslint-comments/recommended"
],
Expand Down Expand Up @@ -57,7 +57,7 @@
"react/no-unused-prop-types": "error",
"react/self-closing-comp": "error",
"import/no-unresolved": [ "error", {
"ignore": [ "jquery", "amp-block-editor-data" ]
"ignore": [ "jquery", "amp-block-editor-data", "amp-settings" ]
} ],
"import/order": [ "error", { "groups": [ "builtin", [ "external", "unknown" ], "internal", "parent", "sibling", "index" ] } ],
"jsdoc/check-indentation": "error",
Expand Down Expand Up @@ -104,6 +104,17 @@
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off"
}
},
{
"files": [
"assets/src/mobile-redirection.js"
],
"globals": {
"AMP_MOBILE_REDIRECTION": false,
"location": false,
"navigator": false,
"sessionStorage": false
}
}
]
}
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lib/optimizer/resources/local_fallback/* linguist-generated=true
lib/optimizer/tests/spec/* linguist-generated=true
*.snap linguist-generated=true
includes/sanitizers/class-amp-allowed-tags-generated.php linguist-generated=true
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Fixes #

## Checklist

- [ ] My pull request is addressing an [open issue](https://github.com/ampproject/amp-wp/contributing/project-management.md#life-of-an-issue) (please create one otherwise).
- [ ] My code is tested and passes existing [tests](https://github.com/ampproject/amp-wp/contributing/engineering.md#tests).
- [ ] My code follows the [Engineering Guidelines](https://github.com/ampproject/amp-wp/contributing/engineering.md) (updates are often made to the guidelines, check it out periodically).
- [ ] My pull request is addressing an open issue (please create one otherwise).
- [ ] My code is tested and passes existing [tests](https://github.com/ampproject/amp-wp/wiki/Engineering-Guidelines#tests).
- [ ] My code follows the [Engineering Guidelines](https://github.com/ampproject/amp-wp/wiki/Engineering-Guidelines) (updates are often made to the guidelines, check it out periodically).
239 changes: 239 additions & 0 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
name: Build, test & measure

on:
push:
branches:
- develop
# Include all release branches.
- '*.*'
pull_request:
# Run workflow whenever a PR is opened, updated (synchronized), or marked ready for review.
types: [opened, synchronize, ready_for_review]

jobs:

dev-zip:
name: Build dev build ZIP and upload as GHA artifact
# Only run if it is not a draft PR and the PR is not from a forked repository.
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}

steps:
- name: Check out source files
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
# Scripts are not ignored as they are needed to apply patches for the
# `sabberworm/php-css-parser` dependency.
run: composer install --prefer-dist --optimize-autoloader

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Configure npm cache
uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node dependencies
# Prevent malicious scripts from being run with `--ignore-scripts`
run: npm install --ignore-scripts

- name: Create destination directories
run: mkdir -p builds/dev

- name: Build develop version
run: |
npm run build:dev
mv amp.zip builds/dev/amp.zip
- name: Retrieve branch name
id: retrieve-branch-name
run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')"

- name: Retrieve git SHA-8 string
id: retrieve-git-sha-8
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"

- name: Upload build as artifact
uses: actions/upload-artifact@v2
with:
name: amp-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}-dev
path: builds/dev

#-----------------------------------------------------------------------------------------------------------------------

prod-zip:
name: Build prod build ZIP and upload as GHA artifact
# Only run if it is not a draft PR and the PR is not from a forked repository.
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}

steps:
- name: Check out source files
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
# Scripts are not ignored as they are needed to apply patches for the
# `sabberworm/php-css-parser` dependency.
run: composer install --prefer-dist --optimize-autoloader

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Configure npm cache
uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node dependencies
# Prevent malicious scripts from being run with `--ignore-scripts`
run: npm install --ignore-scripts

- name: Create destination directories
run: mkdir -p builds/prod

- name: Build production version
run: |
npm run build:prod
mv amp.zip builds/prod/amp.zip
- name: Retrieve branch name
id: retrieve-branch-name
run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')"

- name: Retrieve git SHA-8 string
id: retrieve-git-sha-8
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"

- name: Upload build as artifact
uses: actions/upload-artifact@v2
with:
name: amp-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}-prod
path: builds/prod

#-----------------------------------------------------------------------------------------------------------------------

upload-to-gcs:
name: Upload plugin ZIPs to Google Cloud Storage
runs-on: ubuntu-latest
needs:
- dev-zip
- prod-zip
steps:
- name: Download dev build
uses: actions/download-artifact@v2
with:
name: amp-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}-dev
path: builds/dev

- name: Download prod build
uses: actions/download-artifact@v2
with:
name: amp-${{ needs.prod-zip.outputs.branch-name }}-${{ needs.prod-zip.outputs.git-sha-8 }}-prod
path: builds/prod

- name: Setup Google Cloud SDK
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
service_account_key: ${{ secrets.GCS_APPLICATION_CREDENTIALS }}

- name: Upload dev build to bucket
run: gsutil cp -r builds/dev/amp.zip gs://ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip

- name: Upload prod build to bucket
run: gsutil cp -r builds/prod/amp.zip gs://ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip

#-----------------------------------------------------------------------------------------------------------------------

comment-on-pr:
name: Comment on PR with links to plugin ZIPs
# Only run this job if it's a PR. One way to check for that is if `github.head_ref` is not empty.
if: ${{ github.head_ref && github.head_ref != null }}
runs-on: ubuntu-latest
needs: upload-to-gcs

outputs:
pr_number: ${{ steps.get-pr-number.outputs.num }}
comment_body: ${{ steps.get-comment-body.outputs.body }}

steps:
- name: Get PR number
id: get-pr-number
run: echo "::set-output name=num::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"

- name: Check if a comment was already made
id: find-comment
uses: peter-evans/find-comment@v1
with:
issue-number: ${{ steps.get-pr-number.outputs.num }}
comment-author: github-actions[bot]
body-includes: Download [development build]

- name: Get comment body
id: get-comment-body
# Setting a multi-line output requires escaping line-feeds. See <https://github.community/t/set-output-truncates-multiline-strings/16852/3>.
run: |
body="Plugin builds for ${{ github.event.pull_request.head.sha }} are ready :bellhop_bell:!
- Download [development build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip)
- Download [production build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip)"
body="${body//$'\n'/'%0A'}"
echo "::set-output name=body::$body"
- name: Create comment on PR with links to plugin builds
if: ${{ steps.find-comment.outputs.comment-id == '' }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ steps.get-pr-number.outputs.num }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update comment on PR with links to plugin builds
if: ${{ steps.find-comment.outputs.comment-id != '' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: ${{ steps.get-comment-body.outputs.body }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ wiki
amp.zip
/assets/css/*
!/assets/css/src/
assets/js/*.js
assets/js/**/*.js
assets/js/*.asset.php
!assets/js/amp-service-worker-runtime-precaching.js
assets/js/*.map
built
/amphtml
.env
.idea/
/lib/*/vendor/
/lib/*/composer.lock
/phpcs.xml
/phpunit.xml
Loading

0 comments on commit 77fca7d

Please sign in to comment.