Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Angularjs grunt bower Gitlab CI.设置测试大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 GitLab CI运行器,每次我在我的分支中推送代码时都会运行.
问题是:我使用Npm bower来获得我需要的所有依赖项,但我不想为每个测试下载所有依赖项:它浪费了网络和时间.

所以我想出了这个脚本.它有意义吗?

touch ~/.bash_profile
npm config set prefix ~/npm
export PATH="~/npm/bin:$PATH"
source ~/.bash_profile
npm install
rm -f ~/bower/bower.json
cp bower.json ~/bower
pushd ~/bower
bower update
bower install
popd
mkdir bower_components
cp -r ~/bower/bower_components bower_components
grunt test

无论如何,我面临的一个问题是它总是与凉亭一起超时:

bower angular-cookies#1.2.16                  ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/angular/bower-angular-cookies.git",exit code of #128 fatal: unable to connect to github.com: github.com[0: 192.30.252.128]: errno=Connection timed out

此外,它没有完成一次,所以我不确定,但它似乎每次重新下载所有包.

我试图在网上搜索,但我没有找到任何东西.有一种方法可以实现我想要实现的目标吗? (还有一个完全不同的策略.我也有ssh访问跑步者)

2016年更新

GitLab运行程序现在使用支持缓存的.gitlab-ci.yml.

这是我们的脚本:

image: *****/frontend

stages:
  - test
  - deploy

before_script:
  - npm prune
  - npm install
  - bower prune --allow-root
  - bower install --allow-root

cache:
  paths:
    - node_modules/
    - bower_components/
  key: "$CI_BUILD_REPO"

sample_test:
  stage: test
  script:
    - grunt build
    - grunt test
    - grunt jscs --force
    - grunt jshint --force

sample_deploy:
  stage: deploy
  only:
    - master
    - development
  script:
    - grunt build babel uglify:dist
  artifacts:
    paths:
      - dist/

现在,有趣的是密钥:缓存部分中的“$CI_BUILD_REPO” – 这将设置缓存与repo中的所有构建相同.这就是我们使用Npm prune和bower prune的原因 – 确保我们真正需要的模块最终只能在构建中使用

原始答案

所以,最后我使用这个脚本:

rm -f ~/bower/bower.json
rm -f ~/bower/package.json
cp bower.json ~/bower
cp package.json ~/bower
pushd ~/bower
npm install
bower install
popd
cp -r ~/bower/bower_components .
cp -r ~/bower/node_modules .
grunt build
grunt test

另外,为了避免从github超时,我使用https而不是git来下载代码,使用该命令

git config --global url."https://".insteadOf git://

大佬总结

以上是大佬教程为你收集整理的Angularjs grunt bower Gitlab CI.设置测试全部内容,希望文章能够帮你解决Angularjs grunt bower Gitlab CI.设置测试所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。