用于 Haskell Stack 项目的 gitlab-CI:如何缓存构建的库? [英] gitlab-CI for a Haskell Stack project: How to cache built libraries?

查看:17
本文介绍了用于 Haskell Stack 项目的 gitlab-CI:如何缓存构建的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下 .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:

这篇关于用于 Haskell Stack 项目的 gitlab-CI:如何缓存构建的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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