Skip to content
Permalink
Browse files

Merge pull request #1 from Lctrs/init

Initial version
  • Loading branch information
Lctrs committed Feb 4, 2020
2 parents 71a9c42 + 9de57b6 commit d972aa970004fba53b410f09f39c3d58eed796d3
@@ -7,7 +7,7 @@ update_configs:
- "dependency"
directory: "/"
package_manager: "github_actions"
update_schedule: "daily"
update_schedule: "monthly"

- automerged_updates:
- match:
@@ -19,5 +19,5 @@ update_configs:
- "dependency"
directory: "/"
package_manager: "php:composer"
update_schedule: "live"
update_schedule: "monthly"
version_requirement_updates: "increase_versions"
@@ -10,13 +10,16 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.feature]
indent_size = 2

[*.json{,.dist}]
indent_size = 2

[*.neon{,.dist}]
indent_style = tab

[*.{yml,yaml}{,.dist}]
[*{,.dist}.{yml,yaml}{,.dist}]
indent_size = 2

[Makefile]
@@ -4,7 +4,7 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/infection.json.dist export-ignore
/codeception.dist.yml export-ignore
/Makefile export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
@@ -16,18 +16,6 @@ $ make coding-standards

to automatically fix coding standard violations.

## Dependency Analysis

We are using [`maglnet/composer-require-checker`](https://github.com/maglnet/ComposerRequireChecker) to prevent the use of unknown symbols in production code.

Run

```
$ make dependency-analysis
```

to run a dependency analysis.

## Static Code Analysis

We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
@@ -54,7 +42,7 @@ to regenerate the baselines in [`../phpstan-baseline.neon`](../phpstan-baseline.

## Tests

We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development.
We are using [`codeception/codeception`](https://github.com/Codeception/Codeception) to drive the development.

Run

@@ -64,18 +52,6 @@ $ make tests

to run all the tests.

## Mutation Tests

We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `pcov` or `Xdebug` and run

```
$ make mutation-tests
```

to run mutation tests.

## Extra lazy?

Run
@@ -15,7 +15,6 @@ branches:
required_status_checks:
contexts:
- "Coding Standards (7.2, locked)"
- "Dependency Analysis (7.4, locked)"
- "Static Code Analysis (7.4, locked)"
- "Tests (7.2, lowest)"
- "Tests (7.2, locked)"
@@ -26,10 +25,6 @@ branches:
- "Tests (7.4, lowest)"
- "Tests (7.4, locked)"
- "Tests (7.4, highest)"
- "Code Coverage (7.4, locked)"
- "Mutation Tests (7.4, locked)"
- "codecov/patch"
- "codecov/project"
strict: false
restrictions: null

@@ -70,15 +65,15 @@ repository:
archived: false
default_branch: "master"
delete_branch_on_merge: true
description: ":octocat: + :ledger: Provides a GitHub repository template for a PHP library, using GitHub actions."
description: "Let Psalm understand better psr11 containers"
has_downloads: true
has_issues: true
has_pages: false
has_projects: false
has_wiki: false
name: "php-library-skeleton"
name: "psalm-psr-container-plugin"
private: false

# https://developer.github.com/v3/repos/branches/#remove-branch-protection

topics: "php, library, template, skeleton"
topics: "psalm, plugin, psr, psr11, container"
@@ -9,8 +9,6 @@ on:
- "master"

env:
MIN_COVERED_MSI: 100
MIN_MSI: 100
REQUIRED_PHP_EXTENSIONS: "mbstring"

jobs:
@@ -76,52 +74,6 @@ jobs:
- name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/phpcs"

dependency-analysis:
name: "Dependency Analysis"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

dependencies:
- "locked"

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

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.7.4"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
php-version: "${{ matrix.php-version }}"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install lowest dependencies with composer"
if: "matrix.dependencies == 'lowest'"
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"

- name: "Install locked dependencies with composer"
if: "matrix.dependencies == 'locked'"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies with composer"
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Run maglnet/composer-require-checker"
run: "vendor/bin/composer-require-checker"

static-code-analysis:
name: "Static Code Analysis"

@@ -224,122 +176,16 @@ jobs:
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Run auto-review tests with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml.dist"

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Unit/phpunit.xml.dist"

- name: "Run integration tests with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Integration/phpunit.xml.dist"

code-coverage:
name: "Code Coverage"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

dependencies:
- "locked"

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

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.7.4"
with:
coverage: "pcov"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
php-version: "${{ matrix.php-version }}"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install lowest dependencies with composer"
if: "matrix.dependencies == 'lowest'"
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"

- name: "Install locked dependencies with composer"
if: "matrix.dependencies == 'locked'"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies with composer"
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Collect code coverage with pcov and phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Unit/phpunit.xml.dist --coverage-clover=.build/logs/clover.xml"

- name: "Send code coverage report to Codecov.io"
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
run: "bash <(curl -s https://codecov.io/bash)"

mutation-tests:
name: "Mutation Tests"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

dependencies:
- "locked"

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

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.7.4"
with:
coverage: "pcov"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
php-version: "${{ matrix.php-version }}"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install lowest dependencies with composer"
if: "matrix.dependencies == 'lowest'"
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"

- name: "Install locked dependencies with composer"
if: "matrix.dependencies == 'locked'"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies with composer"
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Run mutation tests with pcov and infection/infection"
run: "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${{ env.MIN_COVERED_MSI }} --min-msi=${{ env.MIN_MSI }}"
- name: "Run acceptance tests with codeception/codeception"
run: "vendor/bin/codecept run --config=codeception.dist.yml --steps"

review:
name: "Review"

runs-on: "ubuntu-latest"

needs:
- "code-coverage"
- "coding-standards"
- "dependency-analysis"
- "mutation-tests"
- "static-code-analysis"
- "tests"

@@ -1,6 +1,5 @@
/.build
/test/*/phpunit.xml
/.build/
/vendor/
/infection.json
/codeception.yml
/phpcs.xml
/phpstan.neon
@@ -8,4 +8,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

For a full diff see [`1902cc2...master`][1902cc2...master].

[1902cc2...master]: https://github.com/Lctrs/php-library-skeleton/compare/1902cc2...master
[1902cc2...master]: https://github.com/Lctrs/psalm-psr-container-plugin/compare/1902cc2...master
@@ -1,8 +1,5 @@
MIN_COVERED_MSI:=100
MIN_MSI:=100

.PHONY: it
it: coding-standards dependency-analysis static-code-analysis tests ## Runs the coding-standards, dependency-analysis, static-code-analysis, and tests targets
it: coding-standards static-code-analysis tests ## Runs the coding-standards, dependency-analysis, static-code-analysis, and tests targets

.PHONY: code-coverage
code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit
@@ -14,19 +11,10 @@ coding-standards: vendor ## Fixes code style issues with doctrine/coding-standar
vendor/bin/phpcbf
vendor/bin/phpcs

.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
vendor/bin/composer-require-checker

.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: mutation-tests
mutation-tests: vendor ## Runs mutation tests with infection/infection
mkdir -p .build/infection
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${MIN_COVERED_MSI} --min-msi=${MIN_MSI}

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
mkdir -p .build/phpstan
@@ -43,11 +31,8 @@ static-code-analysis-baseline: vendor ## Generates a baseline for static code an
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml

.PHONY: tests
tests: vendor ## Runs auto-review, unit, and integration tests with phpunit/phpunit
mkdir -p .build/phpunit
vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml.dist
vendor/bin/phpunit --configuration=test/Unit/phpunit.xml.dist
vendor/bin/phpunit --configuration=test/Integration/phpunit.xml.dist
tests: vendor ## Runs acceptance tests with codeception/codeception
vendor/bin/codecept run --config=codeception.dist.yml --steps

vendor: composer.json composer.lock
composer validate --strict

0 comments on commit d972aa9

Please sign in to comment.
You can’t perform that action at this time.