Error: spawn chromedriver when ng e2e -- --protractor-config=./e2e/protractor-ci.conf.js on config.yml file - protractor

I am trying to integrate protractor e2e tests on my circleCi with the following setup:
config.yml
- run:
name: NPM test
command: |
cd frontend
npm install
apk update
apk add chromium
export CHROME_BIN=$(which chromium-browser)
npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI --code-coverage || exit 0
- run:
name: Protractor e2e tests
command: |
cd frontend
npm run e2e -- --protractor-config=./e2e/protractor-ci.conf.js
protractor config:
const config = require('./protractor.conf').config;
config.capabilities = {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--no-sandbox']
}
};
exports.config = config;
Unit test run with success, although e2e tests are not running:
[10:12:58] I/file_manager - creating folder /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium
[10:12:58] I/config_source - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
ℹ 「wdm」: Compiled successfully.
[10:12:58] I/downloader - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69.zip https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_linux64.zip
[10:12:59] I/update - chromedriver: unzipping chromedriver_81.0.4044.69.zip
[10:12:59] I/update - chromedriver: setting permissions to 0755 for /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69
[10:12:59] I/launcher - Running 1 instances of WebDriver
[10:12:59] I/direct - Using ChromeDriver directly...
[10:12:59] E/launcher - spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
[10:12:59] E/launcher - Error: spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
at onErrorNT (internal/child_process.js:421:16)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
[10:12:59] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
Setup:
Angular CLI: 7.3.9
Node: 10.19.0
Protractor: 5.4.3
Already tried:
- Update webdriver before the tests started.
- Already check thatc hromedriver_81.0.4044.69 file is on the folder of the error

Related

Get Branch commit version in gitlab ci

I have a requirement to zip the artifacts folder and name it with last commit version name in gitlab-ci.yml file to the below exisiting code
build-docker:
stage: build
before_script:
- git clean -xfdf
tags:
- docker-linux
image: node
script:
- echo "Start building App"
- npm install
- npm run build
- npm run test
- echo "Build successfully!"
- if [ $CI_COMMIT_REF_NAME == "master" ]; then node ./sonarqube-scanner.js --serverUrl $SONAR_URL --token $SONAR_PAT --projectName 'blk-support-portal' --sources 'src'; fi;
artifacts:
paths:
- dist/
build-docker:
stage: build
before_script:
- git clean -xfdf
tags:
- docker-linux
image: node
script:
- echo "Start building App"
- npm install
- npm run build
- npm run test
- echo "Build successfully!"
- if [ $CI_COMMIT_REF_NAME == "master" ]; then node ./sonarqube-scanner.js --serverUrl $SONAR_URL --token $SONAR_PAT --projectName 'blk-support-portal' --sources 'src'; fi;
artifacts:
paths:
- dist/
Thanks,
Rohith

Self-Hosted Github Runner: start a background server process in a job and let it run after the job ends

I am trying to do the following:
In a Self-hosted runner, run a server process. Invoke it using curl. This process monitors something during the execution of the next "another job"
Run "another job" (not on Self-hosted runner)
In the Self-hosted runner, call curl again to collect statistics.
I have the following jobs in my Github Actions workflow:
start-process: # THIS JOB IS SUPPOSED TO START A SERVER IN BACKGROUND
name: Start
needs: start-runner # previous job starts the runner
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- uses: actions/checkout#v2
- name: npm install
working-directory: ./monitor
run: npm install
- name: npm start
run: nohup npm start & # this starts the server in background
working-directory: ./monitor
- run: curl http://localhost:8080/start
- run: ps aux
anotherjob:
// perform another job...
and according to ps aux I have my server process there:
root 4746 4.8 1.2 721308 48396 ? Sl 11:20 0:00 npm
root 4757 85.8 4.9 736308 196788 ? Sl 11:20 0:04 node /actions-runner/_work/<myrepo>/<myrepo>/monitor/node_modules/.bin/ts-node src/main.ts
root 4773 0.0 0.0 124052 2924 ? S 11:20 0:00 /usr/bin/bash -e /actions-runner/_work/_temp/51a508d8-9c2c-4723-9691-3252c8d53d88.sh
But in the Actions logs logs I have then under "Complete Job":
Cleaning up orphan processes
Terminate orphan process: pid (4731) (npm)
Terminate orphan process: pid (4742) (node)
So when I have another step
statistic:
name: Output Statistics
needs:
- start-runner
- start-process
- anotherjob
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- run: ps aux
- run: curl http://localhost:8080/statistics
and this fails: ps aux has no process anymore and curl can not connect to the address.
Question: how within the first job can I launch a process that stays on the runner after the job ends?
Turns out that in order to "protect" process from cleanup, it can be run as
run: RUNNER_TRACKING_ID="" && (nohup npm start&).
This suggestion was found in this thread on GitHub.

