Adds PHPStan to Slack plugin#2
Adds PHPStan to Slack plugin#2james-hill-matomo merged 17 commits intoPG-4491-schedule-report-slackfrom
Conversation
james-hill-matomo
left a comment
There was a problem hiding this comment.
Looks good. Given this is a brand new plugin, could we have a higher level as base?
Can bump the level that high with (almost) no errors.
2a2cda8 to
1ddee14
Compare
1ddee14 to
eff2eee
Compare
|
@AltamashShaikh Can you add the git hooks and check that they work with your non ddev setup? They should run successfully on git pushing so long as you've modified or created a php file. I've bumped the base level up to 5 as I was able to do so with minimal code fixes (see commit). |
james-hill-matomo
left a comment
There was a problem hiding this comment.
@AltamashShaikh Happy to merge if you're OK with my changes, and can you confirm that the pre-push git hook works for you?
@james-hill-matomo I gave execute permission to |
…r both created and updated
|
@james-hill-matomo I updated the |
| echo "Running pre-commit hook in repo: $REPO_DIR" | ||
|
|
||
| if [[ "$REPO_DIR" =~ /plugins/(.*) ]]; then | ||
| PLUGIN_PATH=${REPO_DIR} |
There was a problem hiding this comment.
Changed to get plugin_path
| PHPSTAN_CREATED_CONFIG=phpstan/phpstan.created.neon | ||
| BRANCH_NAME=$(git branch --show-current) | ||
| if [[ -f "$PHPSTAN_CREATED_CONFIG" ]]; then | ||
| CHANGED_FILES=$(git diff --name-only ${BRANCH_NAME} --diff-filter=A | grep '\.php$' || true) |
There was a problem hiding this comment.
Added branch name. earlier it was referring to 5.x-dev
| if [ -z "$CHANGED_FILES" ]; then | ||
| echo "No created PHP files" | ||
| else | ||
| echo "Running PHPstan at a very high level on new files" |
There was a problem hiding this comment.
Removed filtering of changed files
There was a problem hiding this comment.
That adds the plugin path, and is needed for it to work in ddev. I hope I fixed it for non ddev by putting a "cd" at the start of the script.
There was a problem hiding this comment.
I removed it because of cd
| ### Run PHPStan on modified files. ### | ||
| PHPSTAN_MODIFIED_CONFIG=phpstan/phpstan.modified.neon | ||
| if [[ -f "$PHPSTAN_MODIFIED_CONFIG" ]]; then | ||
| CHANGED_FILES=$(git diff --name-only ${BRANCH_NAME} --diff-filter=CM | grep '\.php$' || true) |
There was a problem hiding this comment.
Added branch name here
| if [ -z "$CHANGED_FILES" ]; then | ||
| echo "No changed PHP files" | ||
| else | ||
| echo "Running PHPstan on modified files" |
There was a problem hiding this comment.
Removed filtering of files
There was a problem hiding this comment.
That adds the plugin path, and is needed for it to work in ddev. I hope I fixed it for non ddev by putting a "cd" at the start of the script.
| # ../../ does not actually seem to give us anything | ||
| # that ../plugins/ does not, but including it for | ||
| # completeness. It does not seem to slow down performance. | ||
| - ../../ |
There was a problem hiding this comment.
We should be getting everything we need from ../../bootstrap-phpstan.php (for core) and ../plugins/ for non core plugins we include.
Including ../../ is maybe not necessary, but it doesn't seem to slow things down either.
There was a problem hiding this comment.
@james-hill-matomo Was getting recursive error after recent change
I changed to below
| - ../../ | |
| - . |
eb5ed2e to
592fb1f
Compare
|
@AltamashShaikh Ddev broke for me, so I tweaked the files again - can you test on your local and let me know? We can do screenshare if that's easier. |
That branch change didn't work for me - the idea is that the system always compares your current branch with 5.x-dev . I've taken your change and made it so that it figures out the default branch, to save us some time when 6.x comes out. |
| ### Run PHPStan on newly created files. ### | ||
|
|
||
| PHPSTAN_CREATED_CONFIG=phpstan/phpstan.created.neon | ||
| MAIN_BRANCH=$(git symbolic-ref --short refs/remotes/origin/HEAD) |
There was a problem hiding this comment.
@james-hill-matomo getting this error when running MAIN_BRANCH=$(git symbolic-ref --short refs/remotes/origin/HEAD)
fatal: ref refs/remotes/origin/HEAD is not a symbolic ref
There was a problem hiding this comment.
we can hardcode it, we need to change only once in future for 6.x
| if command -v php >/dev/null 2>&1; then | ||
| cd "${MATOMO_DIR}" | ||
| if [ -f "vendor/bin/phpstan" ]; then | ||
| COMMAND="vendor/bin/phpstan" |
There was a problem hiding this comment.
@james-hill-matomo This should have full path
| COMMAND="vendor/bin/phpstan" | |
| COMMAND="${MATOMO_DIR}/vendor/bin/phpstan" |
AltamashShaikh
left a comment
There was a problem hiding this comment.
@james-hill-matomo I made few tweaks to work it for non-ddev, can you check again with ddev ?
|
@AltamashShaikh Works for me too ! |
ebbbc48
into
PG-4491-schedule-report-slack
Description:
Adds PHPStan to Slack plugin
Review