Skip to content

Commit

Permalink
Add GitHub actions (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 21, 2020
1 parent 3f789db commit 7f03103
Show file tree
Hide file tree
Showing 9 changed files with 326 additions and 37 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,95 @@
on:
- pull_request
- push

name: build

jobs:
tests:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

env:
extensions: pdo, pdo_oci, oci8
key: cache-v1

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "7.4"
- "8.0"

services:
oci:
image: wnameless/oracle-xe-11g-r2:latest
ports:
- 1521:1521
options: --name=oci

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

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: date.timezone='UTC'
coverage: pcov
tools: composer:v2

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Update composer
run: composer self-update

- name: Install dependencies with composer php 7.4
if: matrix.php == '7.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with composer php 8.0
if: matrix.php == '8.0'
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit and coverage on Linux php 7.4
if: matrix.os == 'ubuntu-latest' && matrix.php == '7.4'
run: vendor/bin/phpunit --coverage-clover=coverage.clover --colors=always

- name: Run tests with phpunit without coverage
if: matrix.os != 'ubuntu-latest' || matrix.php != '7.4'
run: vendor/bin/phpunit --colors=always

- name: Upload code coverage scrutinizer on Linux php 7.4
if: matrix.php == '7.4'
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
64 changes: 64 additions & 0 deletions .github/workflows/mutation.yml
@@ -0,0 +1,64 @@
on:
pull_request:
push:
branches:
- "master"

name: mutation

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

env:
extensions: pdo, pdo_oci, oci8

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "7.4"

services:
oci:
image: wnameless/oracle-xe-11g-r2:latest
ports:
- 1521:1521
options: --name=oci

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: ${{ env.extensions }}
ini-values: memory_limit=-1
coverage: "pcov"
tools: composer:v2, pecl

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v2.1.1
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Run infection
run: |
git fetch --depth=1 origin $GITHUB_BASE_REF
vendor/bin/roave-infection-static-analysis-plugin -j2 --git-diff-filter=A --git-diff-base=origin/$GITHUB_BASE_REF --logger-github --ignore-msi-with-no-mutations --only-covered
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
47 changes: 47 additions & 0 deletions .github/workflows/static.yml
@@ -0,0 +1,47 @@
name: static analysis

on:
- pull_request
- push

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "7.4"

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

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

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Static analysis
run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize
24 changes: 4 additions & 20 deletions .scrutinizer.yml
Expand Up @@ -5,6 +5,10 @@ filter:
paths:
- "src/*"

tools:
php_code_coverage:
enabled: true

build:
nodes:
analysis:
Expand All @@ -14,23 +18,3 @@ build:
tests:
override:
- php-scrutinizer-run

tests-and-coverage:
environment:
php: 7.4.12

dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
-
command: "./vendor/bin/phpunit --coverage-clover ./coverage.xml"
on_node: 1
coverage:
file: coverage.xml
format: php-clover


52 changes: 51 additions & 1 deletion README.md
Expand Up @@ -14,7 +14,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).

[![Latest Stable Version](https://poser.pugx.org/yiisoft/db-oracle/v/stable.png)](https://packagist.org/packages/yiisoft/db-oracle)
[![Total Downloads](https://poser.pugx.org/yiisoft/db-oracle/downloads.png)](https://packagist.org/packages/yiisoft/db-oracle)
[![Build Status](https://travis-ci.com/yiisoft/db-oracle.svg?branch=master)](https://travis-ci.com/yiisoft/db-oracle)
[![Build status](https://github.com/yiisoft/db-oracle/workflows/build/badge.svg)](https://github.com/yiisoft/db-oracle/actions?query=workflow%3Abuild)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/db-oracle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/db-oracle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/db-oracle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/db-oracle/?branch=master)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-oracle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-oracle/master)
[![static analysis](https://github.com/yiisoft/db-oracle/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/db-oracle/actions?query=workflow%3A%22static+analysis%22)
[![type-coverage](https://shepherd.dev/github/yiisoft/db-oracle/coverage.svg)](https://shepherd.dev/github/yiisoft/db-oracle)


Installation
Expand All @@ -35,3 +40,48 @@ or add
```

to the require section of your composer.json.

## General usage

### Unit testing

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```shell
./vendor/bin/phpunit
```

### Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework. To run it:

```shell
./vendor/bin/infection
```

### Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
./vendor/bin/psalm
```

### Support the project

[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective&logoColor=7eadf1&labelColor=555555)](https://opencollective.com/yiisoft)

### Follow updates

[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)
[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/yiiframework)
[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat&logo=telegram)](https://t.me/yii3en)
[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat&logo=facebook&logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)
[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat&logo=slack)](https://yiiframework.com/go/slack)

## License

The Yii Framework Oracle Extension is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE.md) for more information.

Maintained by [Yii Software](https://www.yiiframework.com/).
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -29,12 +29,13 @@
"php": "^7.4|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^9.4",
"roave/infection-static-analysis-plugin": "^1.3",
"vimeo/psalm": "^4.1",
"yiisoft/active-record": "dev-master",
"yiisoft/di": "dev-master",
"yiisoft/log": "dev-master",
"yiisoft/cache": "dev-master",
"phan/phan": "^3.0"
"yiisoft/cache": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 16 additions & 0 deletions infection.json.dist
@@ -0,0 +1,16 @@
{
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "php:\/\/stderr",
"badge": {
"branch": "master"
}
},
"mutators": {
"@default": true
}
}
43 changes: 30 additions & 13 deletions phpunit.xml.dist
@@ -1,14 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="./vendor/autoload.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
colors="true"
verbose="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
executionOrder="default"
resolveDependencies="true">

<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Oracle">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 7f03103

Please sign in to comment.