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

epic: mvp index #3

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
43 changes: 43 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.git
.github
.idea
.husky
.vscode
bin
client
tests
node_modules
vendor
.composer
.distignore
.editorconfig
.env
.env.example
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.npmrc
.nvmrc
.php-cs-fixer.cache
.php-cs-fixer.php
.php-cs-fixer.dist.php
.prettierignore
.prettierrc.js
.stylelintignore
babel.config.cjs
codeception.yml
codeception.dist.yml
composer.json
composer.lock
jest.config.cjs
package-lock.json
package.json
phpcs.xml
phpstan.neon
phpstan.neon.dist
README.md
tsconfig.eslint.json
tsconfig.json
webpack.config.cjs
$GITHUB_WORKSPACE
36 changes: 36 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# The path to the WordPress root directory, the one containing the wp-load.php file.
# This can be a relative path from the directory that contains the codeception.yml file,
# or an absolute path.
WORDPRESS_ROOT_FOLDER="/var/www/html"

# The port on which the WordPress installation is served.
WORDPRESS_LOCALHOST_PORT=3389

# The URL and domain of the WordPress site used in end-to-end tests.
WORDPRESS_URL="http://localhost:3389"
WORDPRESS_DOMAIN=localhost:3389

# Tests will require a MySQL database to run.
# The database will be created if it does not exist.
# Do not use a database that contains important data!
WORDPRESS_DB_DSN="mysql:host=database;port=3306;dbname=wordpress"
WORDPRESS_DB_HOST=database:3306
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASSWORD=wordpress
WORDPRESS_DB_URL=mysql://wordpress:wordpress@database:3306/wordpress
WORDPRESS_DB_LOCALHOST_PORT=3391

# The Integration suite will use this table prefix for the WordPress tables.
TEST_TABLE_PREFIX=test_

# This table prefix used by the WordPress site in end-to-end tests.
WORDPRESS_TABLE_PREFIX=wp_

# The username and password of the administrator user of the WordPress site used in end-to-end tests.
WORDPRESS_ADMIN_USER=admin
WORDPRESS_ADMIN_PASSWORD=password

WORDPRESS_ADMIN_PATH="/wp-admin"

WORDPRESS_XDEBUG=true
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build-module
build-types
coverage
vendor
vendor-prod

tests/_wordpress
5 changes: 2 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true,
"tsconfigRootDir": "."
"project": ["./tsconfig.json", "./tsconfig.eslint.json"]
},
"extends": ["plugin:@wordpress/eslint-plugin/recommended"],
"rules": {
Expand Down Expand Up @@ -48,7 +47,7 @@
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": ["./tsconfig.eslint.json"]
"project": ["./tsconfig.json", "./tsconfig.eslint.json"]
}
}
},
Expand Down
39 changes: 39 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Install dependencies
description: Setup Node.js, Composer, and install dependencies

runs:
using: "composite"
steps:
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: |
vendor
vendor-prod
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}

- name: Composer install
uses: php-actions/composer@v6
with:
php_version: "8.2"
version: 2.x
dev: yes
args: --optimize-autoloader --ignore-platform-reqs

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: package-lock.json

- name: NPM install
shell: bash
run: npm ci --ignore-scripts

- name: Build NPM dependencies
shell: bash
run: npm rebuild && npm run prepare --if-present
40 changes: 40 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Coding Standards

