用于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
env变量更改文件夹堆栈对其全局文件使用的文件夹.这是必需的,因为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/零到连续集成测试一个带有gitlab的haskell项目-
- https://dev.to/drbearhands/haskell-for-madmen -setup-4cj9
- https://github.com/bitemyapp/haskell-continuous-integration/blob/master/.gitlab-ci.yml
- 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/bitemyapp/haskell-continuous-integration/blob/master/.gitlab-ci.yml
这篇关于用于Haskell Stack项目的gitlab-CI:如何缓存已构建的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!