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

Boilerplate #4

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Set up boilerplate (config, tests, etc)
  • Loading branch information
kevinfodness committed Mar 29, 2022
commit 3cbf021a90c7feacf3760eda2367c6cdd7308171
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 4

[*.{json,yaml,yml}]
indent_style = space
indent_size = 2

# Dotfiles
[.*]
indent_style = space
indent_size = 2
101 changes: 101 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Linting

on:
pull_request:

jobs:
PHPCompatibility:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['8.1', '8.0', '7.4']

name: PHPCompatibility
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none

- name: Install composer dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install

- name: PHPCompatibility for ${{ matrix.php }}
run: composer phpcs -- --standard=PHPCompatibility --extensions=php --runtime-set testVersion ${{ matrix.php }} --ignore="/vendor/*"

coding-standards:
runs-on: ubuntu-latest
strategy:
fail-fast: true

name: Coding Standards
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none

- name: Install composer dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install

- name: Coding standards
run: composer phpcs
83 changes: 83 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Unit Tests

on:
pull_request:

jobs:
tests:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.can_fail }}
strategy:
fail-fast: true
matrix:
wp_version: ["latest"]
can_fail: [false]
multisite: [0,1]

name: phpunit 7.4 @ WP ${{ matrix.wp_version }} WP_MULTISITE=${{ matrix.multisite }}
env:
CACHEDIR: /tmp/test-cache
WP_CORE_DIR: /tmp/wordpress/
WP_VERSION: ${{ matrix.wp_version }}
WP_MULTISITE: ${{ matrix.multisite }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: |
${{ steps.composer-cache.outputs.dir }}
/tmp/test-cache
/tmp/wordpress
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none

- name: Validate Composer
run: composer validate --strict

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install

- name: Install WordPress and Copy Project
shell: bash
run: |
bash bin/install-wp-tests.sh wordpress_unit_tests root '' 127.0.0.1 $WP_VERSION
# Go into the core directory and replace wp-content.
# mkdir -p ${WP_CORE_DIR}/wp-content/plugins/elasticsearch-extensions
rm -rf ${WP_CORE_DIR}/wp-content/plugins/elasticsearch-extensions
rsync -aWq --no-compress . ${WP_CORE_DIR}/wp-content/plugins/elasticsearch-extensions
- name: Test Plugin
shell: bash
run: |
cd ${WP_CORE_DIR}/wp-content/plugins/elasticsearch-extensions
composer phpunit
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ignore temporary OS files
.DS_Store
.DS_Store?
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDEs
.idea
.vscode

# Composer dependencies
/vendor

# Cache
.phpcs.json
51 changes: 51 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" name="Elasticsearch Extensions" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>PHP_CodeSniffer standard for Elasticsearch Extensions.</description>

<!-- Include Alley Rules -->
<rule ref="Alley-Interactive"/>

<!-- Set the text domain for i18n. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="elasticsearch-extensions"/>
</properties>
</rule>

<!-- Set the prefixes for functions etc. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="elasticsearch_extensions"/>
</properties>
</rule>

<!--
Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<arg value="ps"/>

<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value=".phpcs.json"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>

<!-- Set severity to 1 to see everything that isn't effectively turned off. -->
<arg name="severity" value="1"/>

<!-- Exclude a few directories and autogenerated files. -->
<exclude-pattern>vendor/</exclude-pattern>

<!-- The adapter pattern relies on several files exporting the same class name. -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>adapters/</exclude-pattern>
kevinfodness marked this conversation as resolved.
Show resolved Hide resolved
</rule>

<!-- The version set here matches the minimum version tested in buddy.yml. -->
<config name="minimum_supported_wp_version" value="5.9"/>
</ruleset>
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Elasticsearch Extensions

A WordPress plugin to make integrating sites with Elasticsearch easier.
Seamlessly and automatically integrates with different Elasticsearch plugins.
Simplifies common Elasticsearch operations like adding faceted search and
filtering indexable post types, taxonomies, and postmeta in an
implementation-agnostic way.

## Supported Adapters

* [VIP Enterprise Search](https://docs.wpvip.com/how-tos/vip-search/)

## Usage

Install and activate the plugin to have it interface with an existing installed
Elasticsearch plugin. This plugin will automatically detect which supported
Elasticsearch plugin is in use, and will register the appropriate hooks.
kevinfodness marked this conversation as resolved.
Show resolved Hide resolved

Customize the Elasticsearch integration using filter hooks in your site's
theme. A full list of available filter hooks is
[available in the wiki](https://github.com/alleyinteractive/elasticsearch-extensions/wiki).
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "alleyinteractive/elasticsearch-extensions",
"description": "Elasticsearch Extensions",
"type": "project",
"authors": [
{
"name": "Alley",
"email": "[email protected]"
}
],
"require-dev": {
"alleyinteractive/alley-coding-standards": "^0.3.0",
"phpunit/phpunit": "7.5.*",
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
"phpcbf": "phpcbf .",
"phpcs": "phpcs .",
"phpunit": "phpunit",
"setup": [
"composer install"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading