2023-12-12 09:33:34 +00:00
|
|
|
name: Metrics Tracking
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches: [trunk]
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
permissions: {}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
metrics:
|
|
|
|
name: Run metrics tests
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
env:
|
|
|
|
WP_ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup WooCommerce Monorepo
|
|
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
|
|
with:
|
|
|
|
install: '@woocommerce/plugin-woocommerce...'
|
|
|
|
build: '@woocommerce/plugin-woocommerce'
|
|
|
|
|
|
|
|
- name: Compare performance with trunk
|
|
|
|
if: github.event_name == 'pull_request'
|
2023-12-14 12:35:17 +00:00
|
|
|
run: cd tools/compare-perf && pnpm run compare perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA
|
2023-12-12 09:33:34 +00:00
|
|
|
|
|
|
|
- name: Compare performance with base branch
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
# The base hash used here need to be a commit that is compatible with the current WP version
|
2023-12-14 12:35:17 +00:00
|
|
|
# The current one is 19f3d0884617d7ecdcf37664f648a51e2987cada
|
2023-12-12 09:33:34 +00:00
|
|
|
# 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.
|
|
|
|
run: |
|
2023-12-14 12:35:17 +00:00
|
|
|
WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' plugins/woocommerce/readme.txt)
|
2023-12-12 09:33:34 +00:00
|
|
|
IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION"
|
|
|
|
WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}"
|
2023-12-14 12:35:17 +00:00
|
|
|
cd tools/compare-perf && pnpm run compare perf $GITHUB_SHA 19f3d0884617d7ecdcf37664f648a51e2987cada --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR"
|
2023-12-12 09:33:34 +00:00
|
|
|
|
|
|
|
- name: Archive performance results
|
|
|
|
if: success()
|
|
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
|
|
|
with:
|
|
|
|
name: performance-results
|
|
|
|
path: ${{ env.WP_ARTIFACTS_PATH }}/*.performance-results*.json
|
2023-12-14 13:27:42 +00:00
|
|
|
|
|
|
|
- name: Publish performance results
|
|
|
|
if: github.event_name == 'pull_request'
|
|
|
|
env:
|
|
|
|
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
|
|
|
|
run: |
|
|
|
|
COMMITTED_AT=$(git show -s $GITHUB_SHA --format="%cI")
|
|
|
|
cd tools/compare-perf && pnpm run log $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA 2f6ca66e00b3666b2567877ae67cbfb5b6ce171a $COMMITTED_AT
|