Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Improve devx (#59)
Browse files Browse the repository at this point in the history
* add earthfile

* update ci tooling

* disable PHPMD.StaticAccess for getValueFromFixture
  • Loading branch information
edno authored Sep 13, 2021
1 parent 412c355 commit 2cef46f
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 126 deletions.
7 changes: 7 additions & 0 deletions .earthignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
composer.phar
vendor
tests/_output
tests/_support/_generated
composer.lock
.vscode
*.log
11 changes: 5 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
XDEBUG_MODE: coverage

steps:
- uses: actions/checkout@v1
Expand All @@ -14,17 +16,14 @@ jobs:
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
run: composer update --prefer-stable --no-progress --no-interaction --quiet

- name: Run test suite
run: ./vendor/bin/codecept run -q --no-colors --coverage-xml
env:
XDEBUG_MODE: coverage
run: ./vendor/bin/codecept run --quiet --no-colors --no-interaction --coverage --coverage-xml

- name: Run mutation tests
run: ./vendor/bin/infection --min-covered-msi=70 --threads=4 --no-progress --log-verbosity="none"
run: ./vendor/bin/infection --min-covered-msi=80 --threads=2 --no-progress --no-interaction --log-verbosity=none
env:
XDEBUG_MODE: coverage
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

- name: Run Coveralls reporting
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
composer.phar
/vendor/
/tests/_output/
/tests/_support/_generated/
vendor
tests/_output
tests/_support/_generated

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand All @@ -12,3 +12,5 @@ composer.lock
!*.dist.yml

.vscode

*.log
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
- php: nightly

before_script:
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "8.0" ]]; then composer remove --no-interaction --dev infection/infection infection/codeception-adapter infection/extension-installer; fi
- composer install --no-interaction
- composer update --prefer-stable --no-progress --no-interaction --quiet

script:
- "./vendor/bin/codecept run --no-colors"
- "./vendor/bin/codecept run --quiet --no-interaction --no-colors"
45 changes: 45 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG version=7.4
FROM php:$version-alpine
WORKDIR /codeception
ENV XDEBUG_MODE=coverage

deps:
RUN apk add --quiet --no-progress --no-cache $PHPIZE_DEPS
RUN pecl -q install xdebug
RUN docker-php-ext-enable xdebug
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

setup:
FROM +deps
COPY . .
RUN composer update --prefer-stable --no-progress --no-interaction --quiet

test:
FROM +setup
RUN ./vendor/bin/codecept run --no-interaction --coverage --coverage-xml
SAVE ARTIFACT tests/_output AS LOCAL ./tests/_output

mutation:
FROM +setup
RUN ./vendor/bin/infection --min-covered-msi=80 --no-progress --no-interaction --log-verbosity=all --threads=$(nproc)
SAVE ARTIFACT tests/_output/infection AS LOCAL ./tests/_output/infection

phpmd:
FROM +setup
RUN ./vendor/bin/phpmd src,tests ansi codesize,unusedcode,naming,design,controversial

phpcs:
FROM +setup
RUN ./vendor/bin/phpcs -p --colors src tests

phpcbf:
FROM +setup
RUN ./vendor/bin/phpcbf -p src tests 2>&1 || true
SAVE ARTIFACT src AS LOCAL ./src
SAVE ARTIFACT tests AS LOCAL ./tests

all:
BUILD +phpcs
BUILD +phpmd
BUILD +test
BUILD +mutation
18 changes: 12 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@
"composer-runtime-api": "^2.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2",
"brainmaestro/composer-git-hooks": "^2.8",
"codeception/assert-throws": "^1.1",
"codeception/module-asserts": "^1",
"codeception/mockery-module": "^0.4",
"infection/codeception-adapter": "^0.3",
"infection/infection": "^0.24",
"infection/codeception-adapter": "^0.3.4",
"php-coveralls/php-coveralls": "^2",
"phpmd/phpmd" : "@stable",
"squizlabs/php_codesniffer": "3.*",
"codeception/mockery-module": "^0.4.0",
"codeception/assert-throws": "^1.1"
"squizlabs/php_codesniffer": "3.*"
},
"autoload": {
"psr-4": {
"Codeception\\Extension\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"extra": {
"hooks": {
"pre-push": "earthly +all"
}
}
}
2 changes: 1 addition & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"@function_signature": false
},
"testFramework": "codeception",
"testFrameworkOptions": "acceptance"
"testFrameworkOptions": "acceptance"
}
45 changes: 45 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<ruleset name="GherkinParam" namespace="GherkinParam\CS\Standard">
<description>GherkinParam custom phpcs ruleset (based on default ruleset)</description>
<file>./src</file>
<file>./tests</file>

<rule ref="PEAR.Classes.ClassDeclaration"/>
<rule ref="PEAR.Commenting.ClassComment">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PEAR.Commenting.FunctionComment">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<rule ref="PEAR.ControlStructures.MultiLineCondition"/>
<rule ref="PEAR.Files.IncludingFile"/>
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="PEAR.Functions.FunctionCallSignature"/>
<rule ref="PEAR.Functions.FunctionDeclaration"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<rule ref="PEAR.NamingConventions.ValidFunctionName">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PEAR.NamingConventions.ValidVariableName"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
<rule ref="PEAR.WhiteSpace.ScopeIndent"/>
<rule ref="PEAR.Commenting.FileComment">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Files.LineLength"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.Commenting.DocComment">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
</ruleset>
Loading

0 comments on commit 2cef46f

Please sign in to comment.