Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/subscription-block-toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
TimBroddin committed Feb 24, 2023
2 parents a300a83 + cee144a commit ccb0b2a
Show file tree
Hide file tree
Showing 832 changed files with 16,798 additions and 10,388 deletions.
5 changes: 1 addition & 4 deletions .github/actions/tool-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ description: "Setup needed versions of PHP, Node, and Pnpm."
inputs:
php:
description: "Override the PHP version, or set 'false' to skip setting up PHP."
coverage:
description: "Set the PHP coverage driver, e.g. 'none' or 'pcov'."
default: 'none'
node:
description: "Override the Node version, or set 'false' to skip setting up Node and Pnpm."
runs:
Expand Down Expand Up @@ -65,7 +62,7 @@ runs:
ini-values: error_reporting=E_ALL, display_errors=On, zend.assertions=1
tools: composer:${{ steps.versions.outputs.composer-version }}
extensions: mysql, imagick
coverage: ${{ inputs.coverage }}
coverage: none

- name: Configure composer
if: steps.versions.outputs.php-version != 'false'
Expand Down
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;
52 changes: 38 additions & 14 deletions .github/files/e2e-tests/e2e-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,65 @@ const projects = [
project: 'Jetpack connection',
path: 'projects/plugins/jetpack/tests/e2e',
testArgs: [ 'specs/connection', '--retries=1' ],
targets: [ 'plugins/jetpack' ],
suite: '',
},
{
project: 'Jetpack pre-connection',
path: 'projects/plugins/jetpack/tests/e2e',
testArgs: [ 'specs/pre-connection', '--retries=1' ],
targets: [ 'plugins/jetpack', 'monorepo' ],
suite: '',
},
{
project: 'Jetpack post-connection',
path: 'projects/plugins/jetpack/tests/e2e',
testArgs: [ 'specs/post-connection', '--retries=1' ],
targets: [ 'plugins/jetpack' ],
suite: '',
},
{
project: 'Jetpack sync',
path: 'projects/plugins/jetpack/tests/e2e',
testArgs: [ 'specs/sync', '--retries=1' ],
targets: [ 'packages/sync' ],
suite: '',
},
{
project: 'Jetpack blocks',
path: 'projects/plugins/jetpack/tests/e2e',
testArgs: [ 'specs/blocks', '--retries=1' ],
targets: [ 'plugins/jetpack' ],
suite: '',
},
{
project: 'Boost',
path: 'projects/plugins/boost/tests/e2e',
testArgs: [],
targets: [ 'plugins/boost' ],
suite: '',
},
{
project: 'Search',
path: 'projects/plugins/search/tests/e2e',
testArgs: [],
targets: [ 'plugins/search' ],
suite: '',
},
{ project: 'Boost', path: 'projects/plugins/boost/tests/e2e', testArgs: [], suite: '' },
{ project: 'Search', path: 'projects/plugins/search/tests/e2e', testArgs: [], suite: '' },
{
project: 'VideoPress',
path: 'projects/plugins/videopress/tests/e2e',
testArgs: [],
targets: [ 'plugins/videopress' ],
suite: '',
},
{
project: 'Social',
path: 'projects/plugins/social/tests/e2e',
testArgs: [],
targets: [ 'plugins/social' ],
suite: '',
},
{ project: 'Social', path: 'projects/plugins/social/tests/e2e', testArgs: [], suite: '' },
];

const matrix = [];
Expand All @@ -53,18 +77,18 @@ switch ( process.env.GITHUB_EVENT_NAME ) {
);

