Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
28b08ce
Reorganize tests to be PSR4 compliant
vaurdan Jul 9, 2024
ce7e72e
Remove unnecessary imports
vaurdan Jul 9, 2024
73a62e6
Enable composer autoload for the source files
vaurdan Jul 9, 2024
c1c0821
Require utils file in the tests bootstrap file
vaurdan Jul 9, 2024
0a023a5
Testing build step
vaurdan Jul 9, 2024
fcc0e91
Making it run on PR
vaurdan Jul 9, 2024
d81d94b
Bypass commit hooks when committing to built branch
vaurdan Jul 9, 2024
0cb7da7
Include `vendor/` explicity on `git add` since it's on the gitignore …
vaurdan Jul 9, 2024
450d159
Add Tag and Release step
vaurdan Jul 9, 2024
722e6ea
Fix yaml issue
vaurdan Jul 10, 2024
8bea53a
Another fix
vaurdan Jul 10, 2024
4357bef
Pull and merge built branch.
vaurdan Jul 10, 2024
7c2d260
--no-verify the commit
vaurdan Jul 10, 2024
6de004f
Better handling of the fetch logic
vaurdan Jul 10, 2024
5878f61
Add the vendor/ directory before commit
vaurdan Jul 10, 2024
3b9a15c
Fix typo
vaurdan Jul 10, 2024
106b598
Fix branch name
vaurdan Jul 10, 2024
48af0c0
Fix typo in the tag and release step
vaurdan Jul 10, 2024
07a86d5
Change the order of the steps
vaurdan Jul 10, 2024
c6c8eae
Add some debug info
vaurdan Jul 10, 2024
d8f48ff
Add some debug info
vaurdan Jul 10, 2024
257f5d9
Change source branch name
vaurdan Jul 10, 2024
e422046
Another merge test
vaurdan Jul 10, 2024
aa66580
Another test with GITHUB_REF
vaurdan Jul 10, 2024
674b7c0
Fetch GITHUB_REF before merging
vaurdan Jul 10, 2024
077f9fe
Try a different approach
vaurdan Jul 10, 2024
9ca66bd
Another approach
vaurdan Jul 10, 2024
2571d2b
Configure git before merge
vaurdan Jul 10, 2024
f23ef76
Check if built branch exists
vaurdan Jul 10, 2024
34fff66
Tag the built commit with the version
vaurdan Jul 10, 2024
3f7f32a
Fix extract changelog script
vaurdan Jul 10, 2024
f93fbd7
Use different create-release action
vaurdan Jul 10, 2024
c5b52dd
Change commit message
vaurdan Jul 10, 2024
d0bc973
Fix issue with var interpolation
vaurdan Jul 10, 2024
af845a6
Add deploy to wporg job
vaurdan Jul 10, 2024
735726e
Fix checkout param
vaurdan Jul 10, 2024
071aaeb
Improve relibility of the extract changelog step
vaurdan Jul 10, 2024
a7e9ea0
Fix how version number is shared across jobs
vaurdan Jul 10, 2024
8fd7f12
Fix .zip upload to the release
vaurdan Jul 10, 2024
98ff494
Change the WP.org version tag to a test one
vaurdan Jul 10, 2024
6f9d435
Mock change to see if the built branch is properly updated.
vaurdan Jul 11, 2024
6d079ef
Change order of the checkout built branch step
vaurdan Jul 11, 2024
5096e73
Trying git merge with squash
vaurdan Jul 11, 2024
2c4602a
Fix deprecated set-output
vaurdan Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
name: TEST Build and Deploy
on:
workflow_dispatch: null
pull_request: null
jobs:
build:
name: Build and Commit
runs-on: ubuntu-20.04
steps:
- name: Checkout the specific branch/ref
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Fetch and checkout built-test branch
run: |
if git ls-remote --exit-code origin built-test; then
git fetch origin built-test
git checkout built-test
git pull origin built-test
else
git checkout -b built-test develop
fi

- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Merge current branch into built-test
run: |
git merge --squash $GITHUB_SHA
git commit -m "Merge $GITHUB_SHA into built-test" --no-verify

- name: Get list of changed files
run: |
git status -s

- name: Read .nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm

- name: Build
run: |
npm ci
npm run build
composer install --no-dev --optimize-autoloader --classmap-authoritative

