Skip to content

Commit

Permalink
Merge pull request #22 from tflori/github-actions
Browse files Browse the repository at this point in the history
use github actions for CI and add compatibility to php 8
  • Loading branch information
tflori authored Mar 18, 2022
2 parents 7aa07a8 + e8441c9 commit cc29c35
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 287 deletions.
30 changes: 30 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "2"

checks:
method-complexity:
config:
threshold: 9

exclude_patterns:
- "config/"
- "db/"
- "dist/"
- "docs/"
- "features/"
- "**/node_modules/"
- "script/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- "Tests/"
- "example.php"
- "examples/"
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"

plugins:
phpcodesniffer:
enabled: true
config:
standard: "PSR2"
81 changes: 81 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on: [push, pull_request]
jobs:
before:
runs-on: ubuntu-latest
steps:
- name: Prepare CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
unit-tests:
needs: [before]
strategy:
matrix:
include:
- image: 'iras/php7-composer:1'
php_version: 7.1
- image: 'iras/php7-composer:2'
php_version: 7.2
- image: 'iras/php7-composer:3'
php_version: 7.3
- image: 'iras/php7-composer:4'
php_version: 7.4
- image: 'iras/php8-composer:0'
php_version: 8.0
name: PHP Unit Tests on PHP ${{ matrix.php_version }}
runs-on: ubuntu-latest
container: ${{ matrix.image }}
steps:
- name: Container Setup
run: |
apk add --no-cache tar openssl
mkdir coverage
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO /usr/bin/cc-test-reporter
chmod +x /usr/bin/cc-test-reporter
- name: Checkout
run: |
git init && git remote add origin https://github.com/${{ github.repository }}.git
git fetch origin ${{ github.sha }} && git reset --hard ${{ github.sha }}
- uses: actions/cache@v2
with:
path: /composer/cache
key: composer-cache-7.${{ matrix.MINOR_VERSION }}
- name: Install dependencies
run: composer install --no-interaction --ansi
- name: Execute tests
run: |
php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit \
-c phpunit.xml \
--coverage-clover=coverage/clover.xml \
--coverage-text \
--color=always
- name: Format Coverage
run: |
cc-test-reporter format-coverage -t clover -o coverage/cc-${{ matrix.php_version }}.json coverage/clover.xml
- name: Store Coverage Result
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage/

after:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- name: Restore Coverage Result
uses: actions/download-artifact@v3
with:
name: coverage-results
path: coverage/
- name: Report Coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter sum-coverage coverage/cc-*.json -p 5 -o coverage/cc-total.json
./cc-test-reporter upload-coverage -i coverage/cc-total.json
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ composer.phar
# ide settings
/.idea*

# phpunit result
/.phpunit.result.cache

# rendered documentation
/docs/_site
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# tflori/verja

[![Build Status](https://travis-ci.org/tflori/verja.svg?branch=master)](https://travis-ci.org/tflori/verja)
[![Coverage Status](https://coveralls.io/repos/github/tflori/verja/badge.svg?branch=master)](https://coveralls.io/github/tflori/verja?branch=master)
[![.github/workflows/push.yml](https://github.com/tflori/verja/actions/workflows/push.yml/badge.svg)](https://github.com/tflori/verja/actions/workflows/push.yml)
[![Test Coverage](https://api.codeclimate.com/v1/badges/e07f4d5da0789699e27c/test_coverage)](https://codeclimate.com/github/tflori/verja/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/e07f4d5da0789699e27c/maintainability)](https://codeclimate.com/github/tflori/verja/maintainability)
[![Latest Stable Version](https://poser.pugx.org/tflori/verja/v/stable.svg)](https://packagist.org/packages/tflori/verja)
[![Total Downloads](https://poser.pugx.org/tflori/verja/downloads.svg)](https://packagist.org/packages/tflori/verja)
[![License](https://poser.pugx.org/tflori/verja/license.svg)](https://packagist.org/packages/tflori/verja)
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"description": "An validation tool for arrays filled by foreign input",
"license": "MIT",
"require": {
"php": "^7.0",
"php": "^7.0 || ^8.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"mockery/mockery": "^0.9",
"squizlabs/php_codesniffer": "^2.7",
"tflori/dependency-injector": "^1.3",
"nesbot/carbon": "^1.23"
"phpunit/phpunit": "*",
"tflori/phpunit-printer": "*",
"mockery/mockery": "^1.1",
"squizlabs/php_codesniffer": "^3.5",
"tflori/dependency-injector": "^2.2",
"nesbot/carbon": "^2.53"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
printerClass="\Verja\Test\Printer">
printerClass="PhpUnitPrinter\TextPrinter">
<testsuite name="tests">
<directory>./tests/</directory>
</testsuite>
Expand Down
6 changes: 3 additions & 3 deletions tests/ErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function errorsCanBeSerialized()

$serialized = serialize($error);

self::assertContains('ERROR_KEY', $serialized);
self::assertContains('validated value', $serialized);
self::assertContains('Error message from validator', $serialized);
self::assertStringContainsString('ERROR_KEY', $serialized);
self::assertStringContainsString('validated value', $serialized);
self::assertStringContainsString('Error message from validator', $serialized);
}

/** @test */
Expand Down
3 changes: 0 additions & 3 deletions tests/Field/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Verja\Test\Field;

use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Verja\Field;
use Verja\Gate;
use Verja\Test\Examples\NotSerializable;
Expand All @@ -13,8 +12,6 @@

class ValidatorTest extends TestCase
{
use MockeryPHPUnitIntegration;

/** @dataProvider provideValidatorsValueExpected
* @param ValidatorInterface[] $validators
* @param mixed $value
Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class DateTimeTest extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
date_default_timezone_set('Europe/Berlin');
Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/EscapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function doesNotConvertNonStrings()

$filtered = $filter->filter(42);

self::assertInternalType('integer', $filtered);
self::assertIsInt($filtered);
}

/** @dataProvider provideStringsWithHtmlEntities
Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/FromStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class FromStringTest extends TestCase
{
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
Filter::resetNamespaces();
Expand Down
Loading

0 comments on commit cc29c35

Please sign in to comment.