Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test running drupal-check via global installation #50

Merged
merged 5 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ commands:
- run: echo "Downloading box.phar version $BOX_VERSION"
- run: curl -O -L https://github.com/humbug/box/releases/download/$BOX_VERSION/box.phar
- run: php box.phar compile
create-drupal-project:
steps:
- run: composer create-project drupal-composer/drupal-project:8.x-dev /tmp/drupal --no-interaction --no-dev --prefer-dist --ignore-platform-reqs
jobs:
lint:
<<: *defaults
Expand All @@ -45,10 +48,41 @@ jobs:
- start-project
- build-phar
- run: php box.phar info drupal-check.phar
test_global_require:
<<: *defaults
steps:
- start-project
- run:
name: Remove vendor directory
command: |
rm -rf vendor
- run:
name: Add project as a global dependency
command: |
composer global config repositories.drupalCheck '{"type": "path", "url": "~/repo", "options": { "symlink": false }}'
- run:
name: Add globally
command: |
composer global require mglaman/drupal-check *@dev
- run:
name: Add Composer global path
command: |
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> $BASH_ENV
echo $BASH_ENV
- run:
name: Check drupal-check can be executed
command: |
drupal-check --version
- create-drupal-project
- run:
name: Run against a file
command: |
drupal-check /tmp/drupal/web/core/install.php

workflows:
version: 2
test_and_deploy:
jobs:
- lint
- test_global_require
- build
3 changes: 3 additions & 0 deletions .circleci/generate-local-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# Note: must be run from the root of the project.
circleci config process .circleci/config.yml > .circleci/config_local.yml
4 changes: 4 additions & 0 deletions .circleci/run-local-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Note: must be run from the root of the project.
source .circleci/generate-local-config.sh
circleci local execute --job ${1:-build} --config .circleci/config_local.yml
Empty file added .config_local.yml
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/vendor/
/.idea
/*.phar
.circleci/config_local.yml
Empty file added config_local.yml
Empty file.
10 changes: 6 additions & 4 deletions drupal-check
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ use Composer\XdebugHandler\XdebugHandler;

gc_disable();

$composerAutoloadFile = __DIR__ . '/vendor/autoload.php';
if (file_exists($composerAutoloadFile)) {
require $composerAutoloadFile;
} else {
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} elseif (is_file(__DIR__ . '/../../autoload.php')) {
require_once __DIR__ . '/../../autoload.php';
}
else {
echo "Composer autoload file not found.\n";
echo "You need to run 'composer install'.\n";
exit(1);
Expand Down
2 changes: 2 additions & 0 deletions phpstan/base_config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ parameters:
- */tests/Drupal/Tests/Listeners/Legacy/*
- */tests/fixtures/*.php
- */settings*.php
includes:
- phpstan_drupal_extension.php
3 changes: 1 addition & 2 deletions phpstan/deprecation_testing.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ parameters:
- '#Missing cache backend declaration for performance.#'
- '#Plugin manager has cache backend specified but does not declare cache tags.#'
includes:
- ../vendor/mglaman/phpstan-drupal/extension.neon
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- base_config.neon
- phpstan_deprecation_rules.php
- junit_formatter.neon
15 changes: 15 additions & 0 deletions phpstan/phpstan_deprecation_rules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
return [
'includes' => [
'../vendor/phpstan/phpstan-deprecation-rules/rules.neon',
],
];
} elseif (file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
return [
'includes' => [
'../../../vendor/phpstan/phpstan-deprecation-rules/rules.neon',
],
];
}
15 changes: 15 additions & 0 deletions phpstan/phpstan_drupal_extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
return [
'includes' => [
'../vendor/mglaman/phpstan-drupal/extension.neon',
],
];
} elseif (file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
return [
'includes' => [
'../../../vendor/mglaman/phpstan-drupal/extension.neon',
],
];
}
3 changes: 1 addition & 2 deletions phpstan/rules_and_deprecations_testing.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
level: 1
includes:
- ../vendor/mglaman/phpstan-drupal/extension.neon
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- base_config.neon
- phpstan_deprecation_rules.php
- junit_formatter.neon
1 change: 0 additions & 1 deletion phpstan/rules_testing.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
level: 1
includes:
- ../vendor/mglaman/phpstan-drupal/extension.neon
- base_config.neon
- junit_formatter.neon