Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

run tests with MySQL, PostgreSQL, SQLite #421

Merged
merged 3 commits into from
Aug 31, 2023
Merged

Conversation

craue
Copy link
Owner

@craue craue commented Aug 30, 2023

Different approach compared to #420. This makes it possible to run specific tests (only those which actually use a database) against several database platforms. I definitely like that the mechanism is easier to understand and tests themselves are kept clean.

What I don't like is that a failed step causes following steps to be skipped so if tests fail with MySQL they won't be run with PostgreSQL and SQLite. Also the SYMFONY_DEPRECATIONS_HELPER will be harder to use with 4 PHPUnit steps.

I wonder why PhotoUploadFlowTest fails with PostgreSQL. 馃 This at least proves that testing against several database platforms is a good idea. 馃槀

@craue
Copy link
Owner Author

craue commented Aug 30, 2023

PostgreSQL is fine now, at least with PHP > 7.3. I'm gonna remove support for PHP 7.3 but not within this PR.

Awaiting feedback from @franmomu. 馃槉

@coveralls
Copy link

coveralls commented Aug 30, 2023

Coverage Status

coverage: 99.483% (+0.01%) from 99.472% when pulling 1fae5f6 on tests-with-databases into 515871d on master.

@craue craue force-pushed the tests-with-databases branch 5 times, most recently from 29eb888 to 00e4ed1 Compare August 30, 2023 21:38
@craue
Copy link
Owner Author

craue commented Aug 30, 2023

Alright, now I also got all PHPUnit steps running even in case of failures. 馃コ

Copy link
Contributor

@franmomu franmomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +123 to +139
- name: run PHPUnit with MySQL
if: always()
run: vendor/bin/phpunit -v --coverage-clover build/logs/clover-mysql.xml --group run-with-multiple-databases,run-with-multiple-databases-only
env:
DB_FLAVOR: mysql

- name: run PHPUnit with PostgreSQL
if: always()
run: vendor/bin/phpunit -v --coverage-clover build/logs/clover-postgresql.xml --group run-with-multiple-databases,run-with-multiple-databases-only
env:
DB_FLAVOR: postgresql

- name: run PHPUnit with SQLite
if: always()
run: vendor/bin/phpunit -v --coverage-clover build/logs/clover-sqlite.xml --group run-with-multiple-databases,run-with-multiple-databases-only
env:
DB_FLAVOR: sqlite
Copy link
Contributor

@franmomu franmomu Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be moved to its own job I guess, at the same level as tests and creating a new one tests-with-databases, that way maybe it's clearer (I guess these tests don't need to be executed using different versions of Symfony).

Copy link
Owner Author

@craue craue Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then I'd have to decide with which PHP/Symfony versions they'd be run with. As of now, cross coverage is a lot better. Seeing tests fail only with PostgreSQL and PHP 7.3 is worth doing so.

Comment on lines 23 to 31
/**
* @var Connection
*/
private $conn;

protected function getConnection() : Connection {
return $this->conn;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is not used anymore

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought to just leave it there in case it'll be needed. 馃榿
But you're right. If it's really needed, it could be added again easily. Removed.

@craue craue merged commit 8c3ab2a into master Aug 31, 2023
22 of 30 checks passed
@craue craue deleted the tests-with-databases branch August 31, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants