Skip to content

Commit 77fca7d

Browse files
authored
Merge pull request #5117 from xwp/add/spa-amp-shadow-dom
Merge develop and resolve conflicts
2 parents ca3c404 + 7b9077d commit 77fca7d

File tree

1,373 files changed

+100770
-60849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,373 files changed

+100770
-60849
lines changed

.dev-lib

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,33 @@ DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
88
CHECK_SCOPE=all
99

1010
function after_wp_install {
11-
if [[ "$WP_VERSION" != "4.9" ]]; then
12-
echo -n "Installing Gutenberg..."
13-
gutenberg_plugin_svn_url=https://plugins.svn.wordpress.org/gutenberg/trunk/
11+
case "$WP_VERSION" in
12+
"4.9")
13+
gb_version=""
14+
;;
15+
"5.0" | "5.1")
16+
gb_version="6.9.0"
17+
;;
18+
"5.2")
19+
gb_version="7.6.1"
20+
;;
21+
*)
22+
# WP 5.3 onwards can use the latest version of Gutenberg.
23+
gb_version="trunk"
24+
esac
25+
26+
if [[ "$gb_version" != "" ]]; then
27+
echo -n "Installing Gutenberg ${gb_version}..."
28+
29+
url_path=$([ $gb_version == "trunk" ] && echo "trunk" || echo "tags/${gb_version}")
30+
gutenberg_plugin_svn_url="https://plugins.svn.wordpress.org/gutenberg/${url_path}/"
1431
svn export -q "$gutenberg_plugin_svn_url" "$WP_CORE_DIR/src/wp-content/plugins/gutenberg"
1532
echo "done"
1633
fi
1734