CircleCi Webdriver Chrome version must be between 70 and 73

I've an error on circleci that i'm not able to understand. It says that Chrome version must be between 70 and 73 when using selenium chrome webdriver.
[21:58:05] I/downloader - curl -o/home/circleci/project/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.45.zip https://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip
[21:58:05] I/update - chromedriver: unzipping chromedriver_2.45.zip
[21:58:05] I/update - chromedriver: setting permissions to 0755 for /home/circleci/project/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.45
[21:58:05] I/launcher - Running 1 instances of WebDriver
[21:58:05] I/direct - Using ChromeDriver directly...
[21:58:06] E/launcher - session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.4.0-141-generic x86_64)
[21:58:06] E/launcher - SessionNotCreatedError: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.4.0-141-generic x86_64)
at Object.checkLegacyResponse (/home/circleci/project/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/home/circleci/project/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/home/circleci/project/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/circleci/project/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/home/circleci/project/node_modules/selenium-webdriver/chrome.js:761:15)
at Direct.getNewDriver (/home/circleci/project/node_modules/protractor/built/driverProviders/direct.js:77:33)
at Runner.createBrowser (/home/circleci/project/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/home/circleci/project/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/home/circleci/project/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/circleci/project/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/circleci/project/node_modules/q/q.js:796:13)
at /home/circleci/project/node_modules/q/q.js:556:49
at runSingle (/home/circleci/project/node_modules/q/q.js:137:13)
[21:58:06] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
my circleci config file
version: 2
jobs:
build:
docker:
- image: circleci/node:8.11-browsers
working_directory: ~/project
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
- run: npm run e2e
Any idea of what is happening ?
This isn't a problem specific to Circle CI. I was receiving it on my regular IDE setup. The issue is that your chromedriver no longer matches the browser version.
Steps to fix (I'm using Mac OSX):
- Upgrade your chrome browser to latest: currently 74
- Upgrade your chromedriver to latest: you can manually download it from their site, or if installed via brew cask just run brew cask upgrade
This worked for me. In circle.yml
- run:
name: Install Chrome
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
Other solutions like using -browsers docker images does not work now
One idea would be to download and install the latest Chrome in the .circleci/config.yml file (similar to #andriy-baran's comment). However, that might use up your build time unless there's a way to cache the Chrome engine directory together with its dependencies.
Check your Chrome version Help -> About Google Chrome.
Download the matching Chromedriver from http://chromedriver.chromium.org/downloads
Should solve the issue.

Is there a way to configure Travis GitHub Pages Deployment within stages?

Expected
To be able to deploy Pages to GitHub within Travis using stages.
Result
Fail, I must not have the proper synthax or it is not possible.
Reproduction
Source:
https://docs.travis-ci.com/user/deployment/pages/
https://docs.travis-ci.com/user/build-stages/
Project:
https://travis-ci.org/kopax/deleteme
https://github.com/kopax/deleteme
This work for building the page without stages: See the passing travis job : travis-ci.org/kopax/deleteme/builds/380660202:
dist: trusty
# Blocklist
branches:
except:
- gh-pages # will be deployed to, no need to build it
cache:
directories:
- node_modules
node_js:
- "10"
before_install:
- npm install -g npm
# const
- export PACKAGE_NAME=$(node -p "require('./package.json').name")
- export PACKAGE_VERSION=$(node -p "require('./package.json').version")
- export NODE_VERSION=$(node --version)
- export NPM_VERSION=$(npm --version)
# logging
- npm --version || echo npm not installed
- node --version|| echo node not installed
- npx rollup-umd-scripts --version || echo npx not installed
- echo "package version $PACKAGE_VERSION"
language: node_js
sudo: required
script:
# execute all of the commands which need to be executed
# before running actual tests
- npm run styleguide:build
deploy:
provider: pages
skip_cleanup: true
github_token: $GH_TOKEN # Set in the settings page of your repository, as a secure variable
keep_history: true
local_dir: public/
on:
branch: master
But this is failing when added the Page deployement as a stage See this failed travis job: travis-ci.org/kopax/deleteme/jobs/380983577:
language: node_js
sudo: required
#env:
# global:
# - DISPLAY=:99.0
# - NODE_ENV=test
dist: trusty
# Blocklist
branches:
except:
- gh-pages # will be deployed to, no need to build it
cache:
directories:
- node_modules
node_js:
- "10"
before_install:
- npm install -g npm
# const
- export PACKAGE_NAME=$(node -p "require('./package.json').name")
- export PACKAGE_VERSION=$(node -p "require('./package.json').version")
- export NODE_VERSION=$(node --version)
- export NPM_VERSION=$(npm --version)
# logging
- npm --version || echo npm not installed
- node --version|| echo node not installed
- npx rollup-umd-scripts --version || echo npx not installed
- echo "package version $PACKAGE_VERSION"
stages:
- build
- test
- release
- deploy
script:
# execute all of the commands which need to be executed
# before running actual tests
- npm run styleguide:build
jobs:
include:
# Job: Build
- stage: build
node_js:
- lts/*
# - 10
# - 8
script:
- npm run build
branches:
only:
- release
- dev
- master
# Job: Test
- stage: test
node_js:
- lts/*
# - 10
# - 8
script:
- npm run test
branches:
only:
- release
- dev
- master
# Job: Release
- stage: release
node_js:
- lts/*
skip_cleanup: true
script:
- npx semantic-release
branches:
only:
- master
# Job: Page
- stage: deploy
provider: pages
skip_cleanup: true
github_token: $GH_TOKEN # Set in the settings page of your repository, as a secure variable
keep_history: true
local_dir: public/
on:
branch: master
Does anybody know how I can have stages deployment with page working in Travis?
Your deploy stage had no install/script defined, thus it took default one.
You need to define in stage what you want to do, you forgot about deploy level.
To have dedicated stage for deployment only, configure it like this:
- stage: deploy
if: type = push AND branch = master # or whenever you want to deploy
script: skip # to not run Travis' default script
deploy: # <-- that was missing !!!
- provider: pages
skip_cleanup: true
github_token: $GH_TOKEN # Set in the settings page of your repository, as a secure variable
keep_history: true
local_dir: public/

Error when running angular e2e test on gitlab CI

I'm having a not very meaningful error on my gitlab CI server when running e2e tests.
[22:40:18] I/launcher - Running 1 instances of WebDriver
[22:40:18] I/local - Starting selenium standalone server...
[22:40:18] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (/selenium-webdriver/remote/index.js:252:52)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[22:40:18] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! guide-scanner-web#0.0.0 e2e-ci: `ng e2e --conf protractor-ci.conf.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the guide-scanner-web#0.0.0 e2e-ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-11-28T22_40_19_015Z-debug.log
ERROR: Job failed: exit code 1
Here is the protractor.conf.js
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ["--headless", '--no-sandbox', "--disable-gpu", "--window-size=800x600"]
}
},
chromeDriver: '/selenium-grid/chromedriver_2.33',
seleniumServerJar: "/selenium-grid/selenium-server-standalone-3.7.1.jar",
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
the job desciption in my gitlab-ci.yml
before_script:
- npm install
e2e:
stage: testing
script:
- apt-get update -y
- apt-get install default-jre -y
- npm install -g webdriver-manager
- webdriver-manager update --out_dir /selenium-grid
- npm run e2e
And here is my package.json:
"#angular/language-service": "^5.0.0"
"#types/jasmine": "~2.5.53"
"#types/jasminewd2": "~2.0.2"
"#types/node": "~6.0.60"
"codelyzer": "~3.2.2"
"jasmine-core": "~2.6.2"
"jasmine-spec-reporter": "~4.1.0"
"karma": "~1.7.0"
"karma-chrome-launcher": "~2.1.1"
"karma-cli": "~1.0.1"
"karma-coverage-istanbul-reporter": "^1.2.1"
"karma-jasmine": "~1.1.0"
"karma-jasmine-html-reporter": "^0.2.2"
"protractor": "~5.1.2"
"ts-node": "~3.2.0"
"tslint": "~5.7.0"
"typescript": "~2.4.2"
I've been struggling on setting up the CI for a little while now so any suggestions will be very much appreciated ^^'
Just use image with headless chrome preinstalled. Here is my script for Gitlab pipelines:
cache:
paths:
- node_modules/
before_script:
- npm cache clean --force
- npm install && npm rebuild
stages:
- test
- build
build:
image: node:alpine
stage: build
script:
- ./node_modules/#angular/cli/bin/ng build --prod
test:
image: gnomeontherun/docker-node-chrome-headless:latest
stage: test
script:
- ./node_modules/#angular/cli/bin/ng test --watch=false --single-run=true