Skip to content

Commit

Permalink
Try using a file to pass perf report
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Dec 9, 2024
1 parent f1b3180 commit 3bc4afd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/csqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:

env:
MAX_PHPCS_PERF_SECS: 0.4
PHPCS_OUTPUT_FILE: "phpcs-report-file"

steps:
- name: Checkout code
Expand Down Expand Up @@ -139,14 +140,17 @@ jobs:
id: performance_report
run: |
PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php)
echo "${PHPCS_OUTPUT}"
TOTAL_SECS=$(echo ${PHPCS_OUTPUT}| grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }')
echo "-----"
echo "${PHPCS_OUTPUT}" > ${env.PHPCS_OUTPUT_FILE}
- name: Parse performance report
id: parse_performance_report
run: |
TOTAL_SECS=$(cat ${env.PHPCS_OUTPUT_FILE} | grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }')
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 ) > fromJSON( env.MAX_PHPCS_PERF_SECS ) }}
if: ${{ fromJSON( steps.parse_performance_report.outputs.PHPCS_PERF_SECS ) > fromJSON( env.MAX_PHPCS_PERF_SECS ) }}
run: exit 1

0 comments on commit 3bc4afd

Please sign in to comment.