-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Declare test code in subdirectory #2
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,62 @@ jobs: | |
- name: "Test autoloader for production" | ||
run: "php autoloader.php" | ||
|
||
code-coverage: | ||
name: "Code Coverage" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.3" | ||
|
||
dependencies: | ||
- "locked" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/[email protected]" | ||
|
||
- name: "Set up PHP" | ||
uses: "shivammathur/[email protected]" | ||
with: | ||
coverage: "xdebug" | ||
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" | ||
php-version: "${{ matrix.php-version }}" | ||
|
||
- name: "Set up problem matchers for PHP" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" | ||
|
||
- name: "Set up problem matchers for phpunit/phpunit" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" | ||
|
||
- name: "Determine composer cache directory" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/[email protected]" | ||
with: | ||
path: "${{ env.COMPOSER_CACHE_DIR }}" | ||
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | ||
|
||
- name: "Install ${{ matrix.dependencies }} dependencies with composer" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
with: | ||
dependencies: "${{ matrix.dependencies }}" | ||
|
||
- name: "Collect code coverage with Xdebug and phpunit/phpunit" | ||
env: | ||
XDEBUG_MODE: "coverage" | ||
run: "vendor/bin/phpunit --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml" | ||
|
||
- name: "Send code coverage report to codecov.io" | ||
uses: "codecov/[email protected]" | ||
with: | ||
files: ".build/phpunit/logs/clover.xml" | ||
token: "${{ secrets.CODECOV_TOKEN }}" | ||
|
||
coding-standards: | ||
name: "Coding Standards" | ||
|
||
|
@@ -190,6 +246,98 @@ jobs: | |
- name: "Run maglnet/composer-require-checker" | ||
run: ".phive/composer-require-checker check --ansi --config-file=$(pwd)/composer-require-checker.json" | ||
|
||
mutation-tests: | ||
name: "Mutation Tests" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.3" | ||
|
||
dependencies: | ||
- "locked" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/[email protected]" | ||
|
||
- name: "Set up PHP" | ||
uses: "shivammathur/[email protected]" | ||
with: | ||
coverage: "xdebug" | ||
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" | ||
php-version: "${{ matrix.php-version }}" | ||
|
||
- name: "Set up problem matchers for PHP" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" | ||
|
||
- name: "Determine composer cache directory" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/[email protected]" | ||
with: | ||
path: "${{ env.COMPOSER_CACHE_DIR }}" | ||
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | ||
|
||
- name: "Install ${{ matrix.dependencies }} dependencies with composer" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
with: | ||
dependencies: "${{ matrix.dependencies }}" | ||
|
||
- name: "Run mutation tests with Xdebug and infection/infection" | ||
env: | ||
XDEBUG_MODE: "coverage" | ||
run: "vendor/bin/infection --ansi --configuration=infection.json --logger-github" | ||
|
||
performance-tests: | ||
name: "Performance Tests" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.3" | ||
|
||
dependencies: | ||
- "locked" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/[email protected]" | ||
|
||
- name: "Set up PHP" | ||
uses: "shivammathur/[email protected]" | ||
with: | ||
coverage: "none" | ||
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" | ||
php-version: "${{ matrix.php-version }}" | ||
|
||
- name: "Set up problem matchers for PHP" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" | ||
|
||
- name: "Determine composer cache directory" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/[email protected]" | ||
with: | ||
path: "${{ env.COMPOSER_CACHE_DIR }}" | ||
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | ||
|
||
- name: "Install ${{ matrix.dependencies }} dependencies with composer" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
with: | ||
dependencies: "${{ matrix.dependencies }}" | ||
|
||
- name: "Run performance tests with phpbench/phpbench" | ||
run: "vendor/bin/phpbench run --config=phpbench.json src/Test/" | ||
|
||
refactoring: | ||
name: "Refactoring" | ||
|
||
|
@@ -354,3 +502,53 @@ jobs: | |
|
||
- name: "Run vimeo/psalm" | ||
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4" | ||
|
||
tests: | ||
name: "Tests" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.3" | ||
|
||
dependencies: | ||
- "lowest" | ||
- "locked" | ||
- "highest" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/[email protected]" | ||
|
||
- name: "Set up PHP" | ||
uses: "shivammathur/[email protected]" | ||
with: | ||
coverage: "none" | ||
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter" | ||
php-version: "${{ matrix.php-version }}" | ||
|
||
- name: "Set up problem matchers for PHP" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" | ||
|
||
- name: "Set up problem matchers for phpunit/phpunit" | ||
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" | ||
|
||
- name: "Determine composer cache directory" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
|
||
- name: "Cache dependencies installed with composer" | ||
uses: "actions/[email protected]" | ||
with: | ||
path: "${{ env.COMPOSER_CACHE_DIR }}" | ||
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" | ||
|
||
- name: "Install ${{ matrix.dependencies }} dependencies with composer" | ||
uses: "ergebnis/.github/actions/composer/[email protected]" | ||
with: | ||
dependencies: "${{ matrix.dependencies }}" | ||
|
||
- name: "Run tests with phpunit/phpunit" | ||
run: "vendor/bin/phpunit --colors=always --configuration=phpunit.xml" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,10 @@ | |
"autoload": { | ||
"psr-4": { | ||
"Localheinz\\OrganizingTestCodeInPhp\\": "src/" | ||
} | ||
}, | ||
"exclude-from-classmap": [ | ||
"/src/Test/" | ||
] | ||
Comment on lines
+38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you declare test code in a subdirectory of production code, managing exclusions for the |
||
}, | ||
"config": { | ||
"allow-plugins": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"ignoreMsiWithNoMutations": true, | ||
"logs": { | ||
"text": ".build/infection/infection-log.txt" | ||
}, | ||
"minCoveredMsi": 100, | ||
"minMsi": 100, | ||
"phpUnit": { | ||
"configDir": "." | ||
}, | ||
"source": { | ||
"directories": [ | ||
"src" | ||
], | ||
"excludes": [ | ||
"Test/" | ||
] | ||
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you declare test code in a subdirectory of production code, managing exclusions for |
||
}, | ||
"timeout": 10 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema":"vendor/phpbench/phpbench/phpbench.schema.json", | ||
"runner.bootstrap": "vendor/autoload.php", | ||
"runner.file_pattern": "*.php" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you work on a package and declare test code in a subdirectory of the production code, adding exclusions for test code in
.gitattributes
is less work.