From 8ea42bc25b0740a95fed576c5e44cbc94b69d45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 9 Sep 2019 10:19:11 +0200 Subject: [PATCH] Enhancement: Synchronize project tooling configuration with localheinz/php-library-template --- .editorconfig | 3 - .gitattributes | 5 +- .github/CONTRIBUTING.md | 24 ++-- .github/settings.yml | 17 ++- .github/workflows/continuous-integration.yml | 89 +++++++++++++++ .github/workflows/stale.yml | 26 +++++ .php_cs | 2 +- .travis.yml | 114 ------------------- .travis/xdebug.sh | 22 ---- CHANGELOG.md | 9 ++ LICENSE | 2 +- Makefile | 17 +-- README.md | 2 +- test/Unit/phpunit.xml | 3 + 14 files changed, 165 insertions(+), 170 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .github/workflows/stale.yml delete mode 100644 .travis.yml delete mode 100644 .travis/xdebug.sh create mode 100644 CHANGELOG.md diff --git a/.editorconfig b/.editorconfig index b0e92ec..59fb83d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,9 +10,6 @@ trim_trailing_whitespace = true [*.json] indent_size = 2 -[*.md] -trim_trailing_whitespace = false - [*.yml] indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 5e97056..f35f54a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,8 @@ /.dependabot/ export-ignore /.github/ export-ignore -/.travis/ export-ignore -/test export-ignore +/test/ export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore /.php_cs export-ignore -/.travis.yml export-ignore /Makefile export-ignore -/phpunit.xml export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1018cec..e00210a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,34 +1,34 @@ # CONTRIBUTING -We're using [Travis CI](https://travis-ci.com) as a continuous integration system. +We are using [GitHub Actions](https://github.com/features/actions) as a continuous integration system. -For details, see [`.travis.yml`](../.travis.yml). +For details, see [`workflows/continuous-integration.yml`](workflows/continuous-integration.yml). -## Tests +## Coding Standards -We're using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development. +We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards. Run ``` -$ make test +$ make cs ``` -to run all the tests. +to automatically fix coding standard violations. -## Coding Standards +## Extra lazy? -We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards. +## Tests + +We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development. Run ``` -$ make cs +$ make test ``` -to automatically fix coding standard violations. - -## Extra lazy? +to run all the tests. Run diff --git a/.github/settings.yml b/.github/settings.yml index 7133aca..34c12d7 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -10,10 +10,19 @@ branches: required_approving_review_count: 1 required_status_checks: contexts: - - "codecov/patch" - - "codecov/project" - - "Travis CI - Branch" - - "Travis CI - Pull Request" + - "Coding Standards" + - "Tests (php7.1, lowest)" + - "Tests (php7.1, locked)" + - "Tests (php7.1, highest)" + - "Tests (php7.2, lowest)" + - "Tests (php7.2, locked)" + - "Tests (php7.2, highest)" + - "Tests (php7.3, lowest)" + - "Tests (php7.3, locked)" + - "Tests (php7.3, highest)" + - "Code Coverage" + - "codecov/patch" + - "codecov/project" strict: false restrictions: null diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..39381aa --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,89 @@ +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions + +on: + - pull_request + - push + +name: "Continuous Integration" + +jobs: + coding-standards: + name: "Coding Standards" + + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: actions/checkout@master + + - name: "Validate composer.json and composer.lock" + run: php7.1 $(which composer) validate --strict + + - name: "Install locked dependencies with composer" + run: php7.1 $(which composer) install + + - name: "Run localheinz/composer-normalize" + run: php7.1 $(which composer) normalize --dry-run + + - name: "Run friendsofphp/php-cs-fixer" + run: php7.1 vendor/bin/php-cs-fixer fix --diff --dry-run --using-cache=no --verbose + + tests: + name: "Tests" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-binary: + - php7.1 + - php7.2 + - php7.3 + + dependencies: + - lowest + - locked + - highest + + steps: + - name: "Checkout" + uses: actions/checkout@master + + - name: "Install lowest dependencies with composer" + if: matrix.dependencies == 'lowest' + run: ${{ matrix.php-binary }} $(which composer) update --prefer-lowest + + - name: "Install locked dependencies with composer" + if: matrix.dependencies == 'locked' + run: ${{ matrix.php-binary }} $(which composer) install + + - name: "Install highest dependencies with composer" + if: matrix.dependencies == 'highest' + run: ${{ matrix.php-binary }} $(which composer) update + + - name: "Run unit tests with phpunit/phpunit" + run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=test/Unit/phpunit.xml + + code-coverage: + name: "Code Coverage" + + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: actions/checkout@master + + - name: "Install locked dependencies with composer" + run: php7.3 $(which composer) install + + - name: "Dump Xdebug filter with phpunit/phpunit" + run: php7.3 vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php + + - name: "Collect code coverage with Xdebug and phpunit/phpunit" + run: php7.3 vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml --prepend=.build/phpunit/xdebug-filter.php + + - name: "Download code coverage uploader for Codecov.io" + run: curl -s https://codecov.io/bash -o codecov + + - name: "Send code coverage report to Codecov.io" + run: bash codecov -t ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..fd56137 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,26 @@ +# https://github.com/actions/stale + +name: "Close stale issues and pull requests" +on: + schedule: + - cron: "0 * * * *" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 60 + days-before-close: 5 + stale-issue-label: 'stale' + stale-issue-message: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + stale-pr-message: > + This PR has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + stale-pr-label: 'stale' diff --git a/.php_cs b/.php_cs index 8348eed..cb1906b 100644 --- a/.php_cs +++ b/.php_cs @@ -29,8 +29,8 @@ $config->getFinder() ->in(__DIR__) ->exclude([ '.build', + '.dependabot', '.github', - '.travis', ]) ->name('.php_cs'); diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d89461a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,114 +0,0 @@ -language: php - -env: - global: - - secure: "WK9kQNN8xu2cBLAHCpgHYqoEF4Uuj2Q7c81EfDO3wJulGkR/NmKy5+KxwmwnPfVQTE/64FCAJJHMQefQIIe+JfQLn9X1SfIn0RYfj8UUtJw7DSMj0GD175fC23ThUt9fX/rubMjVvOxlC6ll/QAXeAWS1wERA1FrewC0i/x3/Z4I4NJ9lSeMRbE5tEzsvtwLfzR47hbvL4UFcziSg5vglzF1tyaEp8rYRihIT5jYcsprHSHmCIaRh6CIT+iixvofQQP2wfYg19jWfmBFlzeTk7GC5BE5IH7FInHOJq17+BRlHSPTCEZpqUhdewKcnHFWTuwfl2UXwvqJfU70Zj+7i/uGfr8u2kgK6WRW1FtyBLKkxdm4aZJdVhhMlTV6IsEtt1D6Rbg/UVyaFRZ/V+CxGm+Zi1+QtgTT66C9p73I5+j4YkXQUKpdG8yMnmVFDyf6Stl221XbXrjU3UPrCzTno/7Xaqr+IOfK4MNCZAhxfBW7c7HirhgQzZ9ym+YLbl4uAdc/uHJMGYESdBG/IQPUffVec5L8TbCuEH6iOgBj1WAZ4+P1wi2gLiCyaPB2WpMakCyErPc5QzPa6xUg1XCEP9FtmXPd8iWDIHHcLiZ5lke9ySHhCfj1CEX7VqXVHm+e8ui6FmXa2MKTGok0Bj/YZ1NIevu9ocIEN811qv9Xifk=" - -cache: - directories: - - $HOME/.composer/cache - - .build/php-cs-fixer - -stages: - - style - - test - -jobs: - include: - - stage: Style - - php: 7.1 - - before_install: - - source .travis/xdebug.sh - - xdebug-disable - - composer validate - - if [[ -n "$GITHUB_TOKEN" ]]; then composer config github-oauth.github.com $GITHUB_TOKEN; fi - - install: - - composer install - - before_script: - - mkdir -p .build/php-cs-fixer - - script: - - composer normalize --dry-run - - vendor/bin/php-cs-fixer fix --config=.php_cs --diff --dry-run --verbose - - - &TEST - - stage: Test - - php: 7.1 - - env: WITH_LOWEST=true - - before_install: - - source .travis/xdebug.sh - - xdebug-disable - - composer validate - - if [[ -n "$GITHUB_TOKEN" ]]; then composer config github-oauth.github.com $GITHUB_TOKEN; fi - - install: - - if [[ "$WITH_LOWEST" == "true" ]]; then composer update --prefer-lowest; fi - - if [[ "$WITH_LOCKED" == "true" ]]; then composer install; fi - - if [[ "$WITH_HIGHEST" == "true" ]]; then composer update; fi - - script: - - if [[ "$WITH_COVERAGE" == "true" ]]; then xdebug-enable; fi - - if [[ "$WITH_COVERAGE" == "true" ]]; then vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml; else vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; fi - - if [[ "$WITH_COVERAGE" == "true" ]]; then xdebug-disable; fi - - after_success: - - if [[ "$WITH_COVERAGE" == "true" ]]; then bash <(curl -s https://codecov.io/bash); fi - - - <<: *TEST - - php: 7.1 - - env: WITH_LOCKED=true - - - <<: *TEST - - php: 7.1 - - env: WITH_HIGHEST=true - - - <<: *TEST - - php: 7.2 - - env: WITH_LOWEST=true - - - <<: *TEST - - php: 7.2 - - env: WITH_LOCKED=true WITH_COVERAGE=true - - - <<: *TEST - - php: 7.2 - - env: WITH_HIGHEST=true - - - <<: *TEST - - php: 7.3 - - env: WITH_LOWEST=true - - - <<: *TEST - - php: 7.3 - - env: WITH_LOCKED=true - - - <<: *TEST - - php: 7.3 - - env: WITH_HIGHEST=true - -notifications: - email: false diff --git a/.travis/xdebug.sh b/.travis/xdebug.sh deleted file mode 100644 index c3cebe3..0000000 --- a/.travis/xdebug.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it -# -# For reference, see -# -# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions -# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration - -config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" - -function xdebug-disable() { - if [[ -f $config ]]; then - mv $config "$config.bak" - fi -} - -function xdebug-enable() { - if [[ -f "$config.bak" ]]; then - mv "$config.bak" $config - fi -} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bf04163 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +For a full diff see [`1.23.0...master`](https://github.com/localheinz/php-cs-fixer-config/compare/1.23.0...master). diff --git a/LICENSE b/LICENSE index 4354beb..cb45728 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017-2018 Andreas Möller +Copyright (c) 2017 Andreas Möller Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the diff --git a/Makefile b/Makefile index ca4f1b8..aeb373e 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,19 @@ -.PHONY: coverage cs it test +.PHONY: cs help it test -it: cs test +it: cs test ## Runs the cs and test targets -coverage: vendor - vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text - -cs: vendor +cs: vendor ## Fixes code style issues with php-cs-fixer mkdir -p .build/php-cs-fixer vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose -test: vendor +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}' + +test: vendor ## Runs unit tests with phpunit + mkdir -p .build/phpunit vendor/bin/phpunit --configuration=test/Unit/phpunit.xml vendor: composer.json composer.lock - composer validate + composer validate --strict composer install composer normalize diff --git a/README.md b/README.md index 49491eb..edcb962 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # php-cs-fixer-config -[![Build Status](https://travis-ci.com/localheinz/php-cs-fixer-config.svg?branch=master)](https://travis-ci.com/localheinz/php-cs-fixer-config) +[![CI Status](https://github.com/localheinz/php-cs-fixer-config/workflows/CI/badge.svg)](https://github.com/localheinz/php-cs-fixer-config/actions) [![codecov](https://codecov.io/gh/localheinz/php-cs-fixer-config/branch/master/graph/badge.svg)](https://codecov.io/gh/localheinz/php-cs-fixer-config) [![Latest Stable Version](https://poser.pugx.org/localheinz/php-cs-fixer-config/v/stable)](https://packagist.org/packages/localheinz/php-cs-fixer-config) [![Total Downloads](https://poser.pugx.org/localheinz/php-cs-fixer-config/downloads)](https://packagist.org/packages/localheinz/php-cs-fixer-config) diff --git a/test/Unit/phpunit.xml b/test/Unit/phpunit.xml index 8f1c339..07b9c63 100644 --- a/test/Unit/phpunit.xml +++ b/test/Unit/phpunit.xml @@ -8,11 +8,14 @@ beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutTodoAnnotatedTests="true" bootstrap="../../vendor/autoload.php" + cacheResult="true" + cacheResultFile="../../.build/phpunit/unit.cache" colors="true" columns="max" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" + executionOrder="random" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false"