- name: Get list of changed files
run: |
git status -s

- name: Commit built files
run: |
git add -Af vendor/
git status -s
VERSION=$(jq -r .version < package.json)
git commit -m "Build plugin v$VERSION (${{ github.ref_name }})" --no-verify
git push origin built-test

tag_and_release:
name: Tag and Release
needs: build
runs-on: ubuntu-20.04
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
with:
ref: built-test
fetch-depth: 0

- name: Get version from package.json
id: get_version
run: |
VERSION=$(jq -r .version < package.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "The version is $VERSION"

- name: Tag the commit
run: |
git tag test-${{ env.VERSION }}
git push origin test-${{ env.VERSION }}

- name: Extract Changelog
id: extract_changelog
run: |
set -e
VERSION=${{ env.VERSION }}
START_LINE=$(grep -n "## \[${VERSION}\]" CHANGELOG.md | cut -d: -f1)
if [ -z "$START_LINE" ]; then
echo "Version not found in CHANGELOG.md" >&2
exit 1
fi
TAIL_LINE=$(tail -n +$((START_LINE + 1)) CHANGELOG.md | grep -n "^## " | head -n 1 | cut -d: -f1 || true)
if [ -z "$TAIL_LINE" ]; then
END_LINE=$(wc -l < CHANGELOG.md)
else
END_LINE=$((START_LINE + TAIL_LINE - 1))
fi
sed -n "${START_LINE},${END_LINE}p" CHANGELOG.md | sed '$d' > release_notes.md
cat release_notes.md
shell: bash

- name: Format Changelog
id: format_changelog
run: |
sed -i '1d' release_notes.md # Remove the first line
sed -i 's/###/##/g' release_notes.md # Change headers from ### to ##
shell: bash

- name: Create a GitHub release
id: github_release
uses: ncipollo/release-action@v1
with:
tag: test-${{ env.VERSION }}
name: ${{ env.VERSION }}
bodyFile: ./release_notes.md
draft: true
prerelease: true

deploy:
name: Deploy to WordPress.org
needs: tag_and_release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
ref: test-${{ needs.tag_and_release.outputs.VERSION }}

- name: WordPress Plugin Deploy
id: wporg_deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: true
generate-zip: true
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
VERSION: test-${{ needs.tag_and_release.outputs.VERSION }}

- name: Print ZIP file path
run: |
echo "ZIP file path: ${{ steps.wporg_deploy.outputs.zip-path }}"

- name: Update release with ZIP file
uses: ncipollo/release-action@v1
with:
tag: test-${{ needs.tag_and_release.outputs.VERSION }}
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
removeArtifacts: true
updateOnlyUnreleased: true
artifacts: ${{ steps.wporg_deploy.outputs.zip-path }}
artifactContentType: application/zip
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
run: |
npm ci
npm run build
composer dump-autoload --classmap-authoritative
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@stable
env:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Refresh Composer autoload files
run: composer dump-autoload --classmap-authoritative

- name: Use desired version of NodeJS
uses: actions/setup-node@v4.0.2
with:
Expand Down
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'a741adf6df6b723b2f3d');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'cdeb35cda9a85c94d603');
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
"autoload": {
"classmap": [
"src/"
],
"files": [
"wp-parsely.php"
]
},
"autoload-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export function TopPosts(): React.JSX.Element {
* @param {Object} props The filter properties.
*/
const trackFilterChanges = ( filter: string, props: object ): void => {
console.log( 'test' ); // eslint-disable-line no-console
console.log( 'another change' ); // eslint-disable-line no-console
Telemetry.trackEvent( 'dash_widget_filter_changed', { filter, ...props } );
};

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Blocks/RecommendationsBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

declare(strict_types=1);

namespace Parsely\Tests\Blocks;
namespace Parsely\Tests\Integration\Blocks;

use Parsely\Recommendations_Block;
use Parsely\Tests\Integration\TestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

declare(strict_types=1);

namespace Parsely\Tests\ContentHelper;
namespace Parsely\Tests\Integration\ContentHelper;

use Parsely\Content_Helper\Dashboard_Widget;
use Parsely\Parsely;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

declare(strict_types=1);

namespace Parsely\Tests\ContentHelper;
namespace Parsely\Tests\Integration\ContentHelper;

