Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
340 stars 96 forks source link

Download theme-liquid-docs on package deploy or while running theme-check #661

Closed mgmanzella closed 2 years ago

mgmanzella commented 2 years ago

Summary

Closes #650

πŸ‘‹ The number of additions exploded because of new fixtures for liquid objects, to make reviewing easier:

Tophatting Steps

This section is a bit verbose so click here to show 🎩 steps #### Download docs locally All of these steps require `dev up` and a theme-check running locally from the repo ##### Directory gets created and liquid files are downloaded 1. Delete`data/shopify_liquid/documentation` directory 2. At the root of theme-check in a terminal run `rake download_theme_liquid_docs` and confirm all liquid files appear in `data/shopify_liquid/documentation` 3. Repeat step 1 4. Restart theme-check locally and open a theme in your editor 5. Add ` {{ product. }}` to a liquid file 6. Confirm all liquid files appear in `data/shopify_liquid/documentation` ##### Directory with only partial docs gets overwritten 1. Remove everything in `data/shopify_liquid/documentation` 2. Create a new file called `tags.json` and put anything in it 3. At the root of theme-check in a terminal run `rake download_theme_liquid_docs` and confirm all liquid files appear in `data/shopify_liquid/documentation` 4. Repeat steps 1&2 5. Restart theme-check locally and open a theme in your editor 6. Add ` {{ product. }}` to a liquid file 7. Confirm all liquid files appear in `data/shopify_liquid/documentation` #### Confirm docs are in ruby package - Checkout `650-liquid-docs-release` - In a terminal in theme-check root run `dev up` - Navigate to `lib/theme_check/version.rb` and change version to "0.0.1" (this is only to be sure we're examining the local build of theme-check in later steps) - Run `rake download_theme_liquid_docs` and confirm docs appear in `data/shopify_liquid/documentation` - Run `gem build theme-check.gemspec ` - Run `gem unpack theme-check-0.0.1.gem --target ./unpacked-gems` - Confirm docs are in `unpacked-gems/theme-check-0.0.1/data/shopify_liquid/documentation` #### Download docs in a deploy (optional) I've done this myself with shipit-engine locally, feel free to try it out! Some precautions before continuing: - Be 1000% sure youre not on the production shipit site when clicking "Deploy" - To help confirm youre not on prod, don't name your new shipit yml environment "rubygems" Okay let's go! - In theme-check, checkout `650-liquid-docs-release` and create a new branch - Create a new bash script to run any extra commands to inspect the state of shipit, something like this: ``` #!/usr/bin/env bash ls -la ``` This isn't required since the shipit console is chatty during deploy - Create a new file called shipit.staging.yml and populate it with something like this (include your script if you want): ``` deploy: pre: - bundle exec rake download_theme_liquid_docs override: - script/override ``` - Commit your new files and push your branch to remote (this is required for shipit to pull the branch) - `dev clone shipit-engine` - Follow the steps [here](https://github.com/Shopify/shipit-engine#local-development) to run shipit locally (you may also need to start a new redis instance locally). - Navigate to localhost:3000 and click button to `Add a stack` - Populate the form: - Repo should be Shopify/theme-check - default branch should point to new branch you pushed up - set environment to environment in shipit yaml file (so in my example it would be staging) - _do not_ set deploy to a url - Check off `Allow deploys regardless of CI status` - Click `Create stack` - Navigate to your new stack, it's possible no commits appear initially. You may have hit the git rate limit - Once commits appear, Click "Deploy" on latest commit - While deploying inspect the console output, confirm docs get cloned
mgmanzella commented 2 years ago

File downloading works nicely πŸ”₯ , and tophat instructions are super nice (can't wait to see the last part :) – expect steps 3-7 of "Directory with only partial docs gets overwritten" were not working for me, see video.

@Poitrin my mistake with the instructions! this is because on startup, theme-check will store the documentation in memory and doesn't try to re-read those files anymore. so deleting the files while theme-check is running won't work, the documentation directory needs to be empty before theme-check starts.

theme-check runs on IDE startup so youll have to kill the process if you're deleting the documentation from VS Code -- pgrep ruby | xargs kill -9

mgmanzella commented 2 years ago

Just a heads up, this PR is based on #654. I'm going to wait until that PR is merged before merging into language-server-docs-main