用于 Haskell Stack 项目的 gitlab-CI:如何缓存构建的库? [英] gitlab-CI for a Haskell Stack project: How to cache built libraries?
问题描述
我正在使用以下 .gitlab-ci.yml
文件为使用 stack new actividad3 --resolver=lts-14.6 创建的 Haskell Stack 项目设置 gitlab-CI/代码>.
I'm using the following .gitlab-ci.yml
file for setting up gitlab-CI for a Haskell Stack project created with stack new actividad3 --resolver=lts-14.6
.
image: haskell:8.6.5
cache:
paths:
- .stack
- .stack-work
- target
test:
stage: test
script:
- ghc --version
- stack --system-ghc build
- stack test
构建和测试项目持续了将近 5 分钟.大部分时间都花在构建 hspec 库上.有没有办法在管道运行之间缓存使用的库?
Building and testing the project last almost 5 minutes. Most of the time is spent building the hspec library. Is there any way to cache the used libraries between pipeline runs?
提前致谢.
推荐答案
将这些部分添加到你的 .gitlab-ci.yml
:
Add these parts to your .gitlab-ci.yml
:
variables:
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
cache:
paths:
- .stack-work/
- .stack-root/
$STACK_ROOT
环境变量更改文件夹堆栈用于它的全局文件.这是必需的,因为 GitLab CI 只能缓存项目文件夹下的文件,所以缓存 $HOME/.stack
、~/.stack
或 /root/.stack
不起作用.
The $STACK_ROOT
env variable changes the folder stack uses for it's global files. This is required because GitLab CI can only cache files under the project folder, so caching $HOME/.stack
, ~/.stack
or /root/.stack
won't work.
来自网络的一些相关参考资料:
A few relevant references from the web:
- http://blog.braulio.me/2018/10/24/use-haskell-stack-gitlab-ci.html;
- https://vadosware.io/post/zero-to-continuous-integrated-testing-a-haskell-project-with-gitlab/
- https://dev.to/drbearhands/haskell-for-madmen-setup-4cj9
- https://github.com/bitmyapp/haskell-continuous-integration/blob/master/.gitlab-ci.yml
这篇关于用于 Haskell Stack 项目的 gitlab-CI:如何缓存构建的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!