Last active
February 24, 2023 10:25
-
-
Save Ocramius/9dd570fdcc6b53768d2dc9eceeb83e59 to your computer and use it in GitHub Desktop.
Script to check whether `psalm-baseline.xml` improved/worsened over time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export TARGET_REF=${TARGET_REF:-HEAD} | |
git show "$TARGET_REF:psalm-baseline.xml" | xmllint --xpath 'count(//file[not(starts-with(@src, "test"))]/*/code)' - |
Thanks @annervisser: applied your suggestion :)
@Ocramius Another update to support the new format without occurrences=
attribute:
- git show "$TARGET_REF:psalm-baseline.xml" | xmllint --xpath '//file[not(starts-with(@src, "test"))]//@occurrences' - | awk -F\" '{ print $2 }' | awk '{s+=$1} END {print s}'
+ git show "$TARGET_REF:psalm-baseline.xml" | xmllint --xpath 'count(//file[not(starts-with(@src, "test"))]/*/code)' -
Applied, thanks @annervisser!
I've made a GitHub action which uses this to get the score for a pull request compared to its base branch. This allows you to comment it on the PR or use it on other subsequent actions.
https://github.com/annervisser/psalm-baseline-progress-action
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NR % 2 == 0
causes half the lines to be skipped, causing roughly half the number of issues to be output.Removing that part gives the correct result: