Skip to content

Commit

Permalink
Add full CI
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Feb 10, 2021
1 parent 0e10e73 commit cf974cf
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 180 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Expand Up @@ -3,9 +3,11 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.phpstorm.meta.php export-ignore
/infection.json.dist export-ignore
/Makefile export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/tests export-ignore
208 changes: 72 additions & 136 deletions .github/workflows/ci.yaml
@@ -1,138 +1,74 @@
name: CI
on:
pull_request:
push:
branches:
- "master"
schedule:
- cron: "0 17 * * *"
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.4]
dependencies: ["", --prefer-lowest]
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
tools: cs2pr

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}-dependencies-${{ matrix.dependencies }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
env:
COMPOSER_ARGS: "--prefer-stable ${{ matrix.dependencies }}"
run: make

- name: Run a static analysis with phpstan/phpstan
env:
PHPSTAN_ARGS: --error-format=checkstyle
run: make -is static-analysis | cs2pr

coding-standards:
name: Coding Standards
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.4]
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
tools: cs2pr

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
env:
COMPOSER_ARGS: "--prefer-stable"
run: make

- name: Run squizlabs/php_codesniffer
env:
PHPCS_ARGS: -q --no-colors --report=checkstyle
run: make -is cs | cs2pr

tests:
name: Tests
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.4, 8.0]
dependencies: ["", --prefer-lowest]
name: "CI"

steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}-dependencies-${{ matrix.dependencies }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
env:
COMPOSER_ARGS: "--prefer-stable ${{ matrix.dependencies }}"
run: make

- name: Run tests
run: make test

coverage:
name: Tests Coverage
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.4]

steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: pcov
php-version: ${{ matrix.php-version }}

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
env:
COMPOSER_ARGS: "--prefer-stable"
run: make

- name: Run tests coverage
env:
PHPUNIT_ARGS: "--coverage-clover coverage/clover.xml"
run: make test
on:
pull_request:
push:
# branches:
# - "master"
schedule:
- cron: "42 3 * * *"

- name: Report to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_RUN_LOCALLY: 1
run: vendor/bin/php-coveralls --coverage_clover coverage/clover.xml --json_path coverage/coveralls.json
jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.4"
- "8.0"
dependencies:
- "highest"
include:
- dependencies: "lowest"
php-version: "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"

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

- name: "Run PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
needs:
- "phpunit"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v2"
with:
path: "reports"

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v1"
with:
directory: reports
29 changes: 29 additions & 0 deletions .github/workflows/coding-standards.yaml
@@ -0,0 +1,29 @@
name: "Coding Standards"

on:
pull_request:
push:
# branches:
# - "master"

jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-20.04"

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
coverage: "none"
tools: "cs2pr, pecl"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run PHP_CodeSniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
31 changes: 31 additions & 0 deletions .github/workflows/infection.yaml
@@ -0,0 +1,31 @@
name: Infection

on:
pull_request:
push:
# branches:
# - "master"

jobs:
Infection:
runs-on: ubuntu-20.04

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
coverage: "pcov"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: Run Infection
run: vendor/bin/roave-infection-static-analysis-plugin --min-msi=60 --min-covered-msi=93 --log-verbosity=none -s
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
52 changes: 52 additions & 0 deletions .github/workflows/static-analysis.yaml
@@ -0,0 +1,52 @@
name: "Static Analysis"

on:
pull_request:
push:
# branches:
# - "master"

jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
coverage: "none"
tools: "cs2pr, pecl"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"

static-analysis-psalm:
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"

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

- name: Psalm
uses: docker://vimeo/psalm-github-actions:4.4.1
with:
args: --shepherd
composer_ignore_platform_reqs: true
composer_require_dev: true
security_analysis: true
report_file: results.sarif
env:
CHECK_PLATFORM_REQUIREMENTS: "false"
- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,7 +1,9 @@
/.phpcs-cache
/.phpunit.result.cache
/composer.lock
/infection.json
/phpcs.xml
/phpstan.neon
/psalm.xml
/phpunit.xml
/vendor/
31 changes: 28 additions & 3 deletions README.md
@@ -1,8 +1,11 @@
# Cdn77 TestUtils

[![Build Status](https://github.com/cdn77/TestUtils/workflows/CI/badge.svg?branch=master)](https://github.com/cdn77/TestUtils/actions)
[![Coverage Status](https://coveralls.io/repos/github/cdn77/TestUtils/badge.svg?branch=master)](https://coveralls.io/github/cdn77/TestUtils?branch=master)
[![Downloads](https://poser.pugx.org/cdn77/test-utils/d/total.svg)](https://packagist.org/packages/cdn77/test-utils)
[![GitHub Actions][GA Image]][GA Link]
[![Shepherd Type][Shepherd Image]][Shepherd Link]
[![Code Coverage][Coverage Image]][CodeCov Link]
[![Downloads][Downloads Image]][Packagist Link]
[![Packagist][Packagist Image]][Packagist Link]
[![Infection MSI][Infection Image]][Infection Link]

## Contents

Expand Down Expand Up @@ -235,3 +238,25 @@ yield 'Every test is final' => [
new EveryTestIsFinal($testFiles),
];
```

[GA Image]: https://github.com/cdn77/TestUtils/workflows/CI/badge.svg

[GA Link]: https://github.com/cdn77/TestUtils/actions?query=workflow%3A%22CI%22+branch%3Amaster

[Shepherd Image]: https://shepherd.dev/github/cdn77/TestUtils/coverage.svg

[Shepherd Link]: https://shepherd.dev/github/cdn77/TestUtils

[Coverage Image]: https://codecov.io/gh/cdn77/TestUtils/branch/master/graph/badge.svg

[CodeCov Link]: https://codecov.io/gh/cdn77/TestUtils/branch/master

[Downloads Image]: https://poser.pugx.org/simpod/test-utils/d/total.svg

[Packagist Image]: https://poser.pugx.org/simpod/test-utils/v/stable.svg

[Packagist Link]: https://packagist.org/packages/simpod/test-utils

[Infection Image]: https://badge.stryker-mutator.io/github.com/cdn77/TestUtils/master

[Infection Link]: https://infection.github.io

0 comments on commit cf974cf

Please sign in to comment.