From e1c53699fd4d8d8aa5ef91cd47955d35016d6d47 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:41:48 -0500 Subject: [PATCH 1/9] Allow dev setup --- src/class-install-command.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/class-install-command.php b/src/class-install-command.php index 841614d..9f32b7b 100644 --- a/src/class-install-command.php +++ b/src/class-install-command.php @@ -31,7 +31,8 @@ protected function configure() { ->addOption( 'dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release' ) ->addOption( 'force', 'f', InputOption::VALUE_NONE, 'Install even if the directory already exists' ) ->addOption( 'install', 'i', InputOption::VALUE_NONE, 'Install WordPress in the current location if it doesn\'t exist.' ) - ->addOption( 'no-must-use', 'no-mu', InputOption::VALUE_OPTIONAL, 'Don\'t load Mantle as a must-use plugin.', false ); + ->addOption( 'no-must-use', 'no-mu', InputOption::VALUE_OPTIONAL, 'Don\'t load Mantle as a must-use plugin.', false ) + ->addOption( 'setup-dev', null, InputOption::VALUE_NONE, 'Setup mantle for development on the framework.' ); } /** @@ -96,7 +97,7 @@ protected function get_wordpress_root( InputInterface $input, OutputInterface $o // Bail if the folder already exists. if ( $name && is_dir( $name ) && ! $input->getOption( 'force' ) ) { - $style->error( 'Directory already exists: ' . $abspath ); + $style->error( "Directory already exists: [{$abspath}] Use --force to override." ); return null; } @@ -229,8 +230,9 @@ function ( $type, $line ) use ( $output ) { protected function install_mantle( string $dir, InputInterface $input, OutputInterface $output ) { $wp_content = $dir . '/wp-content'; - $name = $input->getArgument( 'name' )[0] ?? 'mantle'; - $mantle_dir = "{$wp_content}/plugins/{$name}"; + $name = $input->getArgument( 'name' )[0] ?? 'mantle'; + $mantle_dir = "{$wp_content}/plugins/{$name}"; + $framework_dir = "{$wp_content}/plugins/{$name}-framework"; // Check if Mantle exists at the current location. if ( is_dir( $mantle_dir ) && file_exists( $mantle_dir . '/composer.json' ) ) { @@ -243,6 +245,21 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt "rm -rf {$mantle_dir}/docs", ]; + // Setup the application for local development on the framework. + if ( $input->getOption('setup-dev') ) { + if ( is_dir( $framework_dir ) && file_exists( "{$framework_dir}/composer.json" ) ) { + throw new RuntimeException( "Mantle Framework is already installed: [{$framework_dir}'" ); + } + + $commands = [ + "git clone git@github.com:alleyinteractive/mantle-framework.git {$framework_dir}", + "cd {$framework_dir} && composer install", + "git clone git@github.com:alleyinteractive/mantle.git {$mantle_dir}", + "cd {$mantle_dir} && composer config repositories.mantle-framework '{\"type\": \"path\", \"url\": \"../{$name}-framework\", \"options\": {\"symlink\": true}}' --file composer.json", + "cd {$mantle_dir} && composer install --no-scripts", + ]; + } + $output->writeln( 'Installing Mantle...' ); $process = $this->run_commands( $commands, $input, $output ); @@ -253,6 +270,10 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt $output->writeln( "Mantle installed successfully at {$mantle_dir}." ); + if ( $input->getOption('setup-dev') ) { + $output->writeln( "Mantle Framework installed successfully at {$framework_dir}." ); + } + // Add Mantle as a must-use plugin. if ( false === $input->getOption( 'no-must-use' ) ) { $mu_plugins = "{$wp_content}/mu-plugins"; From 808f4716307063bfc27bc675a787c5e51768027c Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:43:27 -0500 Subject: [PATCH 2/9] phpcs fixes --- src/class-install-command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/class-install-command.php b/src/class-install-command.php index 9f32b7b..d668bba 100644 --- a/src/class-install-command.php +++ b/src/class-install-command.php @@ -246,7 +246,7 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt ]; // Setup the application for local development on the framework. - if ( $input->getOption('setup-dev') ) { + if ( $input->getOption( 'setup-dev' ) ) { if ( is_dir( $framework_dir ) && file_exists( "{$framework_dir}/composer.json" ) ) { throw new RuntimeException( "Mantle Framework is already installed: [{$framework_dir}'" ); } @@ -270,7 +270,7 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt $output->writeln( "Mantle installed successfully at {$mantle_dir}." ); - if ( $input->getOption('setup-dev') ) { + if ( $input->getOption( 'setup-dev' ) ) { $output->writeln( "Mantle Framework installed successfully at {$framework_dir}." ); } From 3701c770cb01b5b8d58c415cdd9c7b941da5a6e3 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:48:11 -0500 Subject: [PATCH 3/9] Adding actions --- .github/workflows/coding-standards.yml | 47 ++++++++++++++++++++++++++ .github/workflows/unit-test.yml | 45 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..4f04116 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,47 @@ +name: Coding Standards + +on: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: [7.3, 7.4] + + name: PHP ${{ matrix.php }} + + steps: + - 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: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ matrix.php }}-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: Validate Composer + run: composer validate --strict + - name: Install dependencies + uses: nick-invision/retry@v1 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer install + - uses: php-actions/phpunit@v2 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..8bb7c39 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,45 @@ +name: Testing Suite + +on: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: [7.3, 7.4] + + name: PHP ${{ matrix.php }} + + steps: + - 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: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ matrix.php }}-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 dependencies + uses: nick-invision/retry@v1 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer install + - uses: php-actions/phpunit@v2 From 20c4a6188039d9713b66e0e78fccf93432a96496 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:49:03 -0500 Subject: [PATCH 4/9] Trigger --- .github/workflows/coding-standards.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 4f04116..95ec9ac 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -14,7 +14,6 @@ jobs: php: [7.3, 7.4] name: PHP ${{ matrix.php }} - steps: - name: Get Composer cache directory id: composer-cache From f1c28145c65944ba6c2c9ce15aa2759c907fc610 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:49:58 -0500 Subject: [PATCH 5/9] Trigger --- .github/workflows/coding-standards.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 95ec9ac..bc1604d 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -12,7 +12,6 @@ jobs: fail-fast: true matrix: php: [7.3, 7.4] - name: PHP ${{ matrix.php }} steps: - name: Get Composer cache directory From 1ca1927f63e76564635d4aa0f8a5bf5038d24d8b Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:51:18 -0500 Subject: [PATCH 6/9] Limit cs to one matrix --- .github/workflows/coding-standards.yml | 4 +++- .github/workflows/unit-test.yml | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index bc1604d..799a564 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -11,9 +11,11 @@ jobs: strategy: fail-fast: true matrix: - php: [7.3, 7.4] + php: [7.4] name: PHP ${{ matrix.php }} 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)" diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 8bb7c39..a8cab24 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -12,14 +12,13 @@ jobs: fail-fast: true matrix: php: [7.3, 7.4] - name: PHP ${{ matrix.php }} - 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: From d040e5000e22c026bb7ec9b0802d68dc8e242964 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:53:17 -0500 Subject: [PATCH 7/9] Use the composer method --- .github/workflows/coding-standards.yml | 3 ++- .github/workflows/unit-test.yml | 3 ++- README.md | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 799a564..bb08514 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -44,4 +44,5 @@ jobs: timeout_minutes: 5 max_attempts: 5 command: composer install - - uses: php-actions/phpunit@v2 + - name: Run phpcs + run: composer run phpcs diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a8cab24..cec7272 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -41,4 +41,5 @@ jobs: timeout_minutes: 5 max_attempts: 5 command: composer install - - uses: php-actions/phpunit@v2 + - name: Run phpcs + run: composer run phpunit diff --git a/README.md b/README.md index 99f5d2f..b342641 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # Mantle Installer Documentation can be found inside the [Mantle documentation](https://mantle.alley.co/). + +![Testing Suite](https://github.com/alleyinteractive/mantle-installer/workflows/Testing%20Suite/badge.svg) +![Coding Standards](https://github.com/alleyinteractive/mantle-installer/workflows/Coding%20Standards/badge.svg) From 14d5978f868d7a60c63ceb9ca949f609377f9e12 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:54:30 -0500 Subject: [PATCH 8/9] Fix test name --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index cec7272..85b1999 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -41,5 +41,5 @@ jobs: timeout_minutes: 5 max_attempts: 5 command: composer install - - name: Run phpcs + - name: Run phpunit run: composer run phpunit From f17ff91f58ebbece9844cf8fc18846b9d18cc068 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Mon, 28 Dec 2020 15:54:37 -0500 Subject: [PATCH 9/9] Remvoe travis --- .travis.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6863e41..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -dist: bionic - -sudo: false - -language: php - -notifications: - email: false - -cache: - directories: - - $HOME/.composer/cache - -branches: - only: - - main - -matrix: - include: - - php: 7.3 - -before_install: - - | - export PATH="$HOME/.composer/vendor/bin:$PATH" - - | - if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then - phpenv config-rm xdebug.ini - else - echo "xdebug.ini does not exist" - fi - -install: - - composer install -n - - chmod 755 tests/output - -script: - - composer run phpcs - - composer run phpunit