From f6cb5400646eca9af8daf35f8db2546216e390c8 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:07:27 -0300 Subject: [PATCH 01/12] Automatically update wp-cli.md --- .github/workflows/build-docs.yml | 75 +++++++++++++++++++++++++++----- docs/wp-cli.md | 57 +----------------------- 2 files changed, 64 insertions(+), 68 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index a2cc0d7716..ff6c3d6e5f 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -1,28 +1,79 @@ -name: Build Hook Docs +name: Build Docs on: - push: - branches: - - master + push: + branches: + - master + pull_request: + branches: + - develop jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + with: + path: 'wp-content/plugins/elasticpress' + + - name: Set PHP version + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: prestissimo, composer:v1 + ini-values: memory_limit=3G + + - name: Start MySQL + run: | + sudo systemctl start mysql.service + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Install WP-CLI + run: | + curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar + chmod +x wp-cli.phar + sudo mv wp-cli.phar /usr/local/bin/wp + + - name: Install WordPress + run: | + wp core download + wp config create --dbname=wpclidocs --dbuser=root --dbpass=root --dbhost=127.0.0.1 + wp db create + wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com + wp plugin activate elasticpress + + - name: Generate WP-CLI Docs + run: | + wp package install felipeelia/cli-command-docs + wp cli-command-docs elasticpress --custom-order=index,activate-feature,deactivate-feature,list-features,get-algorithm-version,set-algorithm-version --remove=delete_transient_on_int,custom_get_transient --custom-intro='The following WP-CLI commands are supported by ElasticPress:' > wp-content/plugins/elasticpress/docs/wp-cli.md + - name: Use Node.js 10 uses: actions/setup-node@v1 with: node-version: '10.x' + - name: npm install, and build docs run: | - npm install - npm -g install gulp-cli - npm run build:docs + pushd wp-content/plugins/elasticpress + npm install + npm -g install gulp-cli + npm run build:docs + popd env: CI: true - - name: Deploy to GH Pages - uses: maxheld83/ghpages@v0.2.1 - env: - BUILD_DIR: 'docs-built/' - GH_PAT: ${{ secrets.GH_PAT }} + +# - name: Deploy to GH Pages +# uses: maxheld83/ghpages@v0.2.1 +# env: +# BUILD_DIR: 'docs-built/' +# GH_PAT: ${{ secrets.GH_PAT }} + + - name: Upload generated docs + uses: actions/upload-artifact@v2 + with: + name: docs-built + path: wp-content/plugins/elasticpress/docs-built/ diff --git a/docs/wp-cli.md b/docs/wp-cli.md index 2c7440defe..a36e364f2a 100644 --- a/docs/wp-cli.md +++ b/docs/wp-cli.md @@ -1,56 +1 @@ -The following WP-CLI commands are supported by ElasticPress: - -* `wp elasticpress index [--setup] [--network-wide] [--per-page] [--nobulk] [--offset] [--indexables] [--show-bulk-errors] [--post-type] [--include]` - - Index all posts in the current blog. - - * `--network-wide` will force indexing on all the blogs in the network. `--network-wide` takes an optional argument to limit the number of blogs to be indexed across where 0 is no limit. For example, `--network-wide=5` would limit indexing to only 5 blogs on the network. - * `--setup` will clear the index first and re-send the put mapping. - * `--per-page` let's you determine the amount of posts to be indexed per bulk index (or cycle). - * `--nobulk` let's you disable bulk indexing. - * `--offset` let's you skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). - * `--indexables` lets you specify the Indexable(s) which will be indexed. - * `--show-bulk-errors` displays the error message returned from Elasticsearch when a post fails to index (as opposed to just the title and ID of the post). - * `--post-type` let's you specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma. - * `--include` Choose which object IDs to include in the index. - * `--post-ids` Choose which post_ids to include when indexing the Posts Indexable (deprecated). - * `--upper-limit-object-id` Upper limit of a range of IDs to be indexed. If indexing IDs from 30 to 45, this should be 45. - * `--lower-limit-object-id` Lower limit of a range of IDs to be indexed. If indexing IDs from 30 to 45, this should be 30. - -* `wp elasticpress delete-index [--network-wide]` - - Deletes the current Indexables indices. `--network-wide` will force every index on the network to be deleted. - -* `wp elasticpress put-mapping [--network-wide] [--indexables]` - - Sends plugin put mapping to the current Indexables indices (this will delete the indices). `--network-wide` will force mappings to be sent for every index in the network. - -* `wp elasticpress recreate-network-alias` - - Recreates the alias index which points to every index in the network. - -* `wp elasticpress activate-feature ` - - Activate a feature. If a re-indexing is required, you will need to do it manually. - -* `wp elasticpress deactivate-feature ` - - Deactivate a feature. - -* `wp elasticpress list-features [--all]` - - Lists active features. `--all` will show all registered features. - -* `wp elasticpress stats` - - Returns basic stats on Elasticsearch instance i.e. number of documents in current index as well as disk space used. - -* `wp elasticpress status` - -* `wp elasticpress get-indexes` - - Get all index names as json. - -* `wp elasticpress get-cluster-indexes` - - Return all indexes from the cluster as json. \ No newline at end of file +This file is automatically generated. \ No newline at end of file From ecd02862e331719b6ceb6dfdb4303986fdf873ba Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:16:14 -0300 Subject: [PATCH 02/12] Check dir used to install WP --- .github/workflows/build-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index ff6c3d6e5f..06b4ee04b6 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -40,6 +40,7 @@ jobs: - name: Install WordPress run: | + pwd wp core download wp config create --dbname=wpclidocs --dbuser=root --dbpass=root --dbhost=127.0.0.1 wp db create From 47aba5c088aac770cc58cbb63f16ad4653b3858b Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:20:47 -0300 Subject: [PATCH 03/12] Debug GH Workspace vars --- .github/workflows/build-docs.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 06b4ee04b6..82f72570f3 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -12,10 +12,30 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Print github workspace + run: | + echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" + echo "github.workspace = ${{ github.workspace }}" + echo "pr.ref = ${{github.event.pull_request.head.ref}}" + echo "github.ref = ${{ github.ref }}" + echo "$GITHUB_CONTEXT" + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + - uses: actions/checkout@v1 with: path: 'wp-content/plugins/elasticpress' + - name: Print github workspace (again) + run: | + echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" + echo "github.workspace = ${{ github.workspace }}" + echo "pr.ref = ${{github.event.pull_request.head.ref}}" + echo "github.ref = ${{ github.ref }}" + echo "$GITHUB_CONTEXT" + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + - name: Set PHP version uses: shivammathur/setup-php@v2 with: @@ -40,7 +60,6 @@ jobs: - name: Install WordPress run: | - pwd wp core download wp config create --dbname=wpclidocs --dbuser=root --dbpass=root --dbhost=127.0.0.1 wp db create From af6b6f1bffc043b31f7b078d8608274126b0c425 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:25:05 -0300 Subject: [PATCH 04/12] Go back to the right dir --- .github/workflows/build-docs.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 82f72570f3..60297e1575 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -12,29 +12,13 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Print github workspace - run: | - echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" - echo "github.workspace = ${{ github.workspace }}" - echo "pr.ref = ${{github.event.pull_request.head.ref}}" - echo "github.ref = ${{ github.ref }}" - echo "$GITHUB_CONTEXT" - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - - uses: actions/checkout@v1 with: path: 'wp-content/plugins/elasticpress' - - name: Print github workspace (again) + - name: Go back to the workspace directory run: | - echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" - echo "github.workspace = ${{ github.workspace }}" - echo "pr.ref = ${{github.event.pull_request.head.ref}}" - echo "github.ref = ${{ github.ref }}" - echo "$GITHUB_CONTEXT" - env: - GITHUB_CONTEXT: ${{ toJson(github) }} + cd ../../.. - name: Set PHP version uses: shivammathur/setup-php@v2 From 9195cb0ac5cf0b4aa4350c9ec66a31869b62e726 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:31:58 -0300 Subject: [PATCH 05/12] Another try to reset workspace path --- .github/workflows/build-docs.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 60297e1575..84bd35b633 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -12,13 +12,17 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Backup wordspace path + run: | + $GITHUB_WORKSPACE_ORIG = $GITHUB_WORKSPACE + - uses: actions/checkout@v1 with: path: 'wp-content/plugins/elasticpress' - - name: Go back to the workspace directory + - name: Reset wordspace path run: | - cd ../../.. + $GITHUB_WORKSPACE = $GITHUB_WORKSPACE_ORIG - name: Set PHP version uses: shivammathur/setup-php@v2 @@ -44,6 +48,7 @@ jobs: - name: Install WordPress run: | + pwd wp core download wp config create --dbname=wpclidocs --dbuser=root --dbpass=root --dbhost=127.0.0.1 wp db create From 6c529cc82fca36d2b816e32b2ec33a3844f725a2 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:34:32 -0300 Subject: [PATCH 06/12] Fix syntax --- .github/workflows/build-docs.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 84bd35b633..2895afbb86 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -13,16 +13,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Backup wordspace path - run: | - $GITHUB_WORKSPACE_ORIG = $GITHUB_WORKSPACE + run: echo "::set-env name=GITHUB_WORKSPACE_ORIG::$GITHUB_WORKSPACE" - uses: actions/checkout@v1 with: path: 'wp-content/plugins/elasticpress' - name: Reset wordspace path - run: | - $GITHUB_WORKSPACE = $GITHUB_WORKSPACE_ORIG + run: echo "::set-env name=GITHUB_WORKSPACE::$GITHUB_WORKSPACE_ORIG" - name: Set PHP version uses: shivammathur/setup-php@v2 From d77e44f2d1dbf758f3cc8f21e21ee94178f40955 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:37:57 -0300 Subject: [PATCH 07/12] Go up when calling wp-cli --- .github/workflows/build-docs.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 2895afbb86..0e40c51b6f 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -12,16 +12,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Backup wordspace path - run: echo "::set-env name=GITHUB_WORKSPACE_ORIG::$GITHUB_WORKSPACE" - uses: actions/checkout@v1 with: path: 'wp-content/plugins/elasticpress' - - name: Reset wordspace path - run: echo "::set-env name=GITHUB_WORKSPACE::$GITHUB_WORKSPACE_ORIG" - - name: Set PHP version uses: shivammathur/setup-php@v2 with: @@ -46,7 +41,7 @@ jobs: - name: Install WordPress run: | - pwd + cd ../../.. wp core download wp config create --dbname=wpclidocs --dbuser=root --dbpass=root --dbhost=127.0.0.1 wp db create @@ -55,6 +50,7 @@ jobs: - name: Generate WP-CLI Docs run: | + cd ../../.. wp package install felipeelia/cli-command-docs wp cli-command-docs elasticpress --custom-order=index,activate-feature,deactivate-feature,list-features,get-algorithm-version,set-algorithm-version --remove=delete_transient_on_int,custom_get_transient --custom-intro='The following WP-CLI commands are supported by ElasticPress:' > wp-content/plugins/elasticpress/docs/wp-cli.md @@ -65,11 +61,9 @@ jobs: - name: npm install, and build docs run: | - pushd wp-content/plugins/elasticpress - npm install - npm -g install gulp-cli - npm run build:docs - popd + npm install + npm -g install gulp-cli + npm run build:docs env: CI: true @@ -83,4 +77,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: docs-built - path: wp-content/plugins/elasticpress/docs-built/ + path: docs-built/ From e385a8ce26151c5ff44950c7b3e9804427a96dd8 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Sat, 25 Sep 2021 18:40:23 -0300 Subject: [PATCH 08/12] Fix cli-command-docs version --- .github/workflows/build-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 0e40c51b6f..9a69064d6b 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -51,7 +51,7 @@ jobs: - name: Generate WP-CLI Docs run: | cd ../../.. - wp package install felipeelia/cli-command-docs + wp package install felipeelia/cli-command-docs:dev-trunk wp cli-command-docs elasticpress --custom-order=index,activate-feature,deactivate-feature,list-features,get-algorithm-version,set-algorithm-version --remove=delete_transient_on_int,custom_get_transient --custom-intro='The following WP-CLI commands are supported by ElasticPress:' > wp-content/plugins/elasticpress/docs/wp-cli.md - name: Use Node.js 10 From 3e9e3db961bfb6324bef3349ad963008e0f64110 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Mon, 4 Oct 2021 11:20:21 -0300 Subject: [PATCH 09/12] WP-CLI Automatic Docs changes - Remove executions on PRs - Remove artifact creation - Uncomment deployment to GH Pages --- .github/workflows/build-docs.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 9a69064d6b..9e18d6fc63 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - develop jobs: build: @@ -67,14 +64,8 @@ jobs: env: CI: true -# - name: Deploy to GH Pages -# uses: maxheld83/ghpages@v0.2.1 -# env: -# BUILD_DIR: 'docs-built/' -# GH_PAT: ${{ secrets.GH_PAT }} - - - name: Upload generated docs - uses: actions/upload-artifact@v2 - with: - name: docs-built - path: docs-built/ + - name: Deploy to GH Pages + uses: maxheld83/ghpages@v0.2.1 + env: + BUILD_DIR: 'docs-built/' + GH_PAT: ${{ secrets.GH_PAT }} \ No newline at end of file From 94ad0a39b4943798d18f10ac42edf79bb7ecddc8 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 5 Oct 2021 08:51:51 -0300 Subject: [PATCH 10/12] Check if query is using elasticsearch on testSearchAllowedMimeType --- tests/php/features/TestDocuments.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/php/features/TestDocuments.php b/tests/php/features/TestDocuments.php index 72d887df26..c96790614f 100644 --- a/tests/php/features/TestDocuments.php +++ b/tests/php/features/TestDocuments.php @@ -92,6 +92,7 @@ public function testSearchAllowedMimeType() { ); $query = new \WP_Query( $args ); + $this->assertTrue( $query->elasticsearch_success ); $this->assertEquals( 1, count( $query->posts ) ); } From 59225b4197bff5fba14affe5422d78be6334b14f Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 5 Oct 2021 08:53:48 -0300 Subject: [PATCH 11/12] Check if query is using elasticsearch on testSearchDisallowedMimeType --- tests/php/features/TestDocuments.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/php/features/TestDocuments.php b/tests/php/features/TestDocuments.php index c96790614f..1d6ffa503f 100644 --- a/tests/php/features/TestDocuments.php +++ b/tests/php/features/TestDocuments.php @@ -138,6 +138,7 @@ public function testSearchDisallowedMimeType() { $query = new \WP_Query( $args ); + $this->assertTrue( $query->elasticsearch_success ); $this->assertEquals( 0, count( $query->posts ) ); } From 262085a3fc7966d5ae9b5054220bce46fa3f1ed5 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 5 Oct 2021 08:54:48 -0300 Subject: [PATCH 12/12] Check if query is using elasticsearch on testSearchNormalPost --- tests/php/features/TestDocuments.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/php/features/TestDocuments.php b/tests/php/features/TestDocuments.php index 1d6ffa503f..c1fc3bceb1 100644 --- a/tests/php/features/TestDocuments.php +++ b/tests/php/features/TestDocuments.php @@ -188,6 +188,7 @@ public function testSearchNormalPost() { $query = new \WP_Query( $args ); + $this->assertTrue( $query->elasticsearch_success ); $this->assertEquals( 1, count( $query->posts ) ); } }