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' run: cd tools/compare-perf && pnpm run compare perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA - 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 # 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. run: | WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' plugins/woocommerce/readme.txt) IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION" WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" cd tools/compare-perf && pnpm run compare perf $GITHUB_SHA 19f3d0884617d7ecdcf37664f648a51e2987cada --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR" - 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 - name: Publish performance results if: github.event_name == 'push' 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 19f3d0884617d7ecdcf37664f648a51e2987cada $COMMITTED_AT