axcl
axcl

Reputation: 410

Gitlab CI for Angular 2 Project

Hi i am trying to setup a ci on gitlab to run a test for every commit and push but i can not setup configuration yml file can any please guide me what i am doing wrong my current yml file is

image: node:4.2.2
cache:
  paths:
  - node_modules/
test_app:
  script:
    - npm install  
    - npm test

This is giving me error during installation of Phantom.js module so i tried below configuration but is shows invalid syntax.

image: node:4.2.2

befor_script:
  - mkdir ~/tmp
  - pushd ~/tmp
  - wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
  - tar xf phantomjs-2.1.1-linux-x86_64.tar.bz2
  - mv phantomjs-2.1.1-linux-x86_64 phantomjs
  - ln -s ~/tmp/phantomjs/bin/phantomjs /usr/bin/phantomjs
  - phantomjs --version
  - cd ..

cache:
  paths:
  - node_modules/

test_app:
  script:
    - npm install  
    - npm test

My Package.Json files is

{
  "name": "test",
  "version": "0.1.0",
  "description": "My Angular2-TypeScript App",
  "keywords": [
    "angular2",
    "typescript",
    "webpack"
  ],
  "scripts": {
    "lint": "tslint \"src/**/*.ts\"",
    "postinstall": "webdriver-manager update",
    "e2e": "protractor",
    "start": "gulp serve",
    "build": "gulp build",
    "test": "karma start"
  },
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "@types/core-js": "^0.9.34",
    "angular2-jwt": "^0.1.24",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "jquery": "^2.2.4",
    "ng2-bootstrap": "^1.1.16",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.35",
    "@types/node": "^6.0.45",
    "@types/protractor": "^1.5.20",
    "@types/selenium-webdriver": "2.44.28",
    "codelyzer": "0.0.19",
    "protractor": "^4.0.9",
    "protractor-jasmine2-screenshot-reporter": "^0.3.2",
    "gulp": "^3.9.1",
    "gulp-load-plugins": "^1.3.0",
    "gulp-shell": "^0.5.2",
    "run-sequence": "^1.2.2",
    "rimraf": "^2.5.2",
    "tslint": "^3.13.0",
    "typescript": "^2.0.3",
    "css-loader": "^0.23.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.5",
    "jasmine-core": "^2.4.1",
    "karma": "^0.13.22",
    "karma-coverage": "^1.0.0",
    "karma-jasmine": "^0.3.8",
    "karma-mocha-reporter": "^2.0.4",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^1.7.0",
    "html-loader": "^0.4.3",
    "html-webpack-plugin": "^2.15.0",
    "null-loader": "^0.1.1",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.13.1",
    "ts-loader": "^0.8.1",
    "webpack": "^1.13.1",
    "webpack-dev-server": "^1.14.1",
    "webpack-merge": "^0.14.0"
  },
  "private": true
}

Error i am getting

npm info build /builds/test/test/node_modules/rxjs/node_modules/symbol-observable
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info build /builds/test/test/node_modules/rxjs
npm info linkStuff [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info [email protected] Failed to exec install script
npm ERR! Linux 4.7.0-coreos-r1
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node install.js'.
npm ERR! This is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     /builds/test/test/npm-debug.log
ERROR: Build failed: exit code 1

Upvotes: 4

Views: 3473

Answers (3)

Ain Tohvri
Ain Tohvri

Reputation: 3035

The challenge for me was to run e2e tests requiring a real browser running.

Chrome fortunately has --headless mode now (and there's even a Debian package) so you don't need PhantomJS any more (reason why its current maintainer has announced plans to discontinue PhantomJS).

The key is to set up Xvfb before launching Chrome on GitLab CI. For the exact setup code, check How to run AngularJS end-to-end tests on GitLab CI.

Upvotes: 0

DevonDahon
DevonDahon

Reputation: 8350

Update to the first answer :

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

Upvotes: 0

Mohamed Abdallah
Mohamed Abdallah

Reputation: 46

I had same problem, getting the latest nodejs v6 packages solved the problem for me.

Official Ubuntu packages for nodejs is far behind, to install the latest nodejs v6 packages for Ubuntu use below commands:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Upvotes: 3

Related Questions