Skip to content

Commit

Permalink
Streamline the project with the base config.
Browse files Browse the repository at this point in the history
  • Loading branch information
tvbeek committed Oct 29, 2023
1 parent 861161f commit 0f03bc0
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 108 deletions.
104 changes: 28 additions & 76 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -57,29 +70,14 @@ 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
script:
- 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:
Expand All @@ -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+\%/'
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 55 additions & 31 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
{
"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",
"email": "t.vanbeek@tjvb.nl",
"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",
Expand All @@ -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/"
Expand All @@ -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."
}
}
17 changes: 17 additions & 0 deletions infection.json5
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 0f03bc0

Please sign in to comment.