From 698b1dd25e096a79845a1e6652e9ca5629908139 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:43:51 -0500 Subject: [PATCH] Refactor to print output of phpcs alone --- .github/workflows/csqa.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 7b9a485..51649e3 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -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 @@ -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