1835
if [[ ! -z $INSTALL_PWA_PLUGIN ]]; then
19-
echo -n "Installing PWA 0.2-alpha2..."
20-
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://github.com/xwp/pwa-wp/releases/download/0.2-alpha2/pwa.zip
36+
echo -n "Installing PWA plugin..."
37+
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://downloads.wordpress.org/plugin/pwa.zip
2138
unzip -d "$WP_CORE_DIR/src/wp-content/plugins/pwa/" "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip"
2239
echo "done"
2340
fi

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
**/assets/js/*.js
55
!assets/js/amp-service-worker-runtime-precaching.js
66
build/*
7+
lib/*

.eslintrc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"root": true,
33
"extends": [
4-
"plugin:@wordpress/eslint-plugin/recommended",
4+
"plugin:@wordpress/eslint-plugin/recommended-with-formatting",
55
"plugin:import/recommended",
66
"plugin:eslint-comments/recommended"
77
],
@@ -57,7 +57,7 @@
5757
"react/no-unused-prop-types": "error",
5858
"react/self-closing-comp": "error",
5959
"import/no-unresolved": [ "error", {
60-
"ignore": [ "jquery", "amp-block-editor-data" ]
60+
"ignore": [ "jquery", "amp-block-editor-data", "amp-settings" ]
6161
} ],
6262
"import/order": [ "error", { "groups": [ "builtin", [ "external", "unknown" ], "internal", "parent", "sibling", "index" ] } ],
6363
"jsdoc/check-indentation": "error",
@@ -104,6 +104,17 @@
104104
"jest/prefer-expect-assertions": "off",
105105
"jest/prefer-inline-snapshots": "off"
106106
}
107+
},
108+
{
109+
"files": [
110+
"assets/src/mobile-redirection.js"
111+
],
112+
"globals": {
113+
"AMP_MOBILE_REDIRECTION": false,
114+
"location": false,
115+
"navigator": false,
116+
"sessionStorage": false
117+
}
107118
}
108119
]
109120
}

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib/optimizer/resources/local_fallback/* linguist-generated=true
2+
lib/optimizer/tests/spec/* linguist-generated=true
3+
*.snap linguist-generated=true
4+
includes/sanitizers/class-amp-allowed-tags-generated.php linguist-generated=true

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ Fixes #
55

66
## Checklist
77

8-
- [ ] 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).
9-
- [ ] My code is tested and passes existing [tests](https://github.com/ampproject/amp-wp/contributing/engineering.md#tests).
10-
- [ ] 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).
8+
- [ ] My pull request is addressing an open issue (please create one otherwise).
9+
- [ ] My code is tested and passes existing [tests](https://github.com/ampproject/amp-wp/wiki/Engineering-Guidelines#tests).
10+
- [ ] 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).
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
name: Build, test & measure
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
# Include all release branches.
8+
- '*.*'
9+
pull_request:
10+
# Run workflow whenever a PR is opened, updated (synchronized), or marked ready for review.
11+
types: [opened, synchronize, ready_for_review]
12+
13+
jobs:
14+
15+
dev-zip:
16+
name: Build dev build ZIP and upload as GHA artifact
17+
# Only run if it is not a draft PR and the PR is not from a forked repository.
18+
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
19+
runs-on: ubuntu-latest
20+
outputs:
21+
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
22+
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}
23+
24+
steps:
25+
- name: Check out source files
26+
uses: actions/checkout@v2
27+
28+
- name: Get Composer Cache Directory
29+
id: composer-cache
30+
run: |
31+
echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
33+
- name: Configure Composer cache
34+
uses: actions/cache@v1
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-composer-
40+
41+
- name: Install Composer dependencies
42+
# Scripts are not ignored as they are needed to apply patches for the
43+
# `sabberworm/php-css-parser` dependency.
44+
run: composer install --prefer-dist --optimize-autoloader
45+
46+
- name: Get npm cache directory
47+
id: npm-cache
48+
run: |
49+
echo "::set-output name=dir::$(npm config get cache)"
50+
51+
- name: Configure npm cache
52+
uses: actions/cache@v1
53+
with:
54+
path: ${{ steps.npm-cache.outputs.dir }}
55+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
56+
restore-keys: |
57+
${{ runner.os }}-node-
58+
59+
- name: Install Node dependencies
60+
# Prevent malicious scripts from being run with `--ignore-scripts`
61+
run: npm install --ignore-scripts
62+
63+
- name: Create destination directories
64+
run: mkdir -p builds/dev
65+
66+
- name: Build develop version
67+
run: |
68+
npm run build:dev
69+
mv amp.zip builds/dev/amp.zip
70+
71+
- name: Retrieve branch name
72+
id: retrieve-branch-name
73+
run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')"
74+
75+
- name: Retrieve git SHA-8 string
76+
id: retrieve-git-sha-8
77+
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
78+
79+
- name: Upload build as artifact
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: amp-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}-dev
83+
path: builds/dev
84+
85+
#-----------------------------------------------------------------------------------------------------------------------
86+
87+
prod-zip:
88+
name: Build prod build ZIP and upload as GHA artifact
89+
# Only run if it is not a draft PR and the PR is not from a forked repository.
90+
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
91+
runs-on: ubuntu-latest
92+
outputs:
93+
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
94+
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}
95+
96+
steps:
97+
- name: Check out source files
98+
uses: actions/checkout@v2
99+
100+
- name: Get Composer Cache Directory
101+
id: composer-cache
102+
run: |
103+
echo "::set-output name=dir::$(composer config cache-files-dir)"
104+
105+
- name: Configure Composer cache
106+
uses: actions/cache@v1
107+
with:
108+
path: ${{ steps.composer-cache.outputs.dir }}
109+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
110+
restore-keys: |
111+
${{ runner.os }}-composer-
112+
113+
- name: Install Composer dependencies
114+
# Scripts are not ignored as they are needed to apply patches for the
115+
# `sabberworm/php-css-parser` dependency.
116+
run: composer install --prefer-dist --optimize-autoloader
117+
118+
- name: Get npm cache directory
119+
id: npm-cache
120+
run: |
121+
echo "::set-output name=dir::$(npm config get cache)"
122+
123+
- name: Configure npm cache
124+
uses: actions/cache@v1
125+
with:
126+
path: ${{ steps.npm-cache.outputs.dir }}
127+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
128+
restore-keys: |
129+
${{ runner.os }}-node-
130+
131+
- name: Install Node dependencies
132+
# Prevent malicious scripts from being run with `--ignore-scripts`
133+
run: npm install --ignore-scripts
134+
135+
- name: Create destination directories
136+
run: mkdir -p builds/prod
137+
138+
- name: Build production version
139+
run: |
140+
npm run build:prod
141+
mv amp.zip builds/prod/amp.zip
142+
143+
- name: Retrieve branch name
144+
id: retrieve-branch-name
145+
run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')"
146+
147+
- name: Retrieve git SHA-8 string
148+
id: retrieve-git-sha-8
149+
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
150+
151+
- name: Upload build as artifact
152+
uses: actions/upload-artifact@v2
153+
with:
154+
name: amp-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}-prod
155+
path: builds/prod
156+
157+
#-----------------------------------------------------------------------------------------------------------------------
158+
159+
upload-to-gcs:
160+
name: Upload plugin ZIPs to Google Cloud Storage
161+
runs-on: ubuntu-latest
162+
needs:
163+
- dev-zip
164+
- prod-zip
165+
steps:
166+
- name: Download dev build
167+
uses: actions/download-artifact@v2
168+
with:
169+
name: amp-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}-dev
170+
path: builds/dev
171+
172+
- name: Download prod build
173+
uses: actions/download-artifact@v2
174+
with:
175+
name: amp-${{ needs.prod-zip.outputs.branch-name }}-${{ needs.prod-zip.outputs.git-sha-8 }}-prod
176+
path: builds/prod
177+
178+
- name: Setup Google Cloud SDK
179+
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
180+
with:
181+
project_id: ${{ secrets.GCS_PROJECT_ID }}
182+
service_account_key: ${{ secrets.GCS_APPLICATION_CREDENTIALS }}
183+
184+
- name: Upload dev build to bucket
185+
run: gsutil cp -r builds/dev/amp.zip gs://ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip
186+
187+
- name: Upload prod build to bucket
188+
run: gsutil cp -r builds/prod/amp.zip gs://ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip
189+
190+
#-----------------------------------------------------------------------------------------------------------------------
191+
192+
comment-on-pr:
193+
name: Comment on PR with links to plugin ZIPs
194+
# Only run this job if it's a PR. One way to check for that is if `github.head_ref` is not empty.
195+
if: ${{ github.head_ref && github.head_ref != null }}
196+
runs-on: ubuntu-latest
197+
needs: upload-to-gcs
198+
199+
outputs:
200+
pr_number: ${{ steps.get-pr-number.outputs.num }}
201+
comment_body: ${{ steps.get-comment-body.outputs.body }}
202+
203+
steps:
204+
- name: Get PR number
205+
id: get-pr-number
206+
run: echo "::set-output name=num::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"
207+
208+
- name: Check if a comment was already made
209+
id: find-comment
210+
uses: peter-evans/find-comment@v1
211+
with:
212+
issue-number: ${{ steps.get-pr-number.outputs.num }}
213+
comment-author: github-actions[bot]
214+
body-includes: Download [development build]
215+
216+
- name: Get comment body
217+
id: get-comment-body
218+
# Setting a multi-line output requires escaping line-feeds. See <https://github.community/t/set-output-truncates-multiline-strings/16852/3>.
219+
run: |
220+
body="Plugin builds for ${{ github.event.pull_request.head.sha }} are ready :bellhop_bell:!
221+
- Download [development build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip)
222+
- Download [production build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip)"
223+
body="${body//$'\n'/'%0A'}"
224+
echo "::set-output name=body::$body"
225+
226+
- name: Create comment on PR with links to plugin builds
227+
if: ${{ steps.find-comment.outputs.comment-id == '' }}
228+
uses: peter-evans/create-or-update-comment@v1
229+
with:
230+
issue-number: ${{ steps.get-pr-number.outputs.num }}
231+
body: ${{ steps.get-comment-body.outputs.body }}
232+
233+
- name: Update comment on PR with links to plugin builds
234+
if: ${{ steps.find-comment.outputs.comment-id != '' }}
235+
uses: peter-evans/create-or-update-comment@v1
236+
with:
237+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
238+
edit-mode: replace
239+
body: ${{ steps.get-comment-body.outputs.body }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ wiki
66
amp.zip
77
/assets/css/*
88
!/assets/css/src/
9-
assets/js/*.js
9+
assets/js/**/*.js
1010
assets/js/*.asset.php
1111
!assets/js/amp-service-worker-runtime-precaching.js
1212
assets/js/*.map
1313
built
1414
/amphtml
1515
.env
1616
.idea/
17+
/lib/*/vendor/
18+
/lib/*/composer.lock
19+
/phpcs.xml
20+
/phpunit.xml

0 commit comments

Comments
 (0)