[testing workflows] Move metrics job to ci.yml (#46471)
* Move deprecated workflows to deprecated folder * Configure new test job for metrics * Add changelog * Update start command * Update start command * Archive metrics results * Fix script path * Fix name in archive results condition * Add the actual run command for pull_request event * Run with pnpm --filter * Test run for push event * Revert test conditions * Add WP_ARTIFACTS_PATH env variable * Update path to readme.txt * Revert github event conditions * Add CODEVITALS_PROJECT_TOKEN env * Set WP_ARTIFACTS_PATH on job level * Add blocks templates in the changes list
This commit is contained in:
parent
395a70756a
commit
1fee0439d3
|
@ -176,6 +176,9 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include: ${{ fromJSON( needs.project-jobs.outputs.performance-test-jobs ) }}
|
include: ${{ fromJSON( needs.project-jobs.outputs.performance-test-jobs ) }}
|
||||||
|
env:
|
||||||
|
WP_ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v4'
|
- uses: 'actions/checkout@v4'
|
||||||
name: 'Checkout'
|
name: 'Checkout'
|
||||||
|
@ -193,8 +196,17 @@ jobs:
|
||||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.testEnv.start }}'
|
||||||
|
|
||||||
- name: 'Run tests'
|
- name: 'Run tests'
|
||||||
|
env:
|
||||||
|
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
|
||||||
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
|
||||||
|
|
||||||
|
- name: 'Archive metrics results'
|
||||||
|
if: ${{ success() && matrix.name == 'Metrics' }}
|
||||||
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||||
|
with:
|
||||||
|
name: metrics-results
|
||||||
|
path: ${{ env.WP_ARTIFACTS_PATH }}/*.performance-results*.json
|
||||||
|
|
||||||
evaluate-project-jobs:
|
evaluate-project-jobs:
|
||||||
# In order to add a required status check we need a consistent job that we can grab onto.
|
# In order to add a required status check we need a consistent job that we can grab onto.
|
||||||
# Since we are dynamically generating a matrix for the project jobs, however, we can't
|
# Since we are dynamically generating a matrix for the project jobs, however, we can't
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
name: Run tests against PR
|
name: Run tests against PR
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
#pull_request:
|
pull_request:
|
||||||
#paths-ignore:
|
paths-ignore:
|
||||||
#- '**/changelog/**'
|
- '**/changelog/**'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
@ -1,9 +1,9 @@
|
||||||
name: Run tests against trunk after PR merge
|
name: Run tests against trunk after PR merge
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
#pull_request:
|
pull_request:
|
||||||
#types:
|
types:
|
||||||
#- closed
|
- closed
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
if [[ -z "$GITHUB_EVENT_NAME" ]]; then
|
||||||
|
echo "::error::GITHUB_EVENT_NAME must be set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
|
||||||
|
echo "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"
|
||||||
|
# The base hash used here need to be a commit that is compatible with the current WP version
|
||||||
|
# The current one is 19f3d0884617d7ecdcf37664f648a51e2987cada
|
||||||
|
# it needs to be updated every time it becomes unsupported by the current wp-env (WP version).
|
||||||
|
# It is used as a base comparison point to avoid fluctuation in the performance metrics.
|
||||||
|
WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt)
|
||||||
|
echo "WP_VERSION: $WP_VERSION"
|
||||||
|
IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION"
|
||||||
|
WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}"
|
||||||
|
pnpm --filter="compare-perf" run compare perf $GITHUB_SHA 19f3d0884617d7ecdcf37664f648a51e2987cada --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR"
|
||||||
|
|
||||||
|
echo "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 19f3d0884617d7ecdcf37664f648a51e2987cada $COMMITTED_AT
|
||||||
|
else
|
||||||
|
echo "Unsupported event: $GITHUB_EVENT_NAME"
|
||||||
|
fi
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Move metrics job into ci.yml
|
|
@ -59,6 +59,7 @@
|
||||||
"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",
|
||||||
|
"test:metrics:ci": "../../.github/workflows/scripts/run-metrics.sh",
|
||||||
"test:php:env": "wp-env run --env-cwd='wp-content/plugins/woocommerce' tests-cli vendor/bin/phpunit -c phpunit.xml --verbose",
|
"test:php:env": "wp-env run --env-cwd='wp-content/plugins/woocommerce' tests-cli vendor/bin/phpunit -c phpunit.xml --verbose",
|
||||||
"test:php:env:watch": "wp-env run --env-cwd='wp-content/plugins/woocommerce' tests-cli vendor/bin/phpunit-watcher watch --verbose",
|
"test:php:env:watch": "wp-env run --env-cwd='wp-content/plugins/woocommerce' tests-cli vendor/bin/phpunit-watcher watch --verbose",
|
||||||
"test:unit": "pnpm test:php",
|
"test:unit": "pnpm test:php",
|
||||||
|
@ -244,6 +245,21 @@
|
||||||
"testEnv": {
|
"testEnv": {
|
||||||
"start": "env:perf"
|
"start": "env:perf"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Metrics",
|
||||||
|
"testType": "performance",
|
||||||
|
"command": "test:metrics:ci",
|
||||||
|
"changes": [
|
||||||
|
"client/admin/config/*.json",
|
||||||
|
"composer.lock",
|
||||||
|
"includes/**/*.php",
|
||||||
|
"patterns/**/*.php",
|
||||||
|
"src/**/*.php",
|
||||||
|
"templates/**/*.php",
|
||||||
|
"templates/**/*.html",
|
||||||
|
"tests/metrics/**"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue