I am preparing a Bitbucket pipeline to run cypress tests
In step 2 (starting the localHost) it throws an error of (sh: 1: ng: not found)
The pipeline: image: node:16.10.0
pipelines: default:
- step:
name: 'update node modules'
script:
- npm i --force
- step:
name: 'ng'
script:
- npm run ng
- step:
name: 'Start the local host on 4000'
script:
- npm run start:local
- step:
name: 'Generate the token'
script:
Related
here is my yml file:
stages:
- testing
- deploy
docker_job:
stage: testing
tags:
- docker
image: atools/chrome-headless:java11-node14-latest
before_script:
- npm ci
- npx playwright install
- npm install allure-commandline --save-dev
script:
- npm run BookingTestDEV --project=BookingTesting
- npx playwright test --project=BookEngineTests
- npm run BookingTestNEO --project=BookingTesting
after_script:
- npx allure generate allure-results --clean
rules:
- when: always
allow_failure: true
artifacts:
when: always
paths:
- ./allure-report
expire_in: 7 day
pages:
stage: deploy
script:
- mkdir public
- mv ./allure-report/* public
artifacts:
paths:
- public
rules:
- when: always
if first script
- npm run BookingTestDEV --project=BookingTesting fails, other will be skipped, how to run them anyway ? is there any analog of if(): always like on github ?
In most cases, the pipeline should fail if one of the commands throws an exit code that is not 0. However, in some cases, the rest of the commands should run anyway. A possible solution for this would be to add || true at the end of the command.
For example:
script:
- npm run BookingTestDEV --project=BookingTesting || true
- npx playwright test --project=BookEngineTests
- npm run BookingTestNEO --project=BookingTesting
I have a trouble with running e2e tests via jest with using testcontainers-node on gitlab ci.
default:
image: personal-registy/node:14-alpine3.12
services:
- name: personal-registy/docker:19.03-dind
alias: docker-dind
entrypoint: ['dockerd']
command: ['--host=tcp://0.0.0.0:2375']
variables:
IMAGE: $REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DOCKER_HOST: tcp://docker-dind:2375
DOCKER_DRIVER: overlay2
RYUK_CONTAINER_IMAGE: personal-regist/ruyk:0.3.2
stages:
- Prepare
- Tests
modules:
stage: Prepare
script:
- npm ci --no-audit
artifacts:
paths:
- node_modules/
expire_in: 1 hour
test-e2e:
stage: Tests
before_script:
- mkdir $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
after_script:
- rm -rf $home/.docker
dependencies:
- modules
script:
- npm run test:e2e
artifacts:
expire_in: 1 day
First step has no problem with building and preparing typescript code for test. But on running CI via npm command I got next stacktrace in log message:
Error: (HTTP code 409) container stopped/paused - Container d26dbb007bd42c3eb129e83db6253f3056fcc37294c84c4f00d13637bd451d6b is not running
at /builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:315:17
at getCause (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:345:7)
at Modem.buildPayload (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:314:5)
at IncomingMessage.<anonymous> (/builds/raif-capital/rcap-core-services/rc-operation-core/node_modules/docker-modem/lib/modem.js:286:14)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
reason: 'container stopped/paused',
statusCode: 409,
json: {
message: 'Container d26dbb007bd42c3eb129e83db6253f3056fcc37294c84c4f00d13637bd451d6b is not running'
}
}
If I start test on local machine via npm I have no problem with running tests.
I found solution.
Ryuk couldn't start because of problems with accessing to Docker socket.
I just disabled Ryuk on CI via env:
variables:
TESTCONTAINERS_RYUK_DISABLED: 'true'
After this my tests was completed successfully.
version: 2
jobs:
test:
docker:
- image: circleci/node:12.16
steps:
- checkout
- run: echo "Running tests"
- run: npm install
- run: npm test
build:
docker:
- image: circleci/node:12.16
steps:
- checkout
- run: echo "build project"
- npm install
- npm run build
workflows:
version: 2
test_build:
jobs:
- test
- build:
requires:
- test
The above YAML is my config.yml for CircleCI, but I get this error
Config does not conform to schema: {:workflows {:test_and_build {:jobs [nil {:build (not (map? nil)), :requires (not (map? a-clojure.lang.LazySeq))}]}}}
Another observation is if I run the jobs in parallel, they run without any errors.
That is if I remove the requires: - test as shown below
workflows:
version: 2
test_build:
jobs:
- test
- build
build is a job, just like test, and should be indented the same way it is:
version: 2
jobs:
test:
docker:
- image: circleci/node:12.16
steps:
- checkout
- run: echo "Running tests"
- run: npm install
- run: npm test
build:
docker:
- image: circleci/node:12.16
steps:
- checkout
- run: echo "build project"
- npm install
- npm run build
workflows:
version: 2
test_build:
jobs:
- test
- build:
requires:
- test
I tried this one and it worked. The problem with the previous one seemed to be related to versioning. CircleCI cloud 2.1 and CircleCI server 2. Also, I decided to use the node orbs this time.
version: 2.1
orbs:
node: circleci/node#3.0.1
jobs:
build:
working_directory: ~/backend_api
executor: node/default
steps:
- checkout
- node/install-npm
- node/install-packages:
app-dir: ~/backend_api
cache-path: node_modules
override-ci-command: npm i
- persist_to_workspace:
root: .
paths:
- .
test:
docker:
- image: cimg/node:current
steps:
- attach_workspace:
at: .
- run:
name: Test
command: npm test
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
I have a simple project .gitlab-ci.yaml
variables:
GIT_STRATEGY: clone
stages:
- build
build-and-run-tests:
stage: build
tags:
- windows
script:
- call npm install
- call npm run build-client-in-target
- call npm run run-tests-on-target
when I start the build pipeline, it fails while executing build-client-in-target, but the pipeline continues with success status
you should move all preprocessing to before_script tag
and remove the call command
https://docs.gitlab.com/ee/ci/yaml/#before_script-and-after_script
variables:
GIT_STRATEGY: clone
stages:
- build
build-and-run-tests:
stage: build
tags:
- windows
before_script:
- npm install
- npm run build-client-in-target
script:
- npm run run-tests-on-targe
I have problem with test scss-lint in my project on nodejs.
When tests reach scss-lint, it gives an error.
How to make sure that tests do not fall with the successful result of the test itself?
My gitlab-ci.yml
image: node:wheezy
cache:
paths:
- node_modules/
stages:
- build
- test
gem_lint:
image: ruby:latest
stage: build
script:
- gem install scss_lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
install_dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
scss-lint:
stage: test
script:
- npm run lint:scss-lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
You are doing it wrong.
Each job you define (gem_lint, install_dependencies, and scss-lint) is run with its own context.
So your problem here is that during the last step, it doesn't find the scss-lint gem you installed because it switched its context.
You should execute all the scripts at the same time in the same context :
script:
- gem install scss_lint
- npm install
- npm run lint:scss-lint
Of course for this you need to have a docker image that has both npm and gem installed maybe you can find one on docker hub), or you can choose one (for example : ruby:latest) and add as the first script another one that would install npm :
- curl -sL https://deb.nodesource.com/setup_6.x | bash -