From c887f1423db62ad1672208e0a54240ab4835729b Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:30:19 -0500 Subject: [PATCH 01/31] Add perf-guard github workflow --- .github/workflows/csqa.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 79bce8f..7f1aac9 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -105,3 +105,35 @@ jobs: - name: Run Static Analysis run: composer static-analysis + + perf-guard: + name: "Basic Performance Guard" + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.1" + coverage: none + + # Install dependencies and handle caching in one go. + # Dependencies need to be installed to make sure the PHPUnit classes are recognized. + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer + - name: Install Composer dependencies + uses: "ramsey/composer-install@v3" + with: + # Bust the cache at least once a month - output format: YYYY-MM. + custom-cache-suffix: $(date -u "+%Y-%m") + + - name: Download performance test fixture + run: wget https://raw.githubusercontent.com/WordPress/WordPress/refs/heads/master/wp-includes/PHPMailer/PHPMailer.php + + - name: Run performance report + run: _PHPCS_RUNTIME=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }') + + - name: Compare performance to baseline + run: if awk "BEGIN {exit !($_PHPC_RUNTIME > 0.6)}"; then exit 1; fi From 8ab827206c2cd559b4447b930cc815d46ab0fb63 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:32:53 -0500 Subject: [PATCH 02/31] Fix typo --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 7f1aac9..42cc3f5 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -136,4 +136,4 @@ jobs: run: _PHPCS_RUNTIME=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }') - name: Compare performance to baseline - run: if awk "BEGIN {exit !($_PHPC_RUNTIME > 0.6)}"; then exit 1; fi + run: if awk "BEGIN {exit !($_PHPCS_RUNTIME > 0.6)}"; then exit 1; fi From 04e7dbc41656366df4b041a357606c7fdb29ffac Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:44:56 -0500 Subject: [PATCH 03/31] Switch to GITHUB_OUTPUT --- .github/workflows/csqa.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 42cc3f5..7c4f573 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -133,7 +133,9 @@ jobs: run: wget https://raw.githubusercontent.com/WordPress/WordPress/refs/heads/master/wp-includes/PHPMailer/PHPMailer.php - name: Run performance report - run: _PHPCS_RUNTIME=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }') + id: performance_report + run: echo "PHPCS_PERF_SECS=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }')" >> $GITHUB_OUTPUT - name: Compare performance to baseline - run: if awk "BEGIN {exit !($_PHPCS_RUNTIME > 0.6)}"; then exit 1; fi + if: ${{ fromJSON( steps.phpunit_version.outputs.PHPCS_PERF_SECS ) > 0.6 }} + run: exit 1 From 2a8e5f24f4f8a85408e4ed89d5ee6a32055622fd Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:47:44 -0500 Subject: [PATCH 04/31] Fix typo --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 7c4f573..1e36f07 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -137,5 +137,5 @@ jobs: run: echo "PHPCS_PERF_SECS=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }')" >> $GITHUB_OUTPUT - name: Compare performance to baseline - if: ${{ fromJSON( steps.phpunit_version.outputs.PHPCS_PERF_SECS ) > 0.6 }} + if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > 0.6 }} run: exit 1 From 9aa29051bfb26c62463a0003dcc42ca5fb74c42e Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:52:30 -0500 Subject: [PATCH 05/31] Log performance --- .github/workflows/csqa.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 1e36f07..d0acb86 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -136,6 +136,9 @@ jobs: id: performance_report run: echo "PHPCS_PERF_SECS=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php | grep -Eo 'TOTAL RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }')" >> $GITHUB_OUTPUT + - name: Log performance + run: echo "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" + - name: Compare performance to baseline if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > 0.6 }} run: exit 1 From 769bd71a6469f3c929d0003395ae10aec685de4c Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:52:45 -0500 Subject: [PATCH 06/31] Temporarily reduce baseline for testing --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index d0acb86..29df402 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,5 +140,5 @@ jobs: run: echo "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" - 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 ) > 0.2 }} run: exit 1 From 94601a571c47da24b568da45e41e0e377923b818 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:57:03 -0500 Subject: [PATCH 07/31] Revert "Temporarily reduce baseline for testing" This reverts commit 769bd71a6469f3c929d0003395ae10aec685de4c. --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 29df402..d0acb86 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,5 +140,5 @@ jobs: run: echo "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" - name: Compare performance to baseline - if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > 0.2 }} + if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > 0.6 }} run: exit 1 From eafcb48581c90218f873f1deed6e05a1ed27a7a2 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Mon, 2 Dec 2024 18:58:39 -0500 Subject: [PATCH 08/31] Compare SNIFF PROCESSING TIME --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index d0acb86..96c6eda 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -134,7 +134,7 @@ 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 RUN TIME[ ]+[0-9.]+'|awk '{ print $4 }')" >> $GITHUB_OUTPUT + 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 "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" From 2f6807071aaca90f0d7ca25ffde5dd902be00574 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 12:19:08 -0500 Subject: [PATCH 09/31] Add comment for fromJSON usage --- .github/workflows/csqa.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 96c6eda..5401224 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -139,6 +139,8 @@ jobs: - name: Log performance run: echo "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" + # 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 }} run: exit 1 From f0271f89cd488fd292862eeddec697238e67d413 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 12:19:28 -0500 Subject: [PATCH 10/31] Remove unnecessary fromJSON --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 5401224..7b9a485 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -137,7 +137,7 @@ jobs: 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 "${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) }}" + run: echo "${{ steps.performance_report.outputs.PHPCS_PERF_SECS }}" # 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 From 698b1dd25e096a79845a1e6652e9ca5629908139 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:43:51 -0500 Subject: [PATCH 11/31] 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 From c0928bde7964f8b51245f629a0422d61c3440ff5 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:45:43 -0500 Subject: [PATCH 12/31] Replace WP copy of PHPMailer with tagged official version --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 51649e3..f5e5b98 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -133,7 +133,7 @@ jobs: custom-cache-suffix: $(date -u "+%Y-%m") - name: Download performance test fixture - run: wget https://raw.githubusercontent.com/WordPress/WordPress/refs/heads/master/wp-includes/PHPMailer/PHPMailer.php + run: wget https://raw.githubusercontent.com/PHPMailer/PHPMailer/refs/tags/v6.9.3/src/PHPMailer.php - name: Run performance report id: performance_report From a3759ff38b4b75775d805421412e8912f537d6a2 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:47:21 -0500 Subject: [PATCH 13/31] Remove set x --- .github/workflows/csqa.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index f5e5b98..cdfd6a0 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -138,9 +138,7 @@ jobs: - name: Run performance report id: performance_report 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 "-----" From f45a26ac8c5d6b863ae092cfd2aa14c3cffa68df Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:52:26 -0500 Subject: [PATCH 14/31] Move parsing performance to own step --- .github/workflows/csqa.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index cdfd6a0..4fbbc9b 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,13 +140,17 @@ jobs: 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_PERF_REPORT=${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT + + - name: Parse performance report + id: parse_performance_report + run: | + TOTAL_SECS=$(echo ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }}| 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 From 29a2be79ba759c34b634f62a8aa2cc4217468bcd Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 13:54:19 -0500 Subject: [PATCH 15/31] Try quoting phpcs output --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 4fbbc9b..2e97e7c 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,7 +140,7 @@ jobs: run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" - echo "PHPCS_PERF_REPORT=${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT + echo "PHPCS_PERF_REPORT=\"${PHPCS_OUTPUT}\"" >> $GITHUB_OUTPUT - name: Parse performance report id: parse_performance_report From 22fb0cad996a07ddac98d680f9f657ab20622d3b Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:00:09 -0500 Subject: [PATCH 16/31] Use multi-line output to set var --- .github/workflows/csqa.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 2e97e7c..79e1df3 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,7 +140,9 @@ jobs: run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" - echo "PHPCS_PERF_REPORT=\"${PHPCS_OUTPUT}\"" >> $GITHUB_OUTPUT + echo "PHPCS_PERF_REPORT<> $GITHUB_OUTPUT + echo "${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - name: Parse performance report id: parse_performance_report From 5f016c15b775fed94514dd7152c61d814addeb4e Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:07:48 -0500 Subject: [PATCH 17/31] Try to parse with heredoc --- .github/workflows/csqa.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 79e1df3..36aa5f3 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -147,7 +147,11 @@ jobs: - name: Parse performance report id: parse_performance_report run: | - TOTAL_SECS=$(echo ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }}| grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }') + PHPCS_OUTPUT=$(cat <<-EOF + ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }} + EOF + )" + TOTAL_SECS=$(echo ${PHPCS_OUTPUT}| 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 From ffe2de053dee12e48d8499be679635b5ee8da649 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:40:40 -0500 Subject: [PATCH 18/31] Revert "Try to parse with heredoc" This reverts commit 5f016c15b775fed94514dd7152c61d814addeb4e. --- .github/workflows/csqa.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 36aa5f3..79e1df3 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -147,11 +147,7 @@ jobs: - name: Parse performance report id: parse_performance_report run: | - PHPCS_OUTPUT=$(cat <<-EOF - ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }} - EOF - )" - TOTAL_SECS=$(echo ${PHPCS_OUTPUT}| grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }') + TOTAL_SECS=$(echo ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }}| 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 From e059e4ac3e2241898395a4c61d1c5655a157f5ec Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:40:47 -0500 Subject: [PATCH 19/31] Revert "Use multi-line output to set var" This reverts commit 22fb0cad996a07ddac98d680f9f657ab20622d3b. --- .github/workflows/csqa.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 79e1df3..2e97e7c 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,9 +140,7 @@ jobs: run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" - echo "PHPCS_PERF_REPORT<> $GITHUB_OUTPUT - echo "${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + echo "PHPCS_PERF_REPORT=\"${PHPCS_OUTPUT}\"" >> $GITHUB_OUTPUT - name: Parse performance report id: parse_performance_report From c3233eebcfe6da757c35202b9e36a3cf0b45ada3 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:40:55 -0500 Subject: [PATCH 20/31] Revert "Try quoting phpcs output" This reverts commit 29a2be79ba759c34b634f62a8aa2cc4217468bcd. --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 2e97e7c..4fbbc9b 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,7 +140,7 @@ jobs: run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" - echo "PHPCS_PERF_REPORT=\"${PHPCS_OUTPUT}\"" >> $GITHUB_OUTPUT + echo "PHPCS_PERF_REPORT=${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT - name: Parse performance report id: parse_performance_report From 8e360e224ecde58f1e2d3c877ee8249562d83322 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:41:04 -0500 Subject: [PATCH 21/31] Revert "Move parsing performance to own step" This reverts commit f45a26ac8c5d6b863ae092cfd2aa14c3cffa68df. --- .github/workflows/csqa.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 4fbbc9b..cdfd6a0 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,17 +140,13 @@ jobs: run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" - echo "PHPCS_PERF_REPORT=${PHPCS_OUTPUT}" >> $GITHUB_OUTPUT - - - name: Parse performance report - id: parse_performance_report - run: | - TOTAL_SECS=$(echo ${{ steps.performance_report.outputs.PHPCS_PERF_REPORT }}| grep -Eo 'TOTAL SNIFF PROCESSING TIME[ ]+[0-9.]+'|awk '{ print $5 }') + 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.parse_performance_report.outputs.PHPCS_PERF_SECS ) > fromJSON( env.MAX_PHPCS_PERF_SECS ) }} + if: ${{ fromJSON( steps.performance_report.outputs.PHPCS_PERF_SECS ) > fromJSON( env.MAX_PHPCS_PERF_SECS ) }} run: exit 1 From ded6e9e8ba1404db22abf6cdc68aef1510709ee2 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:44:40 -0500 Subject: [PATCH 22/31] Temporarily decrease MAX_PHPCS_PERF_SECS --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index cdfd6a0..66bb7df 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest env: - MAX_PHPCS_PERF_SECS: 0.6 + MAX_PHPCS_PERF_SECS: 0.2 steps: - name: Checkout code From 7d2a1702071eeba63cab4a068a459101473b5c79 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:46:56 -0500 Subject: [PATCH 23/31] Decrease it further --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 66bb7df..ecb8c63 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest env: - MAX_PHPCS_PERF_SECS: 0.2 + MAX_PHPCS_PERF_SECS: 0.1 steps: - name: Checkout code From 541ff56dbc57c29528ca516e26ac11b63ad4b09b Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:49:59 -0500 Subject: [PATCH 24/31] Revert "Decrease it further" This reverts commit 7d2a1702071eeba63cab4a068a459101473b5c79. --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index ecb8c63..66bb7df 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest env: - MAX_PHPCS_PERF_SECS: 0.1 + MAX_PHPCS_PERF_SECS: 0.2 steps: - name: Checkout code From b90d9da35bb66fecc6569f9d3af1096237ff90eb Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:50:20 -0500 Subject: [PATCH 25/31] Revert "Temporarily decrease MAX_PHPCS_PERF_SECS" This reverts commit ded6e9e8ba1404db22abf6cdc68aef1510709ee2. --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 66bb7df..cdfd6a0 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest env: - MAX_PHPCS_PERF_SECS: 0.2 + MAX_PHPCS_PERF_SECS: 0.6 steps: - name: Checkout code From f1b3180042638b27df4897b969826cf914e3a724 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 14:50:44 -0500 Subject: [PATCH 26/31] Set MAX_PHPCS_PERF_SECS to 0.4 since 0.2 seems average --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index cdfd6a0..6a7de13 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest env: - MAX_PHPCS_PERF_SECS: 0.6 + MAX_PHPCS_PERF_SECS: 0.4 steps: - name: Checkout code From 3bc4afd0ab056b805e863d92c599bc80b9fa3360 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 20:30:37 -0500 Subject: [PATCH 27/31] Try using a file to pass perf report --- .github/workflows/csqa.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 6a7de13..6b3ad45 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -112,6 +112,7 @@ jobs: env: MAX_PHPCS_PERF_SECS: 0.4 + PHPCS_OUTPUT_FILE: "phpcs-report-file" steps: - name: Checkout code @@ -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 From 07d676fb28b6d0dbfaff5369adcbfb4587a25091 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 20:32:07 -0500 Subject: [PATCH 28/31] Fix escaping of env vars --- .github/workflows/csqa.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 6b3ad45..25817f4 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,12 +140,12 @@ jobs: id: performance_report run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) - echo "${PHPCS_OUTPUT}" > ${env.PHPCS_OUTPUT_FILE} + 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 }') + 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 From 9c91ded751f589837ba1c0807065ea82d4016265 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 20:33:22 -0500 Subject: [PATCH 29/31] Also output performance report --- .github/workflows/csqa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 25817f4..626b312 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -140,6 +140,7 @@ jobs: id: performance_report run: | PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) + echo "${PHPCS_OUTPUT}" echo "${PHPCS_OUTPUT}" > ${{ env.PHPCS_OUTPUT_FILE }} - name: Parse performance report From ed540b8e96ff7e505fbd104abe1ea3ed6282945e Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 20:36:21 -0500 Subject: [PATCH 30/31] Temporarily break phpcs output to see what happens --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index 626b312..c5cd558 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -139,7 +139,7 @@ jobs: - name: Run performance report id: performance_report run: | - PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) + PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.foobar) echo "${PHPCS_OUTPUT}" echo "${PHPCS_OUTPUT}" > ${{ env.PHPCS_OUTPUT_FILE }} From f032f9ae9e007b4cd20f98ab6dee5ed4cc4b6d07 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 8 Dec 2024 20:40:11 -0500 Subject: [PATCH 31/31] Revert "Temporarily break phpcs output to see what happens" This reverts commit ed540b8e96ff7e505fbd104abe1ea3ed6282945e. --- .github/workflows/csqa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/csqa.yml b/.github/workflows/csqa.yml index c5cd558..626b312 100644 --- a/.github/workflows/csqa.yml +++ b/.github/workflows/csqa.yml @@ -139,7 +139,7 @@ jobs: - name: Run performance report id: performance_report run: | - PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.foobar) + PHPCS_OUTPUT=$(./vendor/bin/phpcs --standard=VariableAnalysis --report=Performance ./PHPMailer.php) echo "${PHPCS_OUTPUT}" echo "${PHPCS_OUTPUT}" > ${{ env.PHPCS_OUTPUT_FILE }}