-
Notifications
You must be signed in to change notification settings - Fork 1
Adds PHPStan to Slack plugin #2
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
Adds PHPStan to Slack plugin #2
Conversation
james-hill-matomo
left a comment
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
.git-hooks-matomo/pre-push
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to get plugin_path
.git-hooks-matomo/pre-push
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed filtering of changed files
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it because of cd
.git-hooks-matomo/pre-push
Outdated
| ### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed filtering of files
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.
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.
phpstan.neon
Outdated
| # ../../ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@james-hill-matomo Is this needed ?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
.git-hooks-matomo/pre-push
Outdated
| ### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can hardcode it, we need to change only once in future for 6.x
.git-hooks-matomo/pre-push
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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