This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
forked from ampproject/amp-wp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ampproject#5117 from xwp/add/spa-amp-shadow-dom
Merge develop and resolve conflicts
- Loading branch information
Showing
1,373 changed files
with
100,770 additions
and
60,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
**/assets/js/*.js | ||
!assets/js/amp-service-worker-runtime-precaching.js | ||
build/* | ||
lib/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.