for ( const project of projects ) {
const packageJson = JSON.parse( fs.readFileSync( `${ project.path }/package.json`, 'utf8' ) );
if ( ! project.targets ) {
// If no targets are defined, run the tests
matrix.push( project );
}

if ( packageJson?.ci?.targets?.length > 0 ) {
// iterate over defined target plugins/projects and see if they are changed
for ( const target of packageJson.ci.targets ) {
if ( Object.keys( changedProjects ).includes( target ) ) {
matrix.push( project );
break;
}
}
} else {
// if no targets are defined, run the tests
const targets = execSync(
`pnpm jetpack dependencies list --add-dependencies ${ project.targets.join( ' ' ) }`
)
.toString()
.split( '\n' );

if ( Object.keys( changedProjects ).some( target => targets.includes( target ) ) ) {
matrix.push( project );
}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/files/renovate-post-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [[ "$HOME" == "/" ]]; then
mkdir /var/tmp/home
export HOME=/var/tmp/home
fi
pnpm config set --location=user store-dir /tmp/renovate/cache/others/pnpm
pnpm config set --global store-dir /tmp/renovate/cache/others/pnpm
composer config --global cache-dir /tmp/renovate/cache/others/composer

# Do the pnpm and changelogger installs.
Expand Down
4 changes: 3 additions & 1 deletion .github/files/required-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- '!projects/js-packages/svelte-data-sync-client/**'
- '!projects/packages/wp-js-data-sync/**'
- '!projects/packages/backup/**'
- '!projects/packages/import/**'
- '!projects/packages/search/**'
- '!projects/packages/stats/**'
- '!projects/packages/stats-admin/**'
Expand All @@ -59,10 +60,11 @@
- avengers
- jetpack-approvers

# The Caribou team reviews changes to the Migration plugin,
# The Caribou team reviews changes to the Migration plugin and its Import package,
# and can add dependencies to the monorepo's lock file.
- name: Migration
paths:
- 'projects/packages/import/**'
- 'projects/plugins/migration/**'
- '!projects/plugins/*/composer.lock'
- '!projects/plugins/*/composer.json'
Expand Down
2 changes: 1 addition & 1 deletion .github/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PHP_VERSION=8.0
COMPOSER_VERSION=2.4.4
NODE_VERSION=18.13.0
PNPM_VERSION=7.9.2
PNPM_VERSION=7.27.1

# Other useful version numbers.
MIN_PHP_VERSION=5.6
Expand Down
36 changes: 15 additions & 21 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 All @@ -79,17 +78,6 @@ jobs:
pnpm jetpack build -v --no-pnpm-install --for-mirrors="$BUILD_BASE" "${PROJECTS[@]}"
fi
- name: Check for weird bug
run: |
if [[ ! -e "$BUILD_BASE/mirrors.txt" ]]; then
RERUN=
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
RERUN=" Please re-run the workflow, the bug seems intermittent."
fi
echo "::error::There's currently a strange bug where the build just exits (with a successful status) instead of completing. Investigation is ongoing.$RERUN"
exit 1
fi
- name: Filter mirror list for release branch
if: github.ref == 'refs/heads/prerelease' || contains( github.ref, '/branch-' )
run: .github/files/filter-mirrors-for-release-branch.sh
Expand Down Expand Up @@ -127,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
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ jobs:
test-report:
name: "Test report"
runs-on: ubuntu-latest
if: ${{ ! cancelled() }}
needs: [create-test-matrix, e2e-tests]
if: ${{ success() || failure() }}
needs: [e2e-tests]

steps:
- name: Set report context
Expand Down Expand Up @@ -234,8 +234,8 @@ jobs:
slack-notification:
name: "Slack notification"
runs-on: ubuntu-latest
if: ${{ ! cancelled() }} # need to run on failure and also on success, so it can send notifications when tests passed on re-runs
needs: [create-test-matrix, e2e-tests]
if: ${{ success() || failure() }}
needs: [e2e-tests]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
EXIT=0
mkdir artifacts
[[ "$TEST_SCRIPT" == "test-coverage" ]] && mkdir coverage
for P in composer.json projects/*/*/composer.json; do
if [[ "$P" == "composer.json" ]]; then
DIR="."
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
save-exact = true
prefer-workspace-packages = true
strict-peer-dependencies = true
use-lockfile-v6 = true
# Force node version
engine-strict = true

Expand Down
Loading

0 comments on commit ccb0b2a

Please sign in to comment.