use Parsely\Content_Helper\Editor_Sidebar;
use Parsely\Parsely;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

declare(strict_types=1);

namespace Parsely\Tests\ContentHelper;
namespace Parsely\Tests\Integration\ContentHelper;

use Parsely\Tests\Integration\TestCase;
use Parsely\Content_Helper\Content_Helper_Feature;
use Parsely\Tests\Integration\TestCase;

/**
* Base class for all Content Helper feature integration tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

declare(strict_types=1);

namespace Parsely\Tests\ContentHelper;
namespace Parsely\Tests\Integration\ContentHelper;

use Mockery;
use Parsely\Content_Helper\Post_List_Stats;
use Parsely\Parsely;
use Parsely\RemoteAPI\Analytics_Posts_API;
use Parsely\Tests\ContentHelper\ContentHelperFeatureTest;
use Parsely\Tests\Integration\TestCase;
use WP_Error;
use WP_Post;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\Proxy;

use Parsely\Endpoints\Analytics_Posts_API_Proxy;
use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Parsely;
use Parsely\RemoteAPI\Analytics_Posts_API;
use Parsely\Tests\Integration\TestCase;
use WP_Error;
use WP_REST_Request;

use function Parsely\Utils\get_date_format;

/**
* Integration Tests for the Analytics Posts API Proxy Endpoint.
*/
final class AnalyticsPostsProxyEndpointTest extends ProxyEndpointTest {
final class AnalyticsPostsProxyEndpointTest extends BaseProxyEndpointTest {

/**
* Initializes all required values for the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\Proxy;

use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Endpoints\User_Meta\Base_Endpoint_User_Meta;
use Parsely\Parsely;
use Parsely\Tests\Integration\TestCase;
use WP_Error;
use WP_REST_Request;
use WP_REST_Server;
Expand All @@ -22,7 +23,7 @@
*
* @phpstan-import-type Parsely_Options from Parsely
*/
abstract class ProxyEndpointTest extends TestCase {
abstract class BaseProxyEndpointTest extends TestCase {

/**
* Holds a reference to the global $wp_rest_server object to restore in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\Proxy;

use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Endpoints\Referrers_Post_Detail_API_Proxy;
use Parsely\Parsely;
use Parsely\RemoteAPI\Referrers_Post_Detail_API;
use Parsely\Tests\Integration\TestCase;
use WP_REST_Request;

/**
* Integration Tests for the Referrers Post Detail API Proxy Endpoint.
*/
final class ReferrersPostDetailProxyEndpointTest extends ProxyEndpointTest {
final class ReferrersPostDetailProxyEndpointTest extends BaseProxyEndpointTest {

/**
* Initializes all required values for the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\Proxy;

use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Endpoints\Related_API_Proxy;
use Parsely\Parsely;
use Parsely\RemoteAPI\Related_API;
use Parsely\Tests\Integration\TestCase;
use WP_REST_Request;

/**
* Integration Tests for the Related API Proxy Endpoint.
*/
final class RelatedProxyEndpointTest extends ProxyEndpointTest {
final class RelatedProxyEndpointTest extends BaseProxyEndpointTest {

/**
* Initializes all required values for the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\Proxy;

use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Endpoints\Analytics_Post_Detail_API_Proxy;
use Parsely\Endpoints\Base_API_Proxy;
use Parsely\Parsely;
use Parsely\RemoteAPI\Analytics_Post_Detail_API;
use Parsely\Tests\Integration\TestCase;
use WP_REST_Request;

/**
* Integration Tests for the Stats Post Detail API Proxy Endpoint.
*/
final class StatsPostDetailProxyEndpointTest extends ProxyEndpointTest {
final class StatsPostDetailProxyEndpointTest extends BaseProxyEndpointTest {

/**
* Initializes all required values for the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;
namespace Parsely\Tests\Integration\Endpoints\UserMeta;

use Parsely\Tests\Integration\Endpoints\Proxy\BaseProxyEndpointTest;
use WP_REST_Request;

/**
* Base class for all User Meta endpoint tests.
*
* @since 3.13.0
*/
abstract class BaseUserMetaEndpointTest extends ProxyEndpointTest {
abstract class BaseUserMetaEndpointTest extends BaseProxyEndpointTest {
/**
* The endpoint's default value.
*
Expand Down
Loading