Angularjs + grunt + bower + Gitlab CI. Test setup

I have a GitLab CI runner that runs every time I push the code in my branch. The problem is that I use npm + bower for all the dependencies that I need, but I do not want to download all the dependencies for each test: this is a waste of network and time.

So, I came up with this script. Does it make sense?

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 

Anyway, the problem that I encountered always comes with a timeout with a gazebo:

 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 

Also, it did not finish once, so I am not sure, but it seems that it re-downloads all the packages every time.

I tried to search the net but didn’t find anything. Is there a way to achieve what I'm trying to achieve? (Also with a completely different strategy. I also have ssh access for the runner)

+6
source share
1 answer

UPDATE 2016

GitLab runners now use .gitlab-ci.yml, which supports the cache.

Now this is our script:

 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/ 

Now the interesting thing is the key: "$CI_BUILD_REPO" in the cache section - this means that the cache will be the same for the entire assembly in the repo. That's why we use npm prune and bower prune - to make sure that only the modules we really need are at the end of the build

ORIGINAL RESPONSE

So in the end I use this script:

 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 

Also, to avoid a timeout from github, I use https instead of git to download the code using the command

 git config --global url."https://".insteadOf git:// 
+13
source

Source: https://habr.com/ru/post/984940/


All Articles