Skip to content

Commit

Permalink
Refactor to print output of phpcs alone
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Dec 8, 2024
1 parent f0271f8 commit 698b1dd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/csqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ jobs:
name: "Basic Performance Guard"
runs-on: ubuntu-latest

env:
MAX_PHPCS_PERF_SECS: 0.6

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -134,13 +137,18 @@ jobs:

- name: Run performance report
id: performance_report
run: echo "PHPCS_PERF_SECS=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }')" >> $GITHUB_OUTPUT

- name: Log performance
run: echo "${{ steps.performance_report.outputs.PHPCS_PERF_SECS }}"
run: |
set -x
PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php)
set +x
echo "${PHPCS_OUTPUT}"
TOTAL_SECS=$(echo ${PHPCS_OUTPUT}| grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }')
echo "-----"
echo "Performance time was ${TOTAL_SECS} (max ${{ env.MAX_PHPCS_PERF_SECS }})"
echo "PHPCS_PERF_SECS=${TOTAL_SECS}" >> $GITHUB_OUTPUT
# fromJSON is used to convert strings to numbers in github actions.
# @link https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#operators
- name: Compare performance to baseline
if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > 0.6 }}
if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > fromJSON( env.MAX_PHPCS_PERF_SECS ) }}
run: exit 1

0 comments on commit 698b1dd

Please sign in to comment.