Skip to content

Commit b2328ff

Browse files
authored
Merge pull request #55 from simPod/ci
Add CI
2 parents bb27c70 + e829e1f commit b2328ff

17 files changed

+207
-132
lines changed

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
schedule:
9+
- cron: "0 17 * * *"
10+
11+
jobs:
12+
coding-standard:
13+
runs-on: ubuntu-18.04
14+
name: Coding Standard
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Install PHP
20+
uses: shivammathur/[email protected]
21+
with:
22+
php-version: 7.4
23+
coverage: none
24+
extensions: json
25+
tools: cs2pr
26+
27+
- name: Get Composer Cache Directory
28+
id: composer-cache
29+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
30+
31+
- name: Cache dependencies
32+
uses: actions/cache@v1
33+
with:
34+
path: ${{ steps.composer-cache.outputs.dir }}
35+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
36+
restore-keys: ${{ runner.os }}-composer-
37+
38+
- name: Install Dependencies
39+
run: composer install ${DEPENDENCIES}
40+
41+
- name: Coding Standard
42+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr
43+
44+
phpstan:
45+
runs-on: ubuntu-18.04
46+
name: PHPStan
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Install PHP
52+
uses: shivammathur/[email protected]
53+
with:
54+
php-version: 7.4
55+
coverage: none
56+
extensions: json
57+
tools: cs2pr
58+
59+
- name: Get Composer Cache Directory
60+
id: composer-cache
61+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
62+
63+
- name: Cache dependencies
64+
uses: actions/cache@v1
65+
with:
66+
path: ${{ steps.composer-cache.outputs.dir }}
67+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
68+
restore-keys: ${{ runner.os }}-composer-
69+
70+
- name: Install Dependencies
71+
run: composer install ${DEPENDENCIES}
72+
73+
- name: PHPStan
74+
run: vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr
75+
76+
coverage:
77+
runs-on: ubuntu-18.04
78+
name: Code Coverage
79+
80+
steps:
81+
- uses: actions/checkout@v2
82+
with:
83+
ref: ${{ github.ref }}
84+
85+
- name: Install PHP
86+
uses: shivammathur/[email protected]
87+
with:
88+
php-version: 7.4
89+
coverage: pcov
90+
extensions: json
91+
92+
- name: Get Composer Cache Directory
93+
id: composer-cache
94+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
95+
96+
- name: Cache dependencies
97+
uses: actions/cache@v1
98+
with:
99+
path: ${{ steps.composer-cache.outputs.dir }}
100+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
101+
restore-keys: ${{ runner.os }}-composer-
102+
103+
- name: Install Dependencies
104+
run: composer install ${DEPENDENCIES}
105+
106+
- name: Code coverage
107+
run: |
108+
./vendor/bin/phpunit --coverage-clover /tmp/coverage/clover.xml
109+
110+
- name: Report to Coveralls
111+
env:
112+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
COVERALLS_RUN_LOCALLY: 1
114+
run: vendor/bin/php-coveralls --coverage_clover /tmp/coverage/clover.xml --json_path /tmp/coverage/coveralls.json
115+
116+
tests:
117+
name: Tests
118+
runs-on: ubuntu-18.04
119+
strategy:
120+
matrix:
121+
php: [ 7.3, 7.4 ]
122+
dependencies: [ "", --prefer-lowest ]
123+
124+
steps:
125+
- uses: actions/checkout@v2
126+
127+
- name: Install PHP
128+
uses: shivammathur/[email protected]
129+
with:
130+
php-version: ${{ matrix.php }}
131+
coverage: none
132+
extensions: json, mbstring
133+
- name: Get Composer Cache Directory
134+
id: composer-cache
135+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
136+
137+
- name: Cache dependencies
138+
uses: actions/cache@v1
139+
with:
140+
path: ${{ steps.composer-cache.outputs.dir }}
141+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
142+
restore-keys: ${{ runner.os }}-composer-
143+
144+
- name: Install Dependencies
145+
run: composer install ${DEPENDENCIES}
146+
147+
- name: Run tests
148+
run: |
149+
export $ENV
150+
./vendor/bin/phpunit
151+
env:
152+
ENV: ${{ matrix.env}}

.scrutinizer.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# PHP GraphQL Utils for graphql-php
22

