Skip to content

Commit

Permalink
chore: Update package tools
Browse files Browse the repository at this point in the history
  • Loading branch information
nlemoine committed Nov 14, 2024
1 parent 9da465a commit 4112be6
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 102 deletions.
5 changes: 4 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
.travis.yml
behat.yml
circle.yml
phpcs.xml.dist
phpunit.xml.dist
bin/
features/
utils/
Expand All @@ -14,4 +16,5 @@ utils/
*.swp
*.txt
*.log
examples/
.release-please-manifest.json
release-please-config.json
Empty file added .git-blame-ignore-revs
Empty file.
12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality Checks

on:
pull_request:
push:
branches:
- main
- master

jobs:
code-quality:
uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: Release

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
with:
target-branch: ${{ github.ref_name }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
93 changes: 12 additions & 81 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,16 @@
name: Testing

on: [push, pull_request]
on:
pull_request:
push:
branches:
- main
- master
schedule:
- cron: '17 1 * * *' # Run every day on a seemly random time.

jobs:
functional:
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }}
continue-on-error: ${{ matrix.experimental == true }}
strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4', '8.0']
wp: ['latest']
test: ["composer behat || composer behat-rerun"]
include:
- php: '8.0'
wp: 'trunk'
test: "composer behat || composer behat-rerun"
- php: '8.1'
wp: 'trunk'
experimental: true

runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:5.7 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"

steps:
- name: Check out source code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: mysql, zip
coverage: none
tools: composer:v2

# - name: Shutdown default MySQL service
# run: sudo service mysql stop

- name: Start MySQL server
run: sudo service mysql start

- name: Get Composer cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer cache
uses: actions/cache@master
with:
path: ${{ steps['composer-cache'].outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --prefer-stable --prefer-dist --no-progress --no-interaction

- name: Configure DB environment
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
- name: Prepare test database
run: composer prepare-tests

- name: Check Behat environment
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat

- name: Run Behat
env:
WP_VERSION: '${{ matrix.wp }}'
run: ${{ matrix.test }}
test:
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main
with:
minimum-php: 7.2
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
wp-cli.local.yml
vendor/
composer.lock
/wp-cli.local.yml
/node_modules
/vendor
*.zip
*.tar.gz
*.swp
*.txt
*.log
/composer.lock
/phpunit.xml
/phpcs.xml
.phpcs.xml
.phpunit.result.cache
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.4.0"
}
16 changes: 7 additions & 9 deletions command.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php

namespace Hellonico\Fixtures;

use WP_CLI;

if (!class_exists('WP_CLI')) {
return;
if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
$wp_fixtures_autoloader = __DIR__ . '/vendor/autoload.php';

if ( file_exists( $wp_fixtures_autoloader ) ) {
require_once $wp_fixtures_autoloader;
}

WP_CLI::add_command('fixtures', __NAMESPACE__ . '\\Command');
WP_CLI::add_command( 'fixtures', 'Hellonico\Fixtures\Command' );
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
"authors": [
{
"name": "Nicolas Lemoine",
"email": "dev@niconico.fr",
"homepage": "https://github.com/nlemoine"
"email": "nico@n5s.dev",
"homepage": "https://n5s.dev/"
}
],
"homepage": "https://github.com/nlemoine/wp-cli-fixtures",
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"fakerphp/faker": "^1.20",
"nelmio/alice": "^3.8",
"wp-cli/wp-cli": "^2.4"
"wp-cli/db-command": "^2.0",
"wp-cli/entity-command": "^2.0"
},
"require-dev": {
"wp-cli/db-command": "^2.0",
"wp-cli/entity-command": "^2.0",
"wp-cli/wp-cli-tests": "^3.1"
"ergebnis/composer-normalize": "^2.44",
"slevomat/coding-standard": "^8.14",
"wp-cli/wp-cli-tests": "^4.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -34,14 +35,16 @@
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
},
"process-timeout": 1800
},
"scripts": {
"behat": "run-behat-tests",
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcbf": "run-phpcbf-cleanup",
"phpcs": "run-phpcs-tests",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
Expand Down
47 changes: 47 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0"?>
<ruleset name="WP-CLI-PROJECT-NAME">
<description>Custom ruleset for WP-CLI PROJECT NAME</description>

<!-- What to scan. -->
<file>.</file>

<!-- Show progress. -->
<arg value="p"/>

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

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

<!-- For help understanding the `testVersion` configuration setting:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.2-"/>

<!-- Rules: Include the base ruleset for WP-CLI projects. -->
<rule ref="WP_CLI_CS"/>

<!-- Verify that everything in the global namespace is either namespaced or prefixed.
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="Hellonico\Fixtures"/><!-- Namespaces. -->
<element value="wp_fixtures"/><!-- Global variables and such. -->
</property>
</properties>
</rule>

<!-- Whitelist property name for a a JSON-decoded object. -->
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="allowed_custom_properties" type="array">
<element value="sourcesContent"/>
<element value="functionsScannerClass"/>
</property>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>

</ruleset>
14 changes: 14 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "php",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"include-v-in-tag": false
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

0 comments on commit 4112be6

Please sign in to comment.