Skip to content

Commit 48faec6

Browse files
committed
Add CircleCI test integration
1 parent 0e1782f commit 48faec6

File tree

6 files changed

+121
-1
lines changed

6 files changed

+121
-1
lines changed

.circleci/config.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
version: 2.1
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/php:7.2-cli
5+
environment:
6+
BOX_VERSION: 3.6.0
7+
working_directory: ~/repo
8+
aliases:
9+
- &composer-cache
10+
v4-composer-cache
11+
commands:
12+
start-project:
13+
steps:
14+
- run: sudo apt-get update && sudo apt-get install -y libpng-dev libjpeg62-turbo-dev
15+
- run:
16+
name: Install PHP Extensions
17+
command: sudo docker-php-ext-install gd
18+
- checkout
19+
- restore_cache:
20+
keys:
21+
- *composer-cache
22+
- run: composer global require "hirak/prestissimo:^0.3"
23+
- run: composer install -n --prefer-dist
24+
- save_cache:
25+
key: *composer-cache
26+
paths:
27+
- ~/.composer/cache
28+
create-drupal-project:
29+
parameters:
30+
project:
31+
type: string
32+
default: 'drupal-composer/drupal-project:8.x-dev'
33+
steps:
34+
- run: composer create-project << parameters.project >> /tmp/drupal --no-interaction --no-dev --prefer-dist --ignore-platform-reqs
35+
local-require:
36+
steps:
37+
- run:
38+
name: Add as local
39+
command: |
40+
cd /tmp/drupal
41+
composer config repositories.phpstanDrupal '{"type": "path", "url": "~/repo", "options": { "symlink": false }}'
42+
composer require mglaman/phpstan-drupal *@dev
43+
cp ~/repo/tests/fixtures/config/drupal-phpstan.neon /tmp/drupal/phpstan.neon
44+
./vendor/bin/phpstan --version
45+
global-require:
46+
steps:
47+
- run:
48+
name: Add PHPStan
49+
command: |
50+
composer global require phpstan/phpstan
51+
- run:
52+
name: Remove vendor directory
53+
command: |
54+
rm -rf vendor
55+
- run:
56+
name: Add project as a global dependency
57+
command: |
58+
composer global config repositories.phpstanDrupal '{"type": "path", "url": "~/repo", "options": { "symlink": false }}'
59+
- run:
60+
name: Add globally
61+
command: |
62+
composer global require mglaman/phpstan-drupal *@dev
63+
- run:
64+
name: Add Composer global path
65+
command: |
66+
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> $BASH_ENV
67+
echo $BASH_ENV
68+
- run:
69+
name: Check drupal-check can be executed
70+
command: |
71+
phpstan --version
72+
jobs:
73+
build:
74+
<<: *defaults
75+
steps:
76+
- start-project
77+
- run:
78+
name: CodeSniffer
79+
command: ./vendor/bin/phpcs src
80+
- run:
81+
name: PHPStan Analyze
82+
command: ./vendor/bin/phpstan analyze src
83+
- run:
84+
name: PHPUnit
85+
command: ./vendor/bin/phpunit
86+
test_drupal:
87+
<<: *defaults
88+
steps:
89+
- start-project
90+
- create-drupal-project:
91+
project: 'drupal/drupal:^8@alpha'
92+
- local-require
93+
- run:
94+
name: Run against a file
95+
command: |
96+
cd /tmp/drupal
97+
./vendor/bin/phpstan analyze core/install.php
98+
- run:
99+
name: Run against a module
100+
command: |
101+
cd /tmp/drupal
102+
./vendor/bin/phpstan analyze core/modules/dynamic_page_cache | grep -q "not found and could not be autoloaded." && false || true
103+
104+
workflows:
105+
version: 2
106+
tests:
107+
jobs:
108+
- build
109+
- test_drupal

.circleci/generate-local-config.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
# Note: must be run from the root of the project.
3+
circleci config process .circleci/config.yml > .circleci/config_local.yml

.circleci/run-local-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
# Note: must be run from the root of the project.
3+
source .circleci/generate-local-config.sh
4+
circleci local execute --job ${1:-build} --config .circleci/config_local.yml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
/vendor/
44
/clover.xml
55
/tests/fixtures/drupal/core
6+
.circleci/config_local.yml

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ script:
2323

2424
# Test that a known non-failing file doesn't error out.
2525
- ./vendor/bin/phpstan analyze web/core/install.php --debug
26-
- ./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache | grep -q "Class Drupal\Tests\BrowserTestBase not found and could not be autoloaded." && false || true
26+
- ./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache | grep -q "Class Drupal\Tests\BrowserTestBase not found and could not be autoloaded." && false || true
2727

2828
# Verify test fixtures are ignored.
2929
- ./vendor/bin/phpstan analyze web/core/modules/migrate_drupal --no-progress | grep -q "tests/fixtures" && false || true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
parameters:
2+
reportUnmatchedIgnoredErrors: false
23
level: 0
4+
ignoreErrors:
5+
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
36
includes:
47
- vendor/mglaman/phpstan-drupal/extension.neon

0 commit comments

Comments
 (0)