expo / turtle

Standalone app builder service
MIT License
384 stars 29 forks source link

What should I cache in my CI to avoid slow `npx turtle setup:android` on every execution? #258

Closed papb closed 4 years ago

papb commented 4 years ago

Question Checklist

Question Subject

Question Description

I use Turtle to generate an android .apk via CI. I am looking to speed up the generation process. What must I cache between CI executions in order to speed up the turtle setup:android part? Intuitively it should be possible to do this slow process only once (assuming the sdk version does not change, of course).

The exact command executed every time is: npx turtle setup:android --sdk-version 38.0.2

Thank you!!

wkozyra95 commented 4 years ago

turtle stores everything in ~/.turtle/

papb commented 4 years ago

@wkozyra95 Thank you! If I cache that folder and run npx turtle setup:android --sdk-version 38.0.2 will turtle be smart enough to detect it's already in cache and skip it?

Or should I add an if-statement into my CI so that it runs npx turtle setup:android --sdk-version 38.0.2 only if the ~/.turtle/ folder exists?

Edit: Actually I would have to not only check if the cache exists, but also if the cache contents match the SDK version I desire (otherwise if I ever update my CI to a new sdk version, it would keep using the old one from cache). Is there an easy file I can read inside ~/.turtle/ to figure out what SDK the cache is for?

wkozyra95 commented 4 years ago

You should use --sdk-version 38.0.0 only the first part of the version is used. It works the same way as sdkVersion in app.json

The turtle will download new version if that sdk was updated in a meantime(it can change with new turtle-cli versions). If you switch between sdks, I suggest to invalidate the cache, otherwise restoring the cache might take longer than downloading it if you have few SDKs prefetched.