From 0f03bc087966a0ef2e7eaa2130ad3143d981df06 Mon Sep 17 00:00:00 2001 From: Tobias van Beek Date: Sun, 29 Oct 2023 20:56:06 +0100 Subject: [PATCH] Streamline the project with the base config. --- .gitlab-ci.yml | 104 +++++++++++++----------------------------------- README.md | 2 +- composer.json | 86 ++++++++++++++++++++++++--------------- infection.json5 | 17 ++++++++ 4 files changed, 101 insertions(+), 108 deletions(-) create mode 100644 infection.json5 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 713146d..b41d106 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,17 +21,30 @@ stages: prepare_cache: stage: prepare script: - # Install composer - - curl -sS https://getcomposer.org/installer | php - - php composer.phar validate - - php composer.phar install + - composer validate + - composer install # we use this artifact for all the jobs artifacts: name: "vendor" paths: - - composer.phar - vendor/* +phpstan: + stage: check + script: + # check for phpstan errors + - php -d memory_limit=500M vendor/bin/phpstan analyse --error-format=gitlab | tee phpstan.json + dependencies: + - prepare_cache + needs: + - prepare_cache + artifacts: + paths: + - phpstan.json + reports: + codequality: phpstan.json + when: always + lint: stage: check script: @@ -57,21 +70,6 @@ phpmd: needs: - prepare_cache -phpstan: - stage: check - script: - # check for phpstan errors - - php -d memory_limit=500M vendor/bin/phpstan analyse --error-format=gitlab > phpstan.json - - cat phpstan.json - dependencies: - - prepare_cache - needs: - - prepare_cache - artifacts: - paths: - - phpstan.json - when: always - test_lowest: stage: test <<: *set_exclude_group @@ -79,7 +77,7 @@ test_lowest: - git checkout $CI_COMMIT_BRANCH # Install composer - rm -f composer.lock - - php composer.phar update --prefer-lowest + - composer update --prefer-lowest - vendor/bin/phpunit --coverage-text --colors=never --log-junit=phpunitresult/junit.xml $EXCLUDE_GROUP artifacts: reports: @@ -89,11 +87,17 @@ test_lowest: needs: - prepare_cache -test_php80: - stage: test +test: + parallel: + matrix: + - PHP: + - 80 + - 81 + - 82 + image: registry.gitlab.com/tjvb/phpimages:php$PHP <<: *set_exclude_group script: - - php composer.phar install + - composer install - vendor/bin/phpunit --coverage-text --colors=never --coverage-cobertura=phpunitresult/cobertura-coverage.xml --log-junit=phpunitresult/junit.xml $EXCLUDE_GROUP - sed -i 's~ filename="~ filename="src/~' phpunitresult/cobertura-coverage.xml coverage: '/^\s*Lines:\s*\d+.\d+\%/' @@ -107,55 +111,3 @@ test_php80: - prepare_cache needs: - prepare_cache - -test_php81: - image: registry.gitlab.com/tjvb/phpimages:php81 - stage: test - <<: *set_exclude_group - script: - - php composer.phar install - - vendor/bin/phpunit --coverage-text --colors=never --coverage-cobertura=phpunitresult/cobertura-coverage.xml --log-junit=phpunitresult/junit.xml $EXCLUDE_GROUP - - sed -i 's~ filename="~ filename="src/~' phpunitresult/cobertura-coverage.xml - coverage: '/^\s*Lines:\s*\d+.\d+\%/' - artifacts: - reports: - junit: phpunitresult/junit.xml - coverage_report: - coverage_format: cobertura - path: phpunitresult/cobertura-coverage.xml - dependencies: - - prepare_cache - needs: - - prepare_cache - -test_php82: - image: registry.gitlab.com/tjvb/phpimages:php82 - stage: test - <<: *set_exclude_group - script: - - php composer.phar install - - vendor/bin/phpunit --coverage-text --colors=never --coverage-cobertura=phpunitresult/cobertura-coverage.xml --log-junit=phpunitresult/junit.xml $EXCLUDE_GROUP - - sed -i 's~ filename="~ filename="src/~' phpunitresult/cobertura-coverage.xml - coverage: '/^\s*Lines:\s*\d+.\d+\%/' - artifacts: - reports: - junit: phpunitresult/junit.xml - coverage_report: - coverage_format: cobertura - path: phpunitresult/cobertura-coverage.xml - dependencies: - - prepare_cache - needs: - - prepare_cache - -CodeQuality: - stage: report - dependencies: - - phpstan - - prepare_cache - script: - - vendor/bin/converter convert --phpstan --phpstan-json-file=phpstan.json - artifacts: - reports: - codequality: code-climate.json - when: always \ No newline at end of file diff --git a/README.md b/README.md index 82ea899..70b38fa 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![License](https://poser.pugx.org/tjvb/githash/license)](https://packagist.org/packages/tjvb/githash) -This package is intended to give a usefull option for getting the hash from the current commit. +This package is intended to give a useful option for getting the hash from the current commit. ## Usage ```php diff --git a/composer.json b/composer.json index 9f40291..9bd4e5f 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { "name": "tjvb/githash", - "type": "library", "description": "Get the current git hash from your project.", + "license": "MIT", + "type": "library", "keywords": [ "tjvb", "githash", "hash" ], - "license": "MIT", "authors": [ { "name": "Tobias van Beek", @@ -15,12 +15,30 @@ "homepage": "https://www.tjvb.nl" } ], + "support": { + "issues": "https://gitlab.com/tjvb/githash/-/issues", + "source": "https://gitlab.com/tjvb/githash/-/tree/master" + }, + "funding": [ + { + "type": "paypal", + "url": "https://paypal.me/tvbeek" + }, + { + "type": "github", + "url": "https://github.com/sponsors/tvbeek/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/TJVB" + } + ], "require": { - "php": "^8.0 || ^8.1 || ^8.2" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "require-dev": { - "beechit/json-to-code-climate-subset-converter": "^1.6", "fakerphp/faker": "^1.15", + "infection/infection": "^0.27.6", "phpmd/phpmd": "^2.10", "phpstan/phpstan": "^0.12.94", "phpunit/phpunit": "^9.5", @@ -30,12 +48,6 @@ "suggest": { "symfony/process": "Used rather than `shell_exec` if available (tested with ^5.3)." }, - "config": { - "sort-packages": true, - "allow-plugins": { - "infection/extension-installer": true - } - }, "autoload": { "psr-4": { "TJVB\\GitHash\\": "src/" @@ -46,33 +58,45 @@ "TJVB\\GitHash\\Tests\\": "tests/" } }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + }, + "sort-packages": true + }, "scripts": { - "check-all": [ - "@format", - "@codestyle", - "@test-coverage", + "analyse": [ "@phpstan", "@phpmd" ], - "codestyle": "vendor/bin/phpcs", - "format": "vendor/bin/phpcbf", - "phpstan": "vendor/bin/phpstan", + "analyze": "@analyse", + "check": [ + "@cs-fix", + "@test-coverage", + "@analyse", + "@infection" + ], + "check-all": "@check", + "cs": "vendor/bin/phpcs", + "cs-fix": "vendor/bin/phpcbf", + "codestyle": "@cs", + "format": "@cs-fix", + "infection": "vendor/bin/infection", "phpmd": "vendor/bin/phpmd src/ text phpmd.xml.dist", + "phpstan": "vendor/bin/phpstan", "test": "vendor/bin/phpunit --no-coverage", "test-coverage": "vendor/bin/phpunit --coverage-html build/coverage" }, - "support": { - "issues": "https://gitlab.com/tjvb/githash/-/issues", - "source": "https://gitlab.com/tjvb/githash/-/tree/master" - }, - "funding": [ - { - "type": "paypal", - "url": "https://paypal.me/tvbeek" - }, - { - "type": "github", - "url": "https://github.com/sponsors/tvbeek/" - } - ] + "scripts-descriptions": { + "analyse": "Run the analyse steps (PHPStan and PHPMD)", + "analyze": "See analyse", + "check": "Runs @analyse, @cs-fix, @test-coverage and @infection.", + "cs": "Check the codestyle with ecs.", + "cs-fix": "Check the codestyle with ecs and if possible fix the found issues.", + "infection": "Run infection.", + "phpmd": "Analyse the code with PHPMD", + "phpstan": "Analyse the code with PHPStan.", + "test": "Run the PHPUnit tests without coverage.", + "test-coverage": "Run the PHPUnit tests with coverage." + } } diff --git a/infection.json5 b/infection.json5 new file mode 100644 index 0000000..e4180cf --- /dev/null +++ b/infection.json5 @@ -0,0 +1,17 @@ +{ + "$schema": "vendor/infection/infection/resources/schema.json", + "source": { + "directories": [ + "src" + ] + }, + "logs": { + "html": "build/infection/log.html", + "json": "build/infection/log.json", + "text": "build/infection/log.txt", + "gitlab": "build/infection/code-climate-gitlab.json" + }, + "mutators": { + "@default": true + } +} \ No newline at end of file