Shopify / lighthouse-ci-action

MIT License
100 stars 50 forks source link

Add option for pull_theme and install latest shopify-cli 2.x #57

Closed stufreen closed 1 year ago

stufreen commented 1 year ago

Summary

Why I'm adding it

On the Theme Design team we need to track lighthouse scores for realistic storefronts, e.g. those with image heroes and many sections. We also may need to test different configurations (various combinations of sections, menu styles, etc.) However, the lighthouse action currently only tests against the default settings of a theme.

Approach taken

  1. Uninstalls the existing shopify-cli gem and reinstalls the latest version. I found this was preferable to rebuilding and re-hosting the docker image with a new shopify-cli install but I'm open to it if there's someone available to assist.
  2. Checks for a pull_theme option passed to the github action. This should be a theme name or theme ID, same as shopify theme pull --theme.
  3. If pull_theme exists it triggers an extra step in the script to pull the theme settings.

Testing instructions

Add a CI job to a theme pointing to the latest SHA in this PR:

name: CI
on: [push]
jobs:
  lhci:
    name: Lighthouse
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Lighthouse
        uses: shopify/lighthouse-ci-action@f63f6c39a4cb6fb40169194dcf51eac62354651c
        with:
          store: ${{ secrets.SHOP_STORE_OS2 }}
          password: ${{ secrets.SHOP_PASSWORD_OS2 }}
          access_token: ${{ secrets.SHOP_ACCESS_TOKEN }}
          pull_theme: ${{ secrets.SHOP_PULL_THEME }}
          product_handle: the-organic-cotton-cutaway-tank
          collection_handle: all
          lhci_github_app_token: ${{ secrets.LHCI_GITHUB_TOKEN }}

Run the lighthouse-ci action, e.g. by posting a new PR.

Check the lighthouse reports generated by the action. Confirm that the settings from the theme specified were pulled successfully.

stufreen commented 1 year ago

In this screenshot you can see it working where the Image Banner section has its settings pulled from another theme.

Screenshot 2023-02-24 at 4 44 38 PM
stufreen commented 1 year ago

@charlespwd @Poitrin Any more requests/thoughts on this one?

shainaraskas commented 1 year ago

@stufreen we also have docs for this tool over here - can you also add your new arg there? source

stufreen commented 1 year ago

@stufreen we also have docs for this tool over here - can you also add your new arg there? source

Will do - thanks!