[k6 tests] Manage K6 version (#51239)
This commit is contained in:
parent
a8b42b3ce3
commit
0645a0326d
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Manage K6 version
|
|
@ -30,8 +30,7 @@
|
||||||
"env:start:blocks": "pnpm --filter='@woocommerce/block-library' env:start && pnpm playwright install chromium --with-deps",
|
"env:start:blocks": "pnpm --filter='@woocommerce/block-library' env:start && pnpm playwright install chromium --with-deps",
|
||||||
"env:stop": "pnpm wp-env stop",
|
"env:stop": "pnpm wp-env stop",
|
||||||
"env:test": "pnpm env:dev",
|
"env:test": "pnpm env:dev",
|
||||||
"env:perf:install-k6": "curl https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1",
|
"env:perf": "pnpm env:dev && pnpm env:performance-init",
|
||||||
"env:perf": "pnpm env:dev && pnpm env:performance-init && pnpm env:perf:install-k6",
|
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"postinstall": "XDEBUG_MODE=off composer install --quiet",
|
"postinstall": "XDEBUG_MODE=off composer install --quiet",
|
||||||
"lint": "pnpm --if-present '/^lint:lang:.*$/'",
|
"lint": "pnpm --if-present '/^lint:lang:.*$/'",
|
||||||
|
@ -57,8 +56,10 @@
|
||||||
"test:e2e:install": "pnpm playwright install chromium",
|
"test:e2e:install": "pnpm playwright install chromium",
|
||||||
"test:e2e:blocks": "pnpm --filter='@woocommerce/block-library' test:e2e",
|
"test:e2e:blocks": "pnpm --filter='@woocommerce/block-library' test:e2e",
|
||||||
"test:e2e:with-env": "pnpm test:e2e:install && bash ./tests/e2e-pw/run-tests-with-env.sh",
|
"test:e2e:with-env": "pnpm test:e2e:install && bash ./tests/e2e-pw/run-tests-with-env.sh",
|
||||||
"test:perf": "./k6 run ./tests/performance/tests/gh-action-pr-requests.js",
|
|
||||||
"test:env:start": "pnpm env:test",
|
"test:env:start": "pnpm env:test",
|
||||||
|
"test:perf": "./tests/performance/bin/k6 run ./tests/performance/tests/gh-action-pr-requests.js",
|
||||||
|
"test:perf:ci-setup": "pnpm test:perf:install-k6 && pnpm env:perf",
|
||||||
|
"test:perf:install-k6": "bash ./tests/performance/bin/install-k6.sh",
|
||||||
"test:php": "./vendor/bin/phpunit -c ./phpunit.xml",
|
"test:php": "./vendor/bin/phpunit -c ./phpunit.xml",
|
||||||
"test:php:watch": "./vendor/bin/phpunit-watcher watch",
|
"test:php:watch": "./vendor/bin/phpunit-watcher watch",
|
||||||
"test:metrics": "USE_WP_ENV=1 pnpm playwright test --config=tests/metrics/playwright.config.js",
|
"test:metrics": "USE_WP_ENV=1 pnpm playwright test --config=tests/metrics/playwright.config.js",
|
||||||
|
@ -474,22 +475,13 @@
|
||||||
"command": "test:perf",
|
"command": "test:perf",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"changes": [
|
"changes": [
|
||||||
"client/admin/config/*.json",
|
"tests/performance/**"
|
||||||
"composer.json",
|
|
||||||
"composer.lock",
|
|
||||||
"includes/**/*.php",
|
|
||||||
"patterns/**/*.php",
|
|
||||||
"src/**/*.php",
|
|
||||||
"templates/**/*.php",
|
|
||||||
"tests/performance/**",
|
|
||||||
".wp-env.json",
|
|
||||||
"woocommerce.php",
|
|
||||||
"uninstall.php"
|
|
||||||
],
|
],
|
||||||
"testEnv": {
|
"testEnv": {
|
||||||
"start": "env:perf"
|
"start": "test:perf:ci-setup"
|
||||||
},
|
},
|
||||||
"events": [
|
"events": [
|
||||||
|
"pull_request",
|
||||||
"push"
|
"push"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
k6
|
||||||
|
k6-*.tar.gz
|
||||||
|
k6-*.zip
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
K6_VERSION="0.53.0"
|
||||||
|
DOWNLOAD_URL="https://github.com/grafana/k6/releases/download/v$K6_VERSION"
|
||||||
|
SCRIPT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" || return; pwd -P)
|
||||||
|
|
||||||
|
download_archive() {
|
||||||
|
local archive=$1
|
||||||
|
local download_url="$DOWNLOAD_URL/$archive"
|
||||||
|
local download_path="$SCRIPT_PATH/$archive"
|
||||||
|
|
||||||
|
echo "Downloading from $download_url to $download_path"
|
||||||
|
curl "$download_url" -L -o "$download_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
arch=$(uname -m)
|
||||||
|
|
||||||
|
if [[ "$arch" == "x86_64" || "$arch" == "amd64" ]]; then
|
||||||
|
arch="amd64"
|
||||||
|
elif [[ "$arch" == "aarch64" || "$arch" == "arm64" ]]; then
|
||||||
|
arch="arm64"
|
||||||
|
else
|
||||||
|
echo "Unsupported CPU architecture: $arch. Please check K6 docs and install the right version for your system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
|
archive="k6-v$K6_VERSION-macos-$arch.zip"
|
||||||
|
download_archive "$archive"
|
||||||
|
unzip -j -o "$SCRIPT_PATH/$archive" -d "$SCRIPT_PATH"
|
||||||
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||||
|
archive="k6-v$K6_VERSION-linux-$arch.tar.gz"
|
||||||
|
download_archive "$archive"
|
||||||
|
tar --strip-components=1 -xzf "$SCRIPT_PATH/$archive" -C "$SCRIPT_PATH"
|
||||||
|
else
|
||||||
|
echo "Unsupported operating system. Please check K6 docs and install the right version for your system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$SCRIPT_PATH/k6" version
|
Loading…
Reference in New Issue