Skip to content

Switch to GH Actions #670

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

Merged
merged 8 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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
33 changes: 33 additions & 0 deletions .github/workflows/code-cov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Code Coverage"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

jobs:
tests:
name: "Code Coverage"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
extensions: "intl, zip"
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
php-version: "7.4"
tools: composer
coverage: xdebug2

- name: "Update dependencies"
run: "composer update ${{ env.COMPOSER_FLAGS }}"

- name: "Run coverage"
run: "composer coverage"
79 changes: 79 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Continuous Integration"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

jobs:
tests:
name: "CI"

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}

strategy:
matrix:
php-version:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
# - "8.0"
dependencies: [highest]
experimental: [false]
include:
- php-version: "5.3"
dependencies: highest
experimental: false
- php-version: "5.3"
dependencies: lowest
experimental: false
# - php-version: "8.0"
# dependencies: highest
# experimental: false
# - php-version: "8.1"
# dependencies: lowest-ignore
# experimental: true
# - php-version: "8.1"
# dependencies: highest-ignore
# experimental: true

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
php-version: "${{ matrix.php-version }}"
tools: composer

- name: "Handle lowest dependencies update"
if: "contains(matrix.dependencies, 'lowest')"
run: "echo \"COMPOSER_UPDATE_FLAGS=$COMPOSER_UPDATE_FLAGS --prefer-lowest\" >> $GITHUB_ENV"

- name: "Handle ignore-platform-reqs dependencies update"
if: "contains(matrix.dependencies, 'ignore')"
run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --ignore-platform-req=php\" >> $GITHUB_ENV"

- name: "Update dependencies"
run: "composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}"

- name: "Validate composer.json"
run: "composer validate"

- name: "Run tests"
run: "composer test"


34 changes: 34 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "PHPStan"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

jobs:
tests:
name: "PHPStan"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1"
php-version: "7.4"

- name: "Update dependencies"
run: "composer update ${{ env.COMPOSER_FLAGS }}"

- name: Run PHPStan
run: |
composer require --dev phpstan/phpstan:^0.12.93 marc-mabe/php-enum-phpstan ${{ env.COMPOSER_FLAGS }}
vendor/bin/phpstan analyse
33 changes: 33 additions & 0 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Style Check"

on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

jobs:
tests:
name: "Style Check"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
php-version: "7.4"
tools: composer

- name: "Update dependencies"
run: "composer update ${{ env.COMPOSER_FLAGS }}"

- name: "Run style-check"
run: "composer style-check"
4 changes: 2 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
'phpdoc_no_package' => false,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'pre_increment' => false,
'increment_style' => false,
'simplified_null_return' => false,
'trailing_comma_in_multiline_array' => false,
'single_line_throw' => false,
'trailing_comma_in_multiline' => false,
'yoda_style' => false,
'phpdoc_types_order' => array('null_adjustment' => 'none', 'sort_algorithm' => 'none'),
'no_superfluous_phpdoc_tags' => false,
Expand Down
43 changes: 0 additions & 43 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,6 +1,6 @@
# JSON Schema for PHP

[![Build Status](https://travis-ci.org/justinrainbow/json-schema.svg?branch=master)](https://travis-ci.org/justinrainbow/json-schema)
[![Build Status](https://github.com/justinrainbow/json-schema/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/justinrainbow/json-schema/actions)
[![Latest Stable Version](https://poser.pugx.org/justinrainbow/json-schema/v/stable.png)](https://packagist.org/packages/justinrainbow/json-schema)
[![Total Downloads](https://poser.pugx.org/justinrainbow/json-schema/downloads.png)](https://packagist.org/packages/justinrainbow/json-schema)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"icecave/parity": "1.0.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1",
"friendsofphp/php-cs-fixer": "~2.2.20 || ^2.15.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pinned due to an issue with newer minor versions of php-cs-fixer rewriting code in a way that actually caused logic changes, without warning. I would prefer to continue with pinning specific versions if possible, as this happened on multiple occasions with different versions of php-cs-fixer.

Is there are strong reason that requires loosening this constraint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason was allowing it to install fine on PHP 8 in development, because 2.15 requires php 5/7. But I'm happy to pin it to 2.19 instead to avoid surprises in the future.

"json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.35"
},
Expand Down
12 changes: 12 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
ignoreErrors:
-
message: "#^PHPDoc tag @throws with type JsonSchema\\\\Exception\\\\ExceptionInterface is not subtype of Throwable$#"
count: 1
path: src/JsonSchema/Constraints/ConstraintInterface.php

-
message: "#^Access to an undefined property object\\:\\:\\$properties\\.$#"
count: 3
path: src/JsonSchema/SchemaStorage.php

9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: 2
paths:
- ./src/
ignoreErrors: []

includes:
- phpstan-baseline.neon
- vendor/marc-mabe/php-enum-phpstan/extension.neon
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected function checkArray(&$value, $schema = null, JsonPointer $path = null,
protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
$additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
{
/** @var ObjectConstraint $validator */
$validator = $this->factory->createInstanceFor('object');
$validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);

Expand Down Expand Up @@ -119,6 +120,7 @@ protected function checkType(&$value, $schema = null, JsonPointer $path = null,
*/
protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
{
/** @var UndefinedConstraint $validator */
$validator = $this->factory->createInstanceFor('undefined');

$validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
Expand Down
7 changes: 5 additions & 2 deletions src/JsonSchema/Constraints/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function setConstraintClass($name, $class)
* @throws InvalidArgumentException if is not possible create the constraint instance
*
* @return ConstraintInterface|ObjectConstraint
* @phpstan-return ConstraintInterface&BaseConstraint
*/
public function createInstanceFor($constraintName)
{
Expand All @@ -202,7 +203,8 @@ public function createInstanceFor($constraintName)
/**
* Get the error context
*
* @return string
* @return int
* @phpstan-return Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION
*/
public function getErrorContext()
{
Expand All @@ -212,7 +214,8 @@ public function getErrorContext()
/**
* Set the error context
*
* @param string $validationContext
* @param int $errorContext
* @phpstan-param Validator::ERROR_DOCUMENT_VALIDATION|Validator::ERROR_SCHEMA_VALIDATION $errorContext
*/
public function setErrorContext($errorContext)
{
Expand Down
13 changes: 7 additions & 6 deletions src/JsonSchema/Constraints/TypeConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ public function check(&$value = null, $schema = null, JsonPointer $path = null,
* of $isValid to true, if at least one $type mateches the type of $value or the value
* passed as $isValid is already true.
*
* @param mixed $value Value to validate
* @param array $type TypeConstraints to check against
* @param array $validTypesWording An array of wordings of the valid types of the array $type
* @param bool $isValid The current validation value
* @param $path
* @param mixed $value Value to validate
* @param array $type TypeConstraints to check against
* @param array $validTypesWording An array of wordings of the valid types of the array $type
* @param bool $isValid The current validation value
* @param ?JsonPointer $path
* @param bool $coerce
*/
protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path, $coerce = false)
{
Expand Down Expand Up @@ -239,7 +240,7 @@ protected function validateType(&$value, $type, $coerce = false)
/**
* Converts a value to boolean. For example, "true" becomes true.
*
* @param $value The value to convert to boolean
* @param mixed $value The value to convert to boolean
*
* @return bool|mixed
*/
Expand Down