Skip to content

Commit

Permalink
Merging in main
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Jul 29, 2024
2 parents 4559fca + 80cb197 commit e2c86d5
Show file tree
Hide file tree
Showing 42 changed files with 3,605 additions and 789 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Coding Standards

on: pull_request

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['8.2']

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: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Log information
run: |
echo "$GITHUB_REF"
echo "$GITHUB_EVENT_NAME"
git --version
php --version
composer --version
- name: Validate Composer
run: composer validate --strict

- name: Install dependencies
uses: ramsey/composer-install@v1
with:
composer-options: "--ignore-platform-reqs"

- name: Run PHPCS
run: composer phpcs
94 changes: 94 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Unit Tests

on: pull_request

jobs:
tests:
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }} - ES: ${{ matrix.es_version }} (MU: ${{ matrix.multisite }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false # do not fail fast, let all the failing tests fail.
matrix:
php: [8.2]
es_version: [7.17.5, 8.10.2]
multisite: [0]
wp_version: ["latest"]
include:
- php: '7.4'
es_version: '8.10.2'
multisite: 0
wp_version: '5.9.3'
- php: '8.0'
es_version: '6.8.23'
multisite: 1
wp_version: '5.9.3'
env:
CACHEDIR: /tmp/test-cache
WP_CORE_DIR: /tmp/wordpress/
WP_TESTS_DIR: /tmp/wordpress-tests-lib
WP_VERSION: ${{ matrix.wp_version }}
WP_MULTISITE: ${{ matrix.multisite }}
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

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: Check out code
uses: actions/checkout@v2

- name: Configure sysctl limits
run: |
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: Set up Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: ${{ matrix.es_version }}
security-enabled: false

- name: Set up 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 dependencies
uses: ramsey/composer-install@v1
with:
composer-options: "--ignore-platform-reqs"

- name: Log information
run: |
echo "$GITHUB_REF"
echo "$GITHUB_EVENT_NAME"
git --version
php --version
composer --version
- name: Set up WordPress
run: |
bash <(curl -s "https://raw.githubusercontent.com/wp-cli/sample-plugin/master/bin/install-wp-tests.sh") wordpress_test root '' 127.0.0.1 ${{ matrix.wp_version }}
rm -rf "${WP_CORE_DIR}wp-content/plugins"
mkdir -p "${WP_CORE_DIR}wp-content/plugins/searchpress"
rsync -a --exclude=.git . "${WP_CORE_DIR}wp-content/plugins/searchpress"
- name: Run tests
run: |
cd ${WP_CORE_DIR}wp-content/plugins/searchpress
composer phpunit
27 changes: 24 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
/report/
# Build files
report
node_modules
vendor

# Log files
*.log

# Cache files
.phpcs/*.json
.phpunit.result.cache

# Ignore temporary OS files
.DS_Store
.svn
/.idea
.DS_Store?
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
.thumbsdb

# IDE files
*.code-workspace
.idea
.vscode
59 changes: 59 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SearchPress" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>PHP_CodeSniffer standard for SearchPress.</description>

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

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

<!-- Enable colors in report -->
<arg name="colors" />

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

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

<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value=".phpcs/cache.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>*/**/tests/</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/bin/*</exclude-pattern>
<exclude-pattern>.phpcs/</exclude-pattern>

<!-- The version set here matches the minimum WP version tested. -->
<config name="minimum_supported_wp_version" value="4.8" />

<!-- Silencing off rules. -->
<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Generic.Arrays.DisallowLongArraySyntax.Found" />
</rule>
</ruleset>
Empty file added .phpcs/.gitkeep
Empty file.
109 changes: 0 additions & 109 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit e2c86d5

Please sign in to comment.