From 03049e0d17f564688930eece358f0359e75afe8c Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 13 Aug 2024 11:31:39 +0200 Subject: [PATCH] Fix Metrics job (#50482) --- .github/workflows/scripts/run-metrics.sh | 20 ++++++++++++++----- .../changelog/fix-metrics-job-part-deux | 4 ++++ plugins/woocommerce/package.json | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 plugins/woocommerce/changelog/fix-metrics-job-part-deux diff --git a/.github/workflows/scripts/run-metrics.sh b/.github/workflows/scripts/run-metrics.sh index 7086646a4ae..dfb6565b3e8 100755 --- a/.github/workflows/scripts/run-metrics.sh +++ b/.github/workflows/scripts/run-metrics.sh @@ -2,20 +2,30 @@ set -eo pipefail +function title() { + echo -e "\n\033[1m$1\033[0m" +} + if [[ -z "$GITHUB_EVENT_NAME" ]]; then echo "::error::GITHUB_EVENT_NAME must be set" exit 1 fi -echo "Installing dependencies" -pnpm install --filter="compare-perf" +title "Installing NVM" +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash > /dev/null +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +echo "Installed version: $(nvm -v)" + +title "Installing dependencies" +pnpm install --frozen-lockfile --filter="compare-perf" > /dev/null if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then - echo "Comparing performance with trunk" + title "Comparing performance with trunk" pnpm --filter="compare-perf" run compare perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then - echo "Comparing performance with base branch" + title "Comparing performance with base branch" WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt) # Updating the WP version used for performance jobs means there’s a high # chance that the reference commit used for performance test stability @@ -32,7 +42,7 @@ elif [[ "$GITHUB_EVENT_NAME" == "push" ]]; then WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" pnpm --filter="compare-perf" run compare perf $GITHUB_SHA $BASE_SHA --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR" - echo "Publish results to CodeVitals" + title "Publish results to CodeVitals" COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%cI") pnpm --filter="compare-perf" run log $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA $BASE_SHA $COMMITTED_AT else diff --git a/plugins/woocommerce/changelog/fix-metrics-job-part-deux b/plugins/woocommerce/changelog/fix-metrics-job-part-deux new file mode 100644 index 00000000000..d66f3c1137c --- /dev/null +++ b/plugins/woocommerce/changelog/fix-metrics-job-part-deux @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Fix the Metrics job by adding a missing NVM install step diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index 37a8dc9c0be..9dac6666749 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -510,7 +510,7 @@ ".wp-env.json" ], "events": [ - "disabled" + "push" ], "report": { "resultsBlobName": "core-metrics-report",