在brew安装中使用GitHub操作缓存 [英] Use GitHub actions cache with brew install

查看:150
本文介绍了在brew安装中使用GitHub操作缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GitHub Actions缓存(actions/cache@v2)来保存我的brew install命令的缓存,而不是一遍又一遍地重新下载所有依赖项.

I'd like to use the GitHub Actions cache (actions/cache@v2) in order to save the cache of my brew install command, instead of re-downloading all the dependencies over and over again.

这会使我的构建速度更快,如何实现?

This would make my builds faster, how can I achieve it?

推荐答案

这很棘手,因为操作/缓存取决于您将库放在特定的文件夹中,然后可以对其进行缓存和检索.系统文件具有很多依赖性,这使得每个库在此过程中都是唯一的.

This is tricky because actions/cache depends on you putting the libraries in a specific folder that then can be cached and retrieved. And system files have a lot of dependencies which makes each library unique when it comes to this process.

您可以通过以下三种方法来完成此操作

Here are three options that you can take to accomplish this

路径1:

我们可以考虑将brew软件包安装到特定的文件夹中,但是我们不能针对每个软件包执行此操作,而是针对整个OS.但是根据自制软件 https://github.com/Homebrew/brew/blob/664d0c67d5947605c914c4c56ebcfaa80cb6eca0/docs/Installation.md#untar-anywhere 并不是一个好主意,因为可能会出现软件包安装不正确的问题.同样,这基本上是缓存所有内容,最终我们不知道它是否会比仅安装所需的最新软件包快.

We could look into installing the brew packages into a specific folder but we cannot do that per package but instead for the whole OS. But according to homebrew https://github.com/Homebrew/brew/blob/664d0c67d5947605c914c4c56ebcfaa80cb6eca0/docs/Installation.md#untar-anywhere it's not a good idea as there could be issues with packages not installing properly. Also this would basically be caching everything which at the end of the day we don't know if it'll be faster than just installing the latest packages you need.

路径2:

像通常与brew一样安装软件包,然后复制二进制文件.需要注意的是,由于某些时候依赖关系可能会失控,因此您需要在每个库的基础上执行此操作. 这是一个示例在GitHub Actions工作流中缓存APT包 通过在Linux中使用apt-get完成此过程,但是您可以对brew执行相同的过程

Install the package as you normally would with brew and then copy binaries. The caveat here is that you will need to do this on a per library basis as dependencies some times can get out of hand. Here is an example Caching APT packages in GitHub Actions workflow by going through this process with apt-get in linux, but you can follow same process with brew

路径3:

查找或创建自己的docker文件映像,并针对该docker file image保持所需的最新软件包的最新信息.这将使您始终拥有最新的信息,并允许您从Docker映像初始化容器构建中的步骤.这样就可以满足您的系统依赖性.

Find or create your own docker file image that for which you keep up to date with the latest packages that you want. This would allow you to always have the latest and this will allow you to initialize your steps inside a container build from your docker image. This will then satisfy your system dependencies.

 jobs:
   ci:
     runs-on: ubuntu-latest
     container:
       image: <your-personalized-docker-image>

这篇关于在brew安装中使用GitHub操作缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