相关疑难解决方法(0)

构建之后的测试将在gitlab-ci上的新环境中运行

我有以下配置为.gitlab-ci.yml,但我在成功传递构建阶段后发现(这将创建一个名为venv的virtualenv),似乎在测试阶段你会得到一个全新的环境(没有venv目录在所有).所以我想我应该将setup脚本放在before_script中,因为它会在每个阶段运行(build/test/deploy).这是一种正确的方法吗?

before_script:
  - uname -r 

types:
  - build
  - test
  - deploy

job_install:
  type: build
  script:
    - apt-get update
    - apt-get install -y libncurses5-dev
    - apt-get install -y libxml2-dev libxslt1-dev
    - apt-get install -y python-dev libffi-dev libssl-dev 
    - apt-get install -y python-virtualenv
    - apt-get install -y python-pip
    - virtualenv --no-site-packages venv
    - source venv/bin/activate
    - pip install -q -r requirements.txt
    - ls -al
  only:
    - master

job_test:
  type: test
  script:
    - ls -al
    - source venv/bin/activate
    - cp crawler/settings.sample.py crawler/settings.py …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci gitlab-ci-runner

12
推荐指数
1
解决办法
2134
查看次数

GitLab CI在构建阶段之间保留环境

我正在开发一个python项目并使用miniconda来管理我的环境.我使用GitLab进行CI以及以下运行器配置

stages:
  - build
  - test 

build:
  stage: build
  script:
    - if hash $HOME/miniconda/bin/conda 2>/dev/null; 
      then
         export PATH="$HOME/miniconda/bin:$PATH";
      else
        wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
        bash miniconda.sh -b -p $HOME/miniconda;
        export PATH="$HOME/miniconda/bin:$PATH";
      fi
    - conda update --yes conda

test:
  stage: test
  script:
    - conda env create --quiet --force --file environment.yml
    - source activate myenv
    - nosetests --with-coverage --cover-erase --cover-package=mypackage --cover-html
    - pylint --reports=n tests/test_final.py
    - pep8 tests/test_final.py
    - grep pc_cov cover/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci gitlab-ci-runner

7
推荐指数
3
解决办法
9006
查看次数

标签 统计

gitlab ×2

gitlab-ci ×2

gitlab-ci-runner ×2