3-
[![Build Status](https://travis-ci.org/simPod/GraphQL-Utils.svg)](https://travis-ci.org/simPod/GraphQL-Utils)
3+
[![Build Status](https://github.com/simPod/GraphQL-Utils/workflows/CI/badge.svg?branch=master)](https://github.com/simPod/GraphQL-Utils/actions)
4+
[![Coverage Status](https://coveralls.io/repos/github/simPod/GraphQL-Utils/badge.svg?branch=master)](https://coveralls.io/github/simPod/GraphQL-Utils?branch=master)
45
[![Downloads](https://poser.pugx.org/simpod/graphql-utils/d/total.svg)](https://packagist.org/packages/simpod/graphql-utils)
56
[![Packagist](https://poser.pugx.org/simpod/graphql-utils/v/stable.svg)](https://packagist.org/packages/simpod/graphql-utils)
6-
[![Licence](https://poser.pugx.org/simpod/graphql-utils/license.svg)](https://packagist.org/packages/simpod/graphql-utils)
7-
[![Quality Score](https://scrutinizer-ci.com/g/simPod/GraphQL-Utils/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/simPod/GraphQL-Utils)
8-
[![Code Coverage](https://scrutinizer-ci.com/g/simPod/GraphQL-Utils/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/simPod/GraphQL-Utils)
97
[![GitHub Issues](https://img.shields.io/github/issues/simPod/GraphQL-Utils.svg?style=flat-square)](https://github.com/simPod/GraphQL-Utils/issues)
108

11-
129
## Contents
1310
- [Installation](#installation)
1411
- [Features](#features)

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
"webonyx/graphql-php": "^0.12||^0.13"
1919
},
2020
"require-dev": {
21-
"doctrine/coding-standard": "^7.0",
21+
"doctrine/coding-standard": "^8.1",
22+
"phpstan/extension-installer": "^1.0",
2223
"phpstan/phpstan": "0.12.25",
2324
"phpstan/phpstan-phpunit": "0.12.10",
2425
"phpstan/phpstan-strict-rules": "0.12.2",
2526
"phpunit/phpunit": "^9.0",
27+
"simpod/php-coveralls-mirror": "^3.0",
2628
"thecodingmachine/phpstan-safe-rule": "^1.0"
2729
},
2830
"autoload": {

phpcs.xml.dist

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?xml version="1.0"?>
22
<ruleset>
33
<arg name="basepath" value="."/>
4-
<arg name="extensions" value="php"/>
5-
<arg name="parallel" value="80"/>
6-
<arg name="cache" value=".phpcs-cache"/>
7-
<arg name="colors"/>
4+
<arg name="extensions" value="php" />
5+
<arg name="parallel" value="80" />
6+
<arg name="cache" value=".phpcs-cache" />
7+
<arg name="colors" />
88

99
<!-- Ignore warnings, show progress of the run and show sniff names -->
10-
<arg value="nps"/>
10+
<arg value="nps" />
1111

1212
<file>src</file>
1313

14-
<rule ref="Doctrine"/>
14+
<rule ref="Doctrine">
15+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator.RequiredNullCoalesceEqualOperator" />
16+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
17+
</rule>
1518
</ruleset>

phpstan.neon.dist

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ parameters:
44
- %currentWorkingDirectory%/src
55
- %currentWorkingDirectory%/tests
66

7-
includes:
8-
- vendor/phpstan/phpstan-phpunit/extension.neon
9-
- vendor/phpstan/phpstan-phpunit/rules.neon
10-
- vendor/phpstan/phpstan-strict-rules/rules.neon
11-
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
12-
13-
ignoreErrors:
14-
# Adds unnecessary maintanence overhead
15-
- "~Class DateTime(Immutable)? is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\\\\DateTime(Immutable)?;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library~"
7+
ignoreErrors:
8+
# Adds unnecessary maintanence overhead
9+
- "~Class DateTime(Immutable)? is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\\\\DateTime(Immutable)?;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library~"

src/Builder/EnumBuilder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimPod\GraphQLUtils\Builder;
66

77
use SimPod\GraphQLUtils\Exception\InvalidArgument;
8+
89
use function Safe\preg_match;
910

1011
class EnumBuilder extends TypeBuilder
@@ -15,15 +16,15 @@ class EnumBuilder extends TypeBuilder
1516
/**
1617
* @return static
1718
*/
18-
public static function create(string $name) : self
19+
public static function create(string $name): self
1920
{
2021
return new static($name);
2122
}
2223

2324
/**
2425
* @return static
2526
*/
26-
public function addValue(string $value, ?string $name = null, ?string $description = null) : self
27+
public function addValue(string $value, ?string $name = null, ?string $description = null): self
2728
{
2829
$name = $name ?? $value;
2930
if (preg_match(self::VALID_NAME_PATTERN, $name) !== 1) {
@@ -43,7 +44,7 @@ public function addValue(string $value, ?string $name = null, ?string $descripti
4344
/**
4445
* @return mixed[]
4546
*/
46-
public function build() : array
47+
public function build(): array
4748
{
4849
$parameters = parent::build();
4950
$parameters['values'] = $this->values;

src/Builder/FieldBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ final private function __construct(string $name, Type $type)
2121
/**
2222
* @return static
2323
*/
24-
public static function create(string $name, Type $type) : self
24+
public static function create(string $name, Type $type): self
2525
{
2626
return new static($name, $type);
2727
}
2828

2929
/**
3030
* @return static
3131
*/
32-
public function setDescription(string $description) : self
32+
public function setDescription(string $description): self
3333
{
3434
$this->parameters['description'] = $description;
3535

@@ -39,7 +39,7 @@ public function setDescription(string $description) : self
3939
/**
4040
* @return static
4141
*/
42-
public function addArgument(string $name, Type $type, ?string $description = null) : self
42+
public function addArgument(string $name, Type $type, ?string $description = null): self
4343
{
4444
$this->parameters['args'][$name] = ['type' => $type];
4545

@@ -55,7 +55,7 @@ public function addArgument(string $name, Type $type, ?string $description = nul
5555
*
5656
* @return static
5757
*/
58-
public function setResolver(callable $resolver) : self
58+
public function setResolver(callable $resolver): self
5959
{
6060
$this->parameters['resolve'] = $resolver;
6161

@@ -65,7 +65,7 @@ public function setResolver(callable $resolver) : self
6565
/**
6666
* @return static
6767
*/
68-
public function setDeprecationReason(string $reason) : self
68+
public function setDeprecationReason(string $reason): self
6969
{
7070
$this->parameters['deprecationReason'] = $reason;
7171

@@ -75,7 +75,7 @@ public function setDeprecationReason(string $reason) : self
7575
/**
7676
* @return mixed[]
7777
*/
78-
public function build() : array
78+
public function build(): array
7979
{
8080
return $this->parameters;
8181
}

0 commit comments

Comments
 (0)