Skip to content

Migrate to github actions, stable phpstan #64

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

Closed
Closed
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
pull-request-branch-name:
separator: '-'
- package-ecosystem: composer
directory: '/'
versioning-strategy: widen
schedule:
interval: weekly
pull-request-branch-name:
separator: '-'
open-pull-requests-limit: 10
88 changes: 88 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Continuous Integration

on:
pull_request: ~
push:
branches:
- master

jobs:

continuous-integration:
name: Continuous Integration

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
dependencies:
- 'highest'
phpunit-args:
- ''
include:
- php-version: '7.2'
dependencies: 'lowest'
- php-version: '8.1'
dependencies: 'lowest'
- php-version: '8.1'
coverage: 'pcov'
phpunit-args: '--coverage-clover coverage.xml'

steps:
# Cancel previous runs of the same branch
- name: cancel
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
tools: composer:v2
coverage: '${{ matrix.coverage }}'

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
with:
dependency-versions: '${{ matrix.dependencies }}'

- name: Validate composer
run: composer validate --strict --no-check-lock

- name: Run php_codesniffer
run: composer cs-check
if: ${{ matrix.php-version == '7.2' }} # Do not suggest using features after 7.2

- name: phpstan-cache
uses: actions/cache@v2
with:
key: phpstan-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ github.ref }}-${{ github.sha }}
path: .phpstan-cache
restore-keys: |
phpstan-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ github.ref }}-
phpstan-${{ matrix.php-version }}-${{ matrix.dependencies }}-
phpstan-${{ matrix.php-version }}-
phpstan-

- name: Run phpstan
run: composer phpstan

- name: Run PHPUnit
run: vendor/bin/phpunit ${{ matrix.phpunit-args }}

- name: Upload coverage results to Coveralls
run: vendor/bin/php-coveralls --coverage_clover=coverage.xml --json_path=coveralls.json -v
if: ${{ matrix.coverage }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/build
.php_cs_cache
.phpunit.result.cache
.phpstan-cache
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/graphqlite-symfony-validator-bridge/v/stable)](https://packagist.org/packages/thecodingmachine/graphqlite-symfony-validator-bridge)
[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/graphqlite-symfony-validator-bridge/v/unstable)](https://packagist.org/packages/thecodingmachine/graphqlite-symfony-validator-bridge)
[![License](https://poser.pugx.org/thecodingmachine/graphqlite-symfony-validator-bridge/license)](https://packagist.org/packages/thecodingmachine/graphqlite-symfony-validator-bridge)
[![Build Status](https://travis-ci.org/thecodingmachine/graphqlite-symfony-validator-bridge.svg?branch=master)](https://travis-ci.org/thecodingmachine/graphqlite-symfony-validator-bridge)
[![Build Status](https://github.com/thecodingmachine/graphqlite-symfony-validator-bridge/workflows/Continuous%20Integration/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/thecodingmachine/graphqlite-symfony-validator-bridge/badge.svg?branch=master&service=github)](https://coveralls.io/github/thecodingmachine/graphqlite-symfony-validator-bridge?branch=master)


Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
"php" : ">=7.2",
"thecodingmachine/graphqlite" : "^5.0",
"symfony/validator": "^4.2 | ^5",
"doctrine/annotations": "^1.6"
"doctrine/annotations": "^1.13"
},
"require-dev": {
"phpunit/phpunit": "^8.4.1",
"phpunit/phpunit": "^8.5.28 | ^9.5",
"mouf/picotainer": "^1.1",
"phpstan/phpstan": "^0.12.14",
"phpstan/phpstan": "^1.8.2",
"php-coveralls/php-coveralls": "^2.1.0",
"symfony/translation": "^4",
"doctrine/coding-standard": "^9.0"
},
"scripts": {
"phpstan": "phpstan analyse src/ -c phpstan.neon --level=7 --no-progress",
"phpstan": "phpstan analyse --no-progress",
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": ["@cs-check", "@phpstan", "phpunit"]
Expand All @@ -46,6 +46,11 @@
"TheCodingMachine\\GraphQLite\\Validator\\" : "tests/"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "5.0.x-dev"
Expand Down
10 changes: 6 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
ignoreErrors:

#includes:
# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
tmpDir: .phpstan-cache
paths:
- src
level: max
20 changes: 18 additions & 2 deletions src/Annotations/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Symfony\Component\Validator\Constraint;
use TheCodingMachine\GraphQLite\Annotations\ParameterAnnotationInterface;

use function assert;
use function is_array;
use function is_string;
use function ltrim;

/**
Expand Down Expand Up @@ -41,8 +43,22 @@ public function __construct(array $values)
throw new BadMethodCallException('The @Assert annotation must be passed one or many constraints. For instance: "@Assert(for="$email", constraint=@Email)"');
}

$this->for = ltrim($values['for'], '$');
$this->constraint = is_array($values['constraint']) ? $values['constraint'] : [$values['constraint']];
assert(is_string($values['for']));
$for = ltrim($values['for'], '$');

$constraints = [];
if (is_array($values['constraint'])) {
foreach ($values['constraint'] as $constraint) {
assert($constraint instanceof Constraint);
$constraints[] = $constraint;
}
} else {
assert($values['constraint'] instanceof Constraint);
$constraints = [$values['constraint']];
}

$this->for = $for;
$this->constraint = $constraints;
}

public function getTarget(): string
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ public function testException(): void
$this->expectExceptionMessage('In method TheCodingMachine\GraphQLite\Validator\Fixtures\InvalidControllers\InvalidController::invalid(), the @Assert annotation is targeting parameter "$resolveInfo". You cannot target this parameter because it is not part of the GraphQL Input type. You can only assert parameters coming from the end user.');
$schema->validate();
}
}
}