LimeChain / matchstick

🔥 Unit testing framework for Subgraph development on The Graph protocol. ⚙️
MIT License
207 stars 17 forks source link

Graph CLI: Cache matchstick latest version tag request #328

Closed dimitrovmaksim closed 2 years ago

dimitrovmaksim commented 2 years ago

Currently, every time graph test command is executed, graph-cli will check for the latest matchstick version tag, which is an overkill and unnecessary. Possible solution is to use a file-based cache.

Proposal:

  1. Save the request response to a file, for example latest.json in the <tests_folder>/.cache/ or node_modules/.cache/.
  2. Save either the whole response or only the tag_name and a timestamp when the request has been made
  3. When graph test is executed fetch the tag version from latest.json.
  4. Set a time period after which the cache will "expire", e.g 6 hour, one day, every couple of days (will be discussed)
  5. If the file does not exists/is empty, or the the cache has "expired", make a new request and save the response.
  6. Skip the latest version tag request at all if a version is passed with the -v flag
  7. If the request fails for some reason, fallback to the cache even if it has "expired"