diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..bb08514 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,48 @@ +name: Coding Standards + +on: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + 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)" + + - 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 + - name: Run phpcs + run: composer run phpcs diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..85b1999 --- /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: 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: + 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 + - name: Run phpunit + run: composer run phpunit 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 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) diff --git a/src/class-install-command.php b/src/class-install-command.php index 841614d..d668bba 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";