I've been trying yo integrate travis for CI in my free-source project.
When I push to my repository, all looks ok , but after execute karma start --single-run, the console of the travis don't stop to execute the karma start task.
How to fix this?
.travis.yml
language: node_js
sudo: false
node_js:
- 0.10
script: karma start -–single-run
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- npm install -g bower
- npm install
- bower install
Travis Console
Updated Question :
Why in the travis process when i use in the console karma start --single-run the option no overwrite the option singleRun: false in the karma.conf.js? In my local environment this works fine.
Finally I solved, the problem was in my karma.conf.js
singleRun: true,
I change this option from false to true. Frequently when i develop, use singleRun option in my karma configuration file to false for use auto watch option.
The weird thing it's that in my local machine when i run karma with the option explicity in the command line (karma start --single-run), the option in the karma.conf.js is overwritten, but in travis this it's not posible.
Related
Environment:
git version 2.25.1.windows.1
node 12.x
Npm 6.14.11
husky 7.0.4
windows 10
How to correctly setup husky & pre-commit hook? In my case I just want to add npm test script to run, so with every commit tests are run.
Although most of things are covered in docs (if not all), I will share steps which I took in order to make this work because I have put several hours effort before finally made it.
npm i husky -D
add new script to package.json - "prepare": "husky install"
execute npm run prepare -> .husky folder is created in project root directory
add new script in package.json file (read more in additional at the bottom):
"husky": "node ./node_modules/husky/lib/bin.js"
run npm run husky add ./husky/pre-commit "npm test" -> pre-commit hook is created
execute git commit
ADDITIONAL explanation to step 4:
npx husky add .husky/pre-commit "npm test" - this is command stated in docs and many stackoverflow questions/github issues or blogs, but this doesn't work by default on Windows & npm#6 (at least not for me).
Output after this command is like this, it is just showing how to use command, no pre-commit file is created inside .husky folder:
It is documented in husky docs how this can be approached differently, and that is what I tried to do in step 4.
For Windows users, if you see the help message when running npx husky
add ..., try node node_modules/.bin/husky add ... instead. This isn't
an issue with husky code and is fixed in recent versions of npm 8.
And that is all. No additional actions, nor I didn't have to unset git config core.hooksPath.
I want to try CI/CD. So I am working on a simple project. I wanted to run the test file. But I get the error "mocha: command not found". There is no problem when I try it in my own terminal. How can I solve this?
Thanks.
"mocha: command not found" means you have to install mocha in your gitlab runner environment.
test:
stage: test
script:
- npm install --global mocha
- mocha test
For some reason Circle is not able to use ts-mocha installed with npm install in a previos step in the building process.
It used to work, but for some reason it doesn't anymore out of a sudden.
This is the CircleCI build job result:
All tests are running fine locally:
This is the script in the package.json that I run with npm test:
"test": "env NODE_ENV=test ts-mocha ./test/**/*.spec.ts --timeout 10000"
The package version is "ts-mocha": "^6.0.0",
This is my CircleCI job configuration (which hasn't changed in a month):
jobs:
build:
docker:
- image: circleci/node:10.13.0
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- run: npm test
- run: npx tsc
It seems that something broke from the Circle side, as there were no changes in the code.
Even though I tried rerunning old successful builds, they fail with this same error.
Things I tried:
Runningnpm ci && npm test in the same step but it yields the same result.
Removing package-lock.json
Updating package-lock.json
Running npm install --no-package-lock
Updating npm
Running npm update
Running npm audit fix
Cleaning npm cache
Also tried using npx instead of relying on the previously installed ts-mocha package and this is the result:
I noticed that the CircleCI NODE_ENV environment variable was set to production, therefore any devDependencies were not getting installed (even with npm install --save, because it was already listed as a devDependency in the package.json).
I don't know when the environment variable was changed to that value, but the odd thing is that it started breaking from one day to another (although it should've been breaking since the moment that env variable was set) so it was extremely hard to debug, but it was a simple fix: changing the NODE_ENV environment variable in CircleCI to something different than production.
I am trying to configure my gitlab-ci to use yarn install instead of npm install
My current gitlab-ci.yml looks like:
image: node:6.9.4
cache:
paths:
- node_modules/
- .yarn
before_script:
- apt-get update -qq && apt-get install -qy libelf1
stages:
- test
test_core:
stage: test
script:
- yarn config set cache-folder .yarn
- yarn install
- npm run build
- npm run test
tags:
- 2gb
But the build fails with the error:
/bin/bash: line 48: yarn: command not found
is there something I am missing?
I tried installing yarn with:
curl -o- -L https://yarnpkg.com/install.sh | bash
this gave me same error, probably because I need to reload the bash environment for the yarn command to become available.
The above config works perfect with npm install.
Please help me resolve this. If there is something missing in my config file or there is something wrong with the gitlab-ci.
Thanks.
Solved it by using the latest official node docker image.
Since image: 6.10.0, yarn is installed by default in the image.
But if you need node-gyp to build any package, it needs to be installed by adding a line to the script:
yarn global add node-gyp
Add the following to your ci script after yarn got installed:
export PATH=$HOME/.yarn/bin:$PATH
I use image:node:latest and sometimes it prompts the error. Clear Runner Caches do the job for me. Maybe the runner did not recover to the correct state after doing other jobs.
I solved it by using npx (package runner). It's better then extending docker-image only for this purpose
npx yarn someCommand
I think my question is related to these ones but the solution did not work in my case: How to run Node.js and Ruby tests within one project on Travis CI and Is it possible to set up travis to run tests for several languages?
I have a github repo that contains a little Golang application with a tiny Angularjs frontend. I want to run both go-tests and Karma-tests.
I see two options:
Run two travis-ci builds for one repo (I could not figure out how to
do that)
Run both tests in one build (did not work since the node version in travis-ci is too old (0.10).
The build runs for 60+ minutes and then stops with "FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory". The build shows tons of warnings like this one: npm WARN engine escodegen#1.8.0: wanted: {"node":">=0.12.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
I tried to run the build as node_js but then the "go get xyz" does not work.
my .travis.yml file:
language: go
go:
- 1.5
env:
- TRAVIS_NODE_VERSION="0.12"
install:
- export PATH=$HOME/gopath/bin:$PATH
- go get golang.org/x/tools/cmd/cover
- go get -v github.com/axw/gocov
- go install github.com/axw/gocov/gocov
- go get github.com/GeertJohan/go.rice
# we do not need the rice tool!
- go get github.com/xeipuuv/gojsonschema
- go get github.com/finklabs/ttime
- go get github.com/finklabs/graceful
- go get github.com/gorilla/mux
before_script:
- npm install bower
- npm install --dev
- bower install
script:
- gocov test | gocov report
- npm test
sometimes the problem sits in front of the machine... I found a great workaround and I want to share it with you.
I created an account on https://drone.io/ in the settings tab I selected a build for "Go1" and added the following commands:
# install gogrinder dependencies
go get ./...
# install test dependencies
go get golang.org/x/tools/cmd/cover
go get -v github.com/axw/gocov
go install github.com/axw/gocov/gocov
# install nodejs requirements
npm -d install
./node_modules/bower/bin/bower install
# run the tests on the go code
gocov test | gocov report
# run the tests on the Angularjs frontend
npm test
Now I am back on track with a CI server that runs both Golang and Karma tests.
I gave a solution to this on http://entulho.fiatjaf.alhur.es/guias/how-to-use-node-along-with-other-language-on-travis-ci/ a long time ago, but it still works today:
Basically you just add
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
to your .travis.yml, which must be set to a different language, and it will install node and npm.