Skip to content

Commit

Permalink
Add support for GitHub as CI in plugin scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Mar 28, 2024
1 parent 8aa906c commit b786c43
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ private function get_output_path( $assoc_args, $subdir ) {
* default: circle
* options:
* - circle
* - bitbucket
* - gitlab
* - github
* ---
*
* [--activate]
Expand Down Expand Up @@ -733,6 +735,7 @@ public function plugin( $args, $assoc_args ) {
* - circle
* - gitlab
* - bitbucket
* - github
* ---
*
* [--force]
Expand Down Expand Up @@ -785,6 +788,7 @@ public function plugin_tests( $args, $assoc_args ) {
* - circle
* - gitlab
* - bitbucket
* - github
* ---
*
* [--force]
Expand Down Expand Up @@ -882,6 +886,8 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
$files_to_create[ "{$target_dir}/.gitlab-ci.yml" ] = self::mustache_render( 'plugin-gitlab.mustache' );
} elseif ( 'bitbucket' === $assoc_args['ci'] ) {
$files_to_create[ "{$target_dir}/bitbucket-pipelines.yml" ] = self::mustache_render( 'plugin-bitbucket.mustache' );
} elseif ( 'github' === $assoc_args['ci'] ) {
$files_to_create[ "{$target_dir}/.github/workflows/testing.yml" ] = self::mustache_render( 'plugin-github.mustache' );
}

$files_written = $this->create_files( $files_to_create, $force );
Expand Down
38 changes: 38 additions & 0 deletions templates/plugin-github.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Testing

on:
pull_request:
branches:
- main
- master

jobs:
phpunit:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2', '8.0', '7.4']
services:
database:
image: mysql:latest
env:
MYSQL_DATABASE: wordpress_tests
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpunit-polyfills:1.1

- name: Setup tests
run: bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true

- name: Run tests
run: phpunit

0 comments on commit b786c43

Please sign in to comment.