This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
…products-block into add/4965-image
- Loading branch information
Showing
514 changed files
with
8,759 additions
and
5,380 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
--- | ||
name: '📖 Feedback – Documentation' | ||
about: Submit feedback or report an issue about some documentation. | ||
labels: 'type: documentation' | ||
--- | ||
|
||
<!-- | ||
Thank you for taking the time to leave your feedback about the documentation. Please explain your issue or suggestion below. | ||
--> |
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,12 @@ | ||
name: 'Compare Assets' | ||
description: 'Compares two assets files created by DependencyExtractionWebpackPlugin and reports the differences.' | ||
inputs: | ||
repo-token: | ||
description: 'GitHub token' | ||
required: true | ||
compare: | ||
description: 'Path to assets file to compare the build assets with.' | ||
required: true | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
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,108 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const { getOctokit, context } = require( '@actions/github' ); | ||
const { setFailed, getInput } = require( '@actions/core' ); | ||
|
||
const runner = async () => { | ||
try { | ||
const token = getInput( 'repo-token', { required: true } ); | ||
const octokit = getOctokit( token ); | ||
const payload = context.payload; | ||
const repo = payload.repository.name; | ||
const owner = payload.repository.owner.login; | ||
const oldAssets = require( '../../' + | ||
getInput( 'compare', { | ||
required: true, | ||
} ) ); | ||
|
||
if ( ! oldAssets ) { | ||
return; | ||
} | ||
|
||
const newAssets = require( '../../build/assets.json' ); | ||
|
||
if ( ! newAssets ) { | ||
return; | ||
} | ||
|
||
const changes = Object.fromEntries( | ||
Object.entries( newAssets ) | ||
.map( ( [ key, { dependencies = [] } ] ) => { | ||
const oldDependencies = | ||
oldAssets[ key ]?.dependencies || []; | ||
const added = dependencies.filter( | ||
( dependency ) => | ||
! oldDependencies.includes( dependency ) | ||
); | ||
const removed = oldDependencies.filter( | ||
( dependency ) => ! dependencies.includes( dependency ) | ||
); | ||
return added.length || removed.length | ||
? [ | ||
key, | ||
{ | ||
added, | ||
removed, | ||
}, | ||
] | ||
: null; | ||
} ) | ||
.filter( Boolean ) | ||
); | ||
|
||
if ( Object.keys( changes ).length === 0 ) { | ||
return; | ||
} | ||
|
||
let reportContent = ''; | ||
|
||
Object.entries( changes ).forEach( | ||
( [ handle, { added, removed } ] ) => { | ||
const addedDeps = added.length | ||
? '`' + added.join( '`, `' ) + '`' | ||
: ''; | ||
const removedDeps = removed.length | ||
? '`' + removed.join( '`, `' ) + '`' | ||
: ''; | ||
|
||
let icon = ''; | ||
|
||
if ( added.length && removed.length ) { | ||
icon = '❓'; | ||
} else if ( added.length ) { | ||
icon = '⚠️'; | ||
} else if ( removed.length ) { | ||
icon = '🎉'; | ||
} | ||
|
||
reportContent += | ||
`| \`${ handle }\` | ${ addedDeps } | ${ removedDeps } | ${ icon } |` + | ||
'\n'; | ||
} | ||
); | ||
|
||
await octokit.rest.issues.createComment( { | ||
owner, | ||
repo, | ||
issue_number: payload.pull_request.number, | ||
body: | ||
'# Script Dependencies Report' + | ||
'\n\n' + | ||
'The `compare-assets` action has detected some changed script dependencies between this branch and ' + | ||
'trunk. Please review and confirm the following are correct before merging.' + | ||
'\n\n' + | ||
'| Script Handle | Added | Removed | |' + | ||
'\n' + | ||
'| ------------- | ------| ------- | -- |' + | ||
'\n' + | ||
reportContent + | ||
'\n\n' + | ||
'__This comment was automatically generated by the `./github/compare-assets` action.__', | ||
} ); | ||
} catch ( error ) { | ||
setFailed( error.message ); | ||
} | ||
}; | ||
|
||
runner(); |
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,71 @@ | ||
name: Check Modified Assets | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build-trunk: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: trunk | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}- | ||
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}- | ||
- name: Use Node.js 14.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- name: npm install and build | ||
run: | | ||
npm ci | ||
npm run build:check-assets | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: assets-list | ||
path: ./build/assets.json | ||
|
||
compare-assets-with-trunk: | ||
needs: [build-trunk] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}- | ||
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}- | ||
- name: Use Node.js 14.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14.x | ||
- name: npm install | ||
run: | | ||
npm ci | ||
npm run build:check-assets | ||
- name: Download assets (trunk) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: assets-list | ||
path: assets-list | ||
- name: Compare Assets | ||
uses: ./.github/compare-assets | ||
with: | ||
repo-token: '${{ secrets.GITHUB_TOKEN }}' | ||
compare: assets-list/assets.json |
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
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.