forked from drupal-graphql/graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
131 lines (109 loc) · 4.36 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
language: php
sudo: false
dist: bionic
services:
- mysql
php:
- 7.2
- 7.3
- 7.4
env:
global:
- DRUPAL_BUILD_DIR=$TRAVIS_BUILD_DIR/../drupal
- SIMPLETEST_DB=mysql://root:@127.0.0.1/graphql
- TRAVIS=true
matrix:
- DRUPAL_CORE=8.9.x
matrix:
# Don't wait for the allowed failures to build.
fast_finish: true
include:
- php: 7.4
env:
- DRUPAL_CORE=8.9.x
# Only run code coverage on the latest php and drupal versions.
- WITH_PHPDBG_COVERAGE=true
- php: 7.4
env:
- DRUPAL_CORE=9.0.x
allow_failures:
# Allow the code coverage report to fail.
- php: 7.4
env:
- DRUPAL_CORE=8.9.x
# Only run code coverage on the latest php and drupal versions.
- WITH_PHPDBG_COVERAGE=true
mysql:
database: graphql
username: root
encoding: utf8
# Cache composer downloads.
cache:
directories:
- $HOME/.composer/cache
before_install:
# Disable xdebug. It might not exist on PHP 7.4 so ignore that error.
- phpenv config-rm xdebug.ini || true
# Determine the php settings file location.
- if [[ $TRAVIS_PHP_VERSION = hhvm* ]];
then export PHPINI=/etc/hhvm/php.ini;
else export PHPINI=$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini;
fi
# Disable the default memory limit.
- echo memory_limit = -1 >> $PHPINI
# Update composer.
- composer self-update
install:
# Create the database.
- mysql -e 'create database graphql'
# Download Drupal 8 core from the Github mirror because it is faster.
- git clone --branch $DRUPAL_CORE --depth 1 https://github.com/drupal/drupal.git $DRUPAL_BUILD_DIR
# Copy the module to the build site. This makes PHPStan find drupal reliably.
- cp -r $TRAVIS_BUILD_DIR $DRUPAL_BUILD_DIR/modules/graphql
# Copy the customized phpunit configuration file to the core directory so
# the relative paths are correct.
- cp $DRUPAL_BUILD_DIR/modules/graphql/phpunit.xml.dist $DRUPAL_BUILD_DIR/core/phpunit.xml
# When running with phpdbg we need to replace all code occurrences that check
# for 'cli' with 'phpdbg'. Some files might be write protected, hence the
# fallback.
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
then grep -rl 'cli' $DRUPAL_BUILD_DIR/core $DRUPAL_BUILD_DIR/modules | xargs sed -i "s/'cli'/'phpdbg'/g" || true;
fi
# We don't care about any dirty changes in the vendor directory, throw them
# all away.
- composer --working-dir=$DRUPAL_BUILD_DIR config discard-changes true
- composer --no-interaction --working-dir=$DRUPAL_BUILD_DIR install
# Make sure to work with the latest PHPUnit version in Drupal 8.
- composer --no-interaction --working-dir=$DRUPAL_BUILD_DIR run-script drupal-phpunit-upgrade
# Bring in the module dependencies without requiring a merge plugin.
# Require redirect module to prevent PHPStan error on an optional dependency.
# Install PHPStan to check for Drupal standards.
- composer --no-interaction --working-dir=$DRUPAL_BUILD_DIR require \
webonyx/graphql-php:^14.3 \
drupal/typed_data:^1.0 \
drupal/redirect:^1.6 \
phpstan/phpstan:^0.12.50 \
mglaman/phpstan-drupal:^0.12.3 \
phpstan/phpstan-deprecation-rules:^0.12.2 \
jangregor/phpstan-prophecy:^0.8 \
phpstan/phpstan-phpunit:^0.12
# Install PHPCS to check for Drupal coding standards.
- travis_retry composer global require drupal/coder:8.3.11
- $HOME/.config/composer/vendor/bin/phpcs --config-set installed_paths $HOME/.config/composer/vendor/drupal/coder/coder_sniffer
script:
# Run the unit tests using phpdbg if the environment variable is 'true'.
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
then phpdbg -qrr $DRUPAL_BUILD_DIR/vendor/bin/phpunit --configuration $DRUPAL_BUILD_DIR/core/phpunit.xml --coverage-clover $TRAVIS_BUILD_DIR/coverage.xml $TRAVIS_BUILD_DIR;
fi
# Check for coding standards violations.
- cd $DRUPAL_BUILD_DIR/modules/graphql && $HOME/.config/composer/vendor/bin/phpcs
# Run the unit tests with standard php otherwise.
- if [[ "$WITH_PHPDBG_COVERAGE" != "true" ]];
then $DRUPAL_BUILD_DIR/vendor/bin/phpunit --configuration $DRUPAL_BUILD_DIR/core/phpunit.xml $TRAVIS_BUILD_DIR;
fi
# Run Phpstan
- cd $DRUPAL_BUILD_DIR/modules/graphql && $DRUPAL_BUILD_DIR/vendor/bin/phpstan analyse
after_success:
- if [[ "$WITH_PHPDBG_COVERAGE" == "true" ]];
then bash <(curl -s https://codecov.io/bash);
fi