on:
pull_request:
branches: [main, epic/*]
workflow_dispatch:

jobs:
lint:
name: Check Coding Standards
runs-on: ubuntu-latest
environment: testing
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependenices
uses: ./.github/actions/install

- name: Generate testing files
shell: bash
run: |
envsubst < tests/.env.example > tests/.env
php vendor/bin/codecept build

- name: Lint PHP
shell: bash
run: |
composer run-script lint
composer run-script analyze

- name: Lint JavaScript
shell: bash
run: |
npm run lint:js
npm run check

- name: Lint Styles
shell: bash
run: npm run lint:css
56 changes: 56 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test Suite

on:
pull_request:
branches: [main, epic/*]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ["unit", "acceptance"]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependenices
uses: ./.github/actions/install

- name: Setup environment
shell: bash
run: envsubst < tests/.env.example > tests/.env

- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.3.6
with:
key: docker-${{ runner.os }}-${{ hashFiles('docker-compose.yml') }}

- name: Build testing files
shell: bash
run: php vendor/bin/codecept build

- name: Setup docker
shell: bash
run: sudo bin/test-up.sh

- name: Run unit tests
if: matrix.test != 'acceptance'
run: bin/test-run.sh ${{ matrix.test }}

- name: Run acceptance tests
if: matrix.test == 'acceptance'
run: php vendor/bin/codecept run acceptance

- name: Upload codeception output
if: ${{ failure() }}
uses: actions/upload-artifact@v2.2.1
with:
name: "${{ matrix.test }}-output"
path: "./tests/_output"

- name: Stop testing container
shell: bash
run: bin/test-down.sh
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ artifacts
# Dependency directories
node_modules/
vendor/
vendor-prod/

# Optional npm cache directory
.npm
Expand All @@ -36,7 +37,15 @@ vendor/
.idea
.vscode

# Local config files
.php-cs-fixer.php
codeception.yml
phpstan.neon

# Cache files
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache

# Testing artifacts
tests/_wordpress
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
6 changes: 4 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
// allows using the latest version of the rules.

$finder = Finder::create()
->notPath(['WP_HTML_Tag_Processor.php'])
->exclude(['vendor', 'vendor-prod', '_support/_generated', '_wordpress'])
->in([
__DIR__ . '/server/src',
__DIR__ . '/server/tests',
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->ignoreDotFiles(true)
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ build-module
build-types
coverage
vendor
vendor-prod

composer.lock
package-lock.json

**/*.md

tests/_wordpress
File renamed without changes.
13 changes: 13 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.cache
build
build-module
build-types

tests
coverage

vendor
vendor-prod
node_modules

tests/_wordpress
4 changes: 0 additions & 4 deletions .wp-env.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WP-Blocks Search, a WordPress plugin.
Indexed Search, a WordPress plugin.
Copyright (C) 2023 The Contributors

This program is free software: you can redistribute it and/or modify
Expand Down
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
# Search
# Indexed Search

An advanced WordPress search block.
An advanced WordPress indexed search plugin.

## Description

A super cool search plugin which uses indexing to make the search of post content speedy!

## Development

### Getting started

The development environment is setup in a Docker container.

```sh
# Create a development environment file
cp .env.example .env

# Command to start the development WordPress instance.
docker-compose up -d
```

## Testing

The development environment is setup in a separate Docker container than development.

```sh
# Create a testing environment file
cp tests/.env.example tests/.env

# Command to start the testing WordPress instance.
bin/test-up.sh

# Command to run Codeception unit tests from inside the container.
bin/test-run.sh unit

# Command to run Codeception acceptance tests from outside the container.
vendor/bin/codecept run acceptance
```

### Testing database

The testing container does not persist volumes. If a local database dump exists, it will be loaded when initializing the database container.

Use the following command to create a local database dump.

```sh
# Command to dump the testing database to tests/_data/dump.sql
bin/dump-acceptance-db.sh
```
3 changes: 3 additions & 0 deletions bin/dump-acceptance-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker compose --file tests/docker-compose.yml --env-file tests/.env exec database /usr/bin/mysqldump -uwordpress -pwordpress wordpress > tests/_data/dump.sql
3 changes: 3 additions & 0 deletions bin/init-pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

./bin/test-up.sh
3 changes: 3 additions & 0 deletions bin/local-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker compose --file docker-compose.yml --env-file .env down
4 changes: 4 additions & 0 deletions bin/local-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

docker compose --file docker-compose.yml --env-file .env up --wait
docker compose --file docker-compose.yml --env-file .env exec -T wordpress chown www-data:www-data wp-content wp-content/plugins
3 changes: 3 additions & 0 deletions bin/local-wp-shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker compose --file docker-compose.yml --env-file .env exec -w /var/www/html/wp-content/plugins/indexed-search wordpress bash -c "vendor/bin/wp --allow-root shell"
Loading
Loading