Skip to content

Commit

Permalink
Merge branch 'trunk' into add/form-responses-v2-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
CGastrell committed Feb 24, 2023
2 parents 795347d + 053c584 commit ba13141
Show file tree
Hide file tree
Showing 193 changed files with 2,917 additions and 717 deletions.
50 changes: 33 additions & 17 deletions .github/files/build-reminder-comment/check-test-reminder-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,36 @@ const getCheckComments = require( './get-check-comments.js' );
* Does the PR touch anything that needs testing on WordPress.com.
*
* Currently we look whether process.env.CHANGED contains `plugins/jetpack`,
* meaning that Jetpack is being built.
* meaning that Jetpack is being built. Or `packages/jetpack-mu-wpcom`,
* for the jetpack-mu-wpcom-plugin used on WordPress.com is being built.
*
* @param {GitHub} github - Initialized Octokit REST client.
* @param {string} owner - Repository owner.
* @param {string} repo - Repository name.
* @param {string} number - PR number.
* @param {Core} core - A reference to the @actions/core package
* @returns {Promise<boolean>} Promise resolving to a boolean if the PR touches something that needs testing.
* @returns {Promise} Promise resolving to an array of project strings needing testing.
*/
async function isTouchingSomethingNeedingTesting( github, owner, repo, number, core ) {
async function touchedProjectsNeedingTesting( github, owner, repo, number, core ) {
const changed = JSON.parse( process.env.CHANGED );
const projects = [];

if ( changed[ 'plugins/jetpack' ] ) {
core.info( 'Build: Jetpack is being built, testing needed' );
return true;
projects.push( 'jetpack' );
}

if ( changed[ 'packages/jetpack-mu-wpcom' ] ) {
core.info( 'Build: jetpack-mu-wpcom is being built, testing needed' );
projects.push( 'jetpack-mu-wpcom-plugin' );
}

if ( projects.length ) {
return projects;
}

core.info( 'Build: Nothing that needs testing was found' );
return false;
return projects;
}

/**
Expand All @@ -35,16 +46,18 @@ async function isTouchingSomethingNeedingTesting( github, owner, repo, number, c
* @param {github} github - Pre-authenticated octokit/rest.js client with pagination plugins
* @param {object} context - Context of the workflow run
* @param {core} core - A reference to the @actions/core package
* @returns {Promise<number>} Promise resolving to a comment ID, or 0 if no comment is found.
* @returns {Promise} Promise resolving to an object with the following properties:
* - {commentId} - a comment ID, or 0 if no comment is found.
* - {projects} - an array of project strings needing testing.
*/
async function checkTestReminderComment( github, context, core ) {
const { repo, issue } = context;
const { owner, repo: repoName } = repo;
const { TEST_COMMENT_INDICATOR } = process.env;
const data = {};

// Check if one of the files modified in this PR has been de-fusioned,
// and thus must now be tested on WordPress.com.
const touchesSomethingNeedingTesting = await isTouchingSomethingNeedingTesting(
// Check if one of the files modified in this PR need testing on WordPress.com.
data.projects = await touchedProjectsNeedingTesting(
github,
owner,
repoName,
Expand All @@ -54,7 +67,7 @@ async function checkTestReminderComment( github, context, core ) {

core.info(
`Build: This PR ${
touchesSomethingNeedingTesting ? 'touches' : 'does not touch'
data.projects.length ? 'touches' : 'does not touch'
} something that needs testing on WordPress.com.`
);

Expand All @@ -68,9 +81,8 @@ async function checkTestReminderComment( github, context, core ) {
core
);

// This PR does not touch de-fusioned files.
if ( ! touchesSomethingNeedingTesting ) {
// If it previously touched Jetpack, delete the comments that were created then.
// This PR does not touch files needing testing.
if ( ! data.projects.length ) {
if ( testCommentIDs.length > 0 ) {
core.info(
`Build: this PR previously touched something that needs testing, but does not anymore. Deleting previous test reminder comments.`
Expand All @@ -87,7 +99,8 @@ async function checkTestReminderComment( github, context, core ) {
);
}

return 0;
data.commentId = 0;
return data;
}

// If our PR needs testing, and there was previously a test reminder comment, return it.
Expand All @@ -97,7 +110,8 @@ async function checkTestReminderComment( github, context, core ) {
core.info(
`Build: this PR touches something that needs testing, and there was previously a test reminder comment, ${ testCommentIDs[ 0 ] }.`
);
return testCommentIDs[ 0 ];
data.commentId = testCommentIDs[ 0 ];
return data;
}

// If our PR touches something that needs testing, and there has been no test reminder comment yet, create one.
Expand All @@ -115,14 +129,16 @@ async function checkTestReminderComment( github, context, core ) {
body,
} );
core.info( `Build: created test reminder comment with ID ${ id }.` );
return id;
data.commentId = id;
return data;
}

// Fallback. No comment exists, or was created.
core.notice(
`Build: final fallback. No comment exists, or was created. We should not get here.`
);
return 0;
data.commentId = 0;
return data;
}

module.exports = checkTestReminderComment;
25 changes: 15 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ jobs:
env:
CHANGED: ${{ steps.changed.outputs.projects }}
with:
result-encoding: string
script: |
const checkTestReminderComment = require('.github/files/build-reminder-comment/check-test-reminder-comment.js')
const commentId = await checkTestReminderComment( github, context, core );
return commentId;
const data = await checkTestReminderComment( github, context, core );
return data;
- name: Build changed projects
id: build
Expand Down Expand Up @@ -116,24 +115,30 @@ jobs:
- name: Update reminder with testing instructions
id: update-reminder-comment
uses: actions/github-script@v6
if: ${{ github.event_name == 'pull_request' && steps.check-test-reminder-comment.outputs.result != 0 && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
if: ${{ github.event_name == 'pull_request' && fromJSON(steps.check-test-reminder-comment.outputs.result)['commentId'] != 0 && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
env:
BRANCH_NAME: ${{ github.head_ref }}
COMMENT_ID: ${{ steps.check-test-reminder-comment.outputs.result }}
DATA: ${{ steps.check-test-reminder-comment.outputs.result }}
with:
script: |
const { BRANCH_NAME, COMMENT_ID, TEST_COMMENT_INDICATOR } = process.env;
const { BRANCH_NAME, TEST_COMMENT_INDICATOR } = process.env;
const data = JSON.parse( process.env.DATA );
const commands = data.projects.reduce( ( acc, cur ) => {
return acc += `
\`\`\`
bin/jetpack-downloader test ${ cur } ${ BRANCH_NAME }
\`\`\`
`;
}, '' );
const commentBody = `${ TEST_COMMENT_INDICATOR }
Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run
\`\`\`
bin/jetpack-downloader test jetpack ${ BRANCH_NAME }
\`\`\`
${ commands }
to get started. More details: p9dueE-5Nn-p2`;
await github.rest.issues.updateComment( {
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody,
comment_id: +COMMENT_ID,
comment_id: +data.commentId,
} );
jetpack_beta:
Expand Down
50 changes: 25 additions & 25 deletions pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

JS Components: Add Mastodon icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Update React peer dependencies to match updated dev dependencies.
6 changes: 5 additions & 1 deletion projects/js-packages/components/components/icons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Available slugs are:
* linkedin
* tumblr
* google
* mastodon

```es6
import {
Expand Down Expand Up @@ -52,6 +53,7 @@ return (
* LinkedinIcon
* TumblrIcon
* GoogleIcon
* MastodonIcon

```es6
import {
Expand All @@ -69,7 +71,8 @@ import {
TwitterIcon,
LinkedinIcon,
TumblrIcon,
GoogleIcon
GoogleIcon,
MastodonIcon
} from '@automattic/jetpack-components';

return (
Expand All @@ -89,6 +92,7 @@ return (
<LinkedinIcon />
<TumblrIcon />
<GoogleIcon />
<MastodonIcon />
</div>
)
```
13 changes: 13 additions & 0 deletions projects/js-packages/components/components/icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ export const GoogleIcon: React.FC< SocialIconWrapperProps > = ( { fill, size, cl
);
};

export const MastodonIcon: React.FC< SocialIconWrapperProps > = ( { fill, size, className } ) => {
return (
<SocialIconWrapper
fill={ fill }
size={ size }
className={ classNames( styles.mastodon, className ) }
>
<Path d="M 19.997205,6.2868955 C 19.729197,4.3162778 17.992912,2.7633017 15.93468,2.4623753 15.587434,2.4115195 14.271759,2.2264681 11.224008,2.2264681 h -0.02277 c -3.0485688,0 -3.7026204,0.1850577 -4.0498676,0.2359072 C 5.1504449,2.7549655 3.3231548,4.1503966 2.879815,6.1443318 2.6665754,7.1263038 2.6438193,8.2149794 2.6834329,9.2136207 c 0.056471,1.4321143 0.067433,2.8617113 0.1989115,4.2879943 0.090908,0.947406 0.2494696,1.887266 0.4745239,2.812521 0.4214237,1.708868 2.1273496,3.130966 3.7987144,3.71116 1.7894479,0.605052 3.7138403,0.705478 5.5577463,0.290088 0.202828,-0.04667 0.403445,-0.100873 0.601781,-0.162549 0.447558,-0.140863 0.972662,-0.298434 1.358683,-0.575188 0.0052,-0.004 0.0097,-0.0089 0.01266,-0.01471 0.0031,-0.0056 0.0047,-0.01218 0.005,-0.01866 v -1.382076 c -9.4e-5,-0.006 -0.0016,-0.01202 -0.0043,-0.01754 -0.0027,-0.0054 -0.0067,-0.01028 -0.01155,-0.01392 -0.0049,-0.0038 -0.01044,-0.0063 -0.01648,-0.0078 -0.006,-0.0013 -0.01218,-0.0013 -0.01825,7.1e-5 -1.181368,0.279106 -2.391962,0.419012 -3.606552,0.416801 -2.0902554,0 -2.6524392,-0.981126 -2.8134375,-1.3896 -0.1293933,-0.353009 -0.2115739,-0.721231 -0.2444221,-1.095331 -3.29e-4,-0.0063 8.463e-4,-0.0125 0.00348,-0.01832 0.00253,-0.0056 0.00649,-0.01077 0.011389,-0.01471 0.0049,-0.004 0.010755,-0.0068 0.016957,-0.0081 0.00617,-0.0014 0.012655,-0.0012 0.018808,3.52e-4 1.1616831,0.277201 2.3525266,0.417106 3.5475526,0.416801 0.287408,0 0.573966,0 0.861395,-0.0074 1.201893,-0.03335 2.468685,-0.0942 3.6512,-0.322606 0.02952,-0.0058 0.059,-0.01091 0.0843,-0.01833 1.865209,-0.354279 3.640245,-1.466278 3.820617,-4.282163 0.0068,-0.110869 0.0236,-1.161191 0.0236,-1.276219 8.46e-4,-0.390958 0.127273,-2.7733487 -0.01856,-4.2371335 z m -2.87074,7.0263315 H 15.165179 V 8.5617567 c 0,-1.0003116 -0.421434,-1.5104614 -1.278618,-1.5104614 -0.942305,0 -1.414292,0.6035217 -1.414292,1.7955379 V 11.44764 H 10.522764 V 8.8468332 c 0,-1.1920162 -0.472832,-1.7955379 -1.4151372,-1.7955379 -0.8521293,0 -1.2777701,0.5101498 -1.2786179,1.5104614 V 13.313227 H 5.8693944 V 8.4175496 c 0,-1.0003133 0.2582014,-1.7949986 0.7745804,-2.3840846 0.5326766,-0.587672 1.2314038,-0.8894211 2.0986981,-0.8894211 1.003817,0 1.7623841,0.3817657 2.2680911,1.1445204 l 0.488023,0.8102521 0.488846,-0.8102521 c 0.505705,-0.7627547 1.264275,-1.1445204 2.26642,-1.1445204 0.866449,0 1.565152,0.3017491 2.099521,0.8894211 0.516404,0.5885211 0.774583,1.3832066 0.774583,2.3840846 z" />
</SocialIconWrapper>
);
};

const jetpackIcons = {
'anti-spam': AntiSpamIcon,
backup: BackupIcon,
Expand All @@ -304,6 +316,7 @@ const socialIcons = {
linkedin: LinkedinIcon,
tumblr: TumblrIcon,
google: GoogleIcon,
mastodon: MastodonIcon,
};

const iconsMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
&.google {
fill: var( --color-gplus );
}
&.mastodon {
fill: var( --color-mastodon );
}
}

Loading

0 comments on commit ba13141

Please sign in to comment.