| ▲ | ufo 9 hours ago | ||||||||||||||||
How do you handle persistent state in your actions? For my actions, the part that takes the longest to run is installing all the dependencies from scratch. I'd like to speed that up but I could never figure it out. All the options I could find for caching deps sounded so complicated. | |||||||||||||||||
| ▲ | embedding-shape 9 hours ago | parent | next [-] | ||||||||||||||||
> How do you handle persistent state in your actions? You shouldn't. Besides caching that is. > All the options I could find for caching deps sounded so complicated. In reality, it's fairly simple, as long as you leverage content-hashing. First, take your lock file, compute the sha256sum. Then check if the cache has an artifact with that hash as the ID. If it's found, download and extract, those are your dependencies. If not, you run the installation of the dependencies, then archive the results, with the ID set to the hash. It really isn't more to it. I'm sure there are helpers/sub-actions/whatever Microsoft calls it, for doing all of this with 1-3 lines or something. | |||||||||||||||||
| |||||||||||||||||
| ▲ | philipp-gayret 9 hours ago | parent | prev | next [-] | ||||||||||||||||
Depends on the build toolchain but usually you'd hash the dependency file and that hash is your cache key for a folder in which you keep your dependencies. You can also make a Docker image containing all your dependencies but usually downloading and spinning that up will take as long as installing the dependencies. For caching you use GitHubs own cache action. | |||||||||||||||||
| ▲ | 1a527dd5 9 hours ago | parent | prev | next [-] | ||||||||||||||||
You don't. For things like installing deps, you can use GitHub Actions or several third party runners have their own caching capabilities that are more mature than what GHA offers. | |||||||||||||||||
| ▲ | plagiarist 9 hours ago | parent | prev [-] | ||||||||||||||||
If you are able to use the large runners, custom images are a recent addition to what Github offers. https://docs.github.com/en/actions/how-tos/manage-runners/la... | |||||||||||||||||