v8-archive icon indicating copy to clipboard operation
v8-archive copied to clipboard

Add GitHub actions

Open jooola opened this issue 4 years ago • 17 comments

This adds some CI PHP code analyzing. It contains a huge set of reformatting change, And CI is still broken.

See https://github.com/jooola/api/pull/1/checks

jooola avatar Jan 04 '20 04:01 jooola

I didn't format the config/_example.php file, and saw a few weird changes I didn't added to the formatting commits.

This is why the CI is still complaining about some unformatted files.

jooola avatar Jan 04 '20 17:01 jooola

This is really awesome and something I really wanted to do for quite some time, so thanks for this! I just think this will be really hard to make a proper review due to the amount of files changed.

I'll take some time later to do this and I'll probably add these into future branch too.

WoLfulus avatar Jan 05 '20 08:01 WoLfulus

@WoLfulus This is why I tried to split the reformatting into multiple chunk. I admit I didn't completely review the changes for the src folder. It was too much at once. But I did check the 4 first formatting commits.

What could be done is that your make the formatting yourself and just cherry pick the CI files installation.

jooola avatar Jan 05 '20 14:01 jooola

I'll try to review this later, so I'll keep this open for now ok? I'd love to merge these on the current codebase too.

WoLfulus avatar Jan 06 '20 12:01 WoLfulus

Based on the fact that the script errors out at exactly 30MB memory use, I'm assuming we're hitting some sort of limit in GH Actions

rijkvanzanten avatar Jan 06 '20 20:01 rijkvanzanten

@rijkvanzanten No the error is from the files not being correctly formatted. You can see the diff above the error line. Also the error code is 8, which means some files need some formatting.

https://github.com/FriendsOfPHP/PHP-CS-Fixer#exit-code

I don't think Github Actions would limit to 30Mo, it feels way not enough even for free plans.

I previously mentioned that I didn't format some files because I wasn't sure if the formatting was right so I left them unchanged.

jooola avatar Jan 06 '20 22:01 jooola

ah gotcha. just felt suspicious to me that it was exactly 30.00 😁

rijkvanzanten avatar Jan 06 '20 22:01 rijkvanzanten

@rijkvanzanten @WoLfulus I mean I need your input on those failing files so we can fix this.

The first is the configuration file, should we exclude it from the PHP-cs-fixer formatter ?

The second problem comes from a file named public/extensions/custom/hashers/_CustomHasher.php and the class has been renamed to _CustomHasher to match the file name.

Not sure what to do.

-class CustomHasher implements \Directus\Hash\Hasher\HasherInterface
+class _CustomHasher implements \Directus\Hash\Hasher\HasherInterface

jooola avatar Jan 06 '20 23:01 jooola

The configuration file is an example for users, and the formatter is tripping over the way comments are structured. Can we add a rule that ignores all files prefixed by a _? Those are meant as example files in Directus and aren't actually used.

rijkvanzanten avatar Jan 07 '20 15:01 rijkvanzanten

Now that Php-CS-Fixer passes, we have PHP stan complaining about some unimplemented methods from a parent abstract class. @rijkvanzanten What should we do ? This project doesn't even seem to use SQLite anyway right ?

Fatal error: Class Directus\Database\Schema\Sources\SQLiteSchema contains 26
abstract methods and must therefore be declared abstract or implement the remaining
methods (
Directus\Database\Schema\Sources\SchemaInterface::getConnection, 
Directus\Database\Schema\Sources\SchemaInterface::getSchemaName,
Directus\Database\Schema\Sources\SchemaInterface::getCollections,
...
) in
/home/runner/work/api/api/src/core/Directus/Database/Schema/Sources/SQLiteSchema.php
on line 414

jooola avatar Jan 07 '20 18:01 jooola

There was a good effort a while ago to support more SQL based databases in the past, this must be a remnant of that. I don't think it's being used for anything right now, but I'll have to defer to @bjgajjar to confirm that.

rijkvanzanten avatar Jan 07 '20 18:01 rijkvanzanten

@rijkvanzanten Is :+1: an answer ?

jooola avatar Jan 07 '20 20:01 jooola

@bjgajjar ?

rijkvanzanten avatar Jan 07 '20 20:01 rijkvanzanten

@rijkvanzanten I took the liberty of removing the file myself. This allowed me to add some configuration to PHPStan, which is now yelling a huge amount of errors that should be fixed.

See by yourself https://github.com/jooola/api/runs/378290711

We could either ignore some of those, or fix them. Reducing the analysis level is also something we could do to reduce some warnings. Or print all the warnings but make the test pass anyway using a || true.

jooola avatar Jan 07 '20 21:01 jooola

@jooola - Thanks for this amazing PR.

I don't think it's being used for anything right now,

Agree. It's not being used anymore.

binal-7span avatar Jan 08 '20 09:01 binal-7span

@jooola should we apply this to the new laravel branch instead? Retroactively trying to fix all the warnings and errors in the current codebase is going to be a huge task

rijkvanzanten avatar Jan 09 '20 17:01 rijkvanzanten

I can do that, but it looks like Wolfulu has already pushed the CI system in the laravel branch.

Le 9 janvier 2020 18:02:53 GMT+01:00, Rijk van Zanten [email protected] a écrit :

@jooola should we apply this to the new laravel branch instead? Retroactively trying to fix all the warnings and errors in the current codebase is going to be a huge task

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/directus/api/pull/1615#issuecomment-572657094

-- Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.

jooola avatar Jan 10 '20 17:01 jooola