Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a skeleton of wpcomsh to experiment with running tests. #35792

Closed
wants to merge 13 commits into from
Closed
10 changes: 10 additions & 0 deletions .github/files/generate-ci-matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
'with-woocommerce' => true,
);

// Add WooCommerce tests.
$matrix[] = array(
'name' => 'PHP tests: PHP 7.4 WP latest with WPCOMSH',
Comment on lines +92 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Add WooCommerce tests.
$matrix[] = array(
'name' => 'PHP tests: PHP 7.4 WP latest with WPCOMSH',
// Add wpcomsh tests.
$matrix[] = array(
'name' => 'PHP tests: PHP 8.1 WP latest with WPCOMSH',

'script' => 'test-php',
'php' => '8.1',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can avoid hard-coding 8.1 here, to avoid having to remember to update this in the future when Atomic's minimum PHP version changes.

Might it make sense to read wpcomsh's composer.json for .require.php, which I think will probably be ">=8.1", and strip out the ">=" to determine the version to use?

'wp' => 'latest',
'timeout' => 20,
'with-wpcomsh' => true,
);

// Add JS tests.
$matrix[] = array(
'name' => 'JS tests',
Expand Down
10 changes: 10 additions & 0 deletions .github/files/setup-wordpress-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ if [[ "$WITH_WOOCOMMERCE" == true ]]; then
echo "::endgroup::"
fi

# Install WooCommerce plugin used for some Jetpack integration tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Install WooCommerce plugin used for some Jetpack integration tests.
# Install wpcomsh plugin used for some Jetpack integration tests.

if [[ "$WITH_WPCOMSH" == true ]]; then
echo "::group::Installing wpcomsh into WordPress"

mkdir "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins"
cp -r "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh/src" "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins/wpcomsh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. If we need to move it into mu-plugins at all, it should probably be like this

Suggested change
cp -r "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh/src" "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins/wpcomsh"
cp -r "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh" "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins/wpcomsh"


echo "::endgroup::"
fi

cd "/tmp/wordpress-$WP_BRANCH"

cp wp-tests-config-sample.php wp-tests-config.php
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
NODE_VERSION: ${{ matrix.node }}
MONOREPO_BASE: ${{ github.workspace }}
WITH_WOOCOMMERCE: ${{ matrix.with-woocommerce }}
WITH_WPCOMSH: ${{ matrix.with-wpcomsh }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you need something below around line 86 as well?

strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Added ability to test Jetpack together with wpcomsh.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/tests/action-test-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ if [[ "$WITH_WOOCOMMERCE" == true ]]; then
exit 0
fi

if [[ "$WITH_WPCOMSH" == true ]]; then
export JETPACK_TEST_WPCOMSH=1
fi

echo "::group::Jetpack tests"
phpunit
echo "::endgroup::"
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/tests/php/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ function _manually_load_plugin() {
if ( '1' === getenv( 'JETPACK_TEST_WOOCOMMERCE' ) ) {
require JETPACK_WOOCOMMERCE_INSTALL_DIR . '/woocommerce.php';
}

if ( '1' === getenv( 'JETPACK_TEST_WPCOMSH' ) ) {
require __DIR__ . '/../../../../mu-plugins/wpcomsh/wpcomsh.php';
}
require __DIR__ . '/../../jetpack.php';
$jetpack = Jetpack::init();
$jetpack->configure();
Expand Down
15 changes: 15 additions & 0 deletions projects/plugins/wpcomsh/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Files not needed to be distributed in the package.
.gitattributes export-ignore
.github/ export-ignore
package.json export-ignore

# Files to include in the mirror repo, but excluded via gitignore
# Remember to end all directories with `/**` to properly tag every file.
# /src/js/example.min.js production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
.gitignore production-exclude
changelog/** production-exclude
phpunit.xml.dist production-exclude
tests/** production-exclude
2 changes: 2 additions & 0 deletions projects/plugins/wpcomsh/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
node_modules/
7 changes: 7 additions & 0 deletions projects/plugins/wpcomsh/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

24 changes: 24 additions & 0 deletions projects/plugins/wpcomsh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# wpcomsh

A helper for connecting WordPress.com sites to external host infrastructure.

## How to install wpcomsh

### Installation From Git Repo

## Contribute

## Get Help

## Using this package in your WordPress plugin

If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

## Security

Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).

## License

wpcomsh is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)

Empty file.
4 changes: 4 additions & 0 deletions projects/plugins/wpcomsh/changelog/initial-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Initial version.
51 changes: 51 additions & 0 deletions projects/plugins/wpcomsh/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "automattic/jetpack-wpcomsh",
"description": "A helper for connecting WordPress.com sites to external host infrastructure.",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {},
"require-dev": {
"yoast/phpunit-polyfills": "1.1.0",
"automattic/jetpack-changelogger": "@dev",
"automattic/wordbless": "dev-master"
},
"autoload": {
"classmap": [
"src/"
]
},
"scripts": {
"phpunit": [
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-php": [
"@composer phpunit"
],
"build-production": "echo 'Add your build step to composer.json, please!'",
"build-development": "echo 'Add your build step to composer.json, please!'",
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy"
},
"repositories": [
{
"type": "path",
"url": "../../packages/*",
"options": {
"monorepo": true
}
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"roots/wordpress-core-installer": true
}
},
"extra": {
"release-branch-prefix": "wpcomsh",
"changelogger": {
"versioning": "semver"
}
}
}
25 changes: 25 additions & 0 deletions projects/plugins/wpcomsh/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"private": true,
"name": "@automattic/jetpack-wpcomsh",
"version": "0.1.0-alpha",
"description": "A helper for connecting WordPress.com sites to external host infrastructure.",
"homepage": "https://jetpack.com",
"bugs": {
"url": "https://github.com/Automattic/jetpack/labels/[Plugin] Wpcomsh"
},
"repository": {
"type": "git",
"url": "https://github.com/Automattic/jetpack.git",
"directory": "projects/plugins/wpcomsh"
},
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "echo 'Not implemented.'",
"build-js": "echo 'Not implemented.'",
"build-production": "echo 'Not implemented.'",
"build-production-js": "echo 'Not implemented.'",
"clean": "true"
},
"devDependencies": {}
}
14 changes: 14 additions & 0 deletions projects/plugins/wpcomsh/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<phpunit bootstrap="tests/php/bootstrap.php" backupGlobals="false" colors="true" convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="main">
<directory prefix="test" suffix=".php">tests/php</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<!-- Better to only include "src" than to add "." and then exclude "tests", "vendor", and so on, as PHPUnit still scans the excluded directories. -->
<!-- Add additional lines for any files or directories outside of src/ that need coverage. -->
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
56 changes: 56 additions & 0 deletions projects/plugins/wpcomsh/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
== Description ==

Longer description of the plugin.

== Installation ==

Installation instructions go here.

== Frequently Asked Questions ==

= A question that someone might have =

An answer to that question.

== Screenshots ==

1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
(or jpg, jpeg, gif).
2. This is the second screen shot

== Changelog ==

<!-- When you do a release, use the monorepo script tools/plugin-changelog-to-readme.sh to copy from CHANGELOG.md to here. -->

== Arbitrary section ==

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.

== A brief Markdown Example ==

Ordered list:

1. Some feature
1. Another feature
1. Something else about the plugin

Unordered list:

* something
* something else
* third thing

Here's a link to [WordPress](https://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax].
Titles are optional, naturally.

[markdown syntax]: http://daringfireball.net/projects/markdown/syntax
"Markdown is what the parser uses to process much of the readme file"

Markdown uses email style notation for blockquotes and I've been told:
> Asterisks for *emphasis*. Double it up for **strong**.

`<?php code(); // goes in backticks ?>`
8 changes: 8 additions & 0 deletions projects/plugins/wpcomsh/src/example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Put your classes in this `src` folder!
*
* @package automattic/PACKAGE-NAME
*/

// Start your code here!
Loading
Loading