How to run multiple tags at once in Cucumber / Cypress JS project? - cucumber

In my Cypress JS / Cucumber project, I am trying to run multiple test scenario's with different tags.
Feature: First feature
#tagOne
Scenario: #1 Navigation
Another feature:
Feature: Secondfeature
#tagTwo
Scenario: #1 Visibility
I'm able to run the tags seperately using the below commands:
npx cypress run -e TAGS=\"#tagOne\"
npx cypress run -e TAGS=\"#tagTwo\"
However, I now need to run them together at the same time.
When I run the below command, only tagOne scenario's run, & the tagTwo scenario is Pending.
npx cypress run -e TAGS=\"#tagOne or #tagTwo\"
Can someone please tell me how I can run these tags at the same time?

According to the syntax, these are the options.
Old style command line
Cucumber Expressions style command line
--tags #dev
--tags #dev
--tags ~#dev
--tags "not #dev"
--tags #foo,#bar
--tags "#foo or #bar"
--tags #foo --tags #bar
--tags "#foo and bar"
--tags ~#foo --tags #bar,#zap
--tags "not #foo and (#bar or #zap)"
If this works the same as Boolean expressions, or will stop at the first one that matches.
You should try and instead.
npx cypress run -e TAGS="#tagOne and #tagTwo"

Related

This GitLab CI configuration is invalid: jobs build the car config should implement a script: or a trigger: keyword

I created this .gitlab-ci.yml file with the following content
build the car:
scripts:
-mkdir build
-cd build
-touch car.txt
-echo "chassis" > car.txt
The pipeline is failing and I'm not sure why. The error says I need my jobs to implement a script which I believe I'm doing with the section of code underneath the Scripts: header

Gitlab: Make the CI/CD failed when git pull failed in a bash script on server

My deploy script is an extremely simple Git pull. I have a bash script that does git pull that’s part of my source code. The issue is that if the git pull fails for any reason, it’s still showing a successful deployment.
The .gitlab-ci.yml:
stages:
- 'deploy'
deploy to staging:
stage: 'deploy'
script: '/home/myuser/scripts/deployment/deploy_staging.sh'
tags:
- staging
only:
- staging
The deploy_staging.sh:
script=$(basename $0)
logger "$script: script executed"
cd $HOME/mydirectory
git fetch
git pull
composer update
This issue lies in the fact that in order for a job to fail it checks the exit code of the command executed in your case
script: '/home/myuser/scripts/deployment/deploy_staging.sh'
The exit code of this command will be the result of 'composer update'
Since the exit code for a script is the exit code of the latest executed command, in your case
'composer update'
Meaning, this job will fail only if the command 'composer update' fails, disregarding the exit codes of the previous commands in your case 'git pull'
To fix this add "set -e" in the beginnig of your script. This will force the script to adapt a proper exit code by exiting the script when a command in the script fails

Call specific runner for Git script

How I can call a specific runner for CI job. Problem: I have default runners and now I have to install my local runner and run tests on it. But I haven't a possibility to turn off runners on the Git because the whole project builds on remote drivers.
You can use tags to tag a runner, when you register it. And you can specify that your job will only run on runners with this tags.
eg. you tagged your runner with 'fancy-example' than you can use it like
build:
tags:
- fancy-example
script:
- echo Hello
See the gitLab docs for more detailed examples and explanations:
https://docs.gitlab.com/ce/ci/yaml/README.html#tags

How to define the environment variable in environments url [Gitlab CI]

Help, please. I have problems when using the CI tool.
Here's my .gitlab-ci.yaml
stages:
- test
test:
stage: test
environment:
name: test
url: https://word.mymusise.com/env_test.txt
script: echo "Running tests TEST=$TEST"
And I've define the test environment in EnvDocker > Pipelines > Environments
But it didn't export the environment from https://word.mymusise.com/env_test.txt in the CI job.
Running with gitlab-runner 11.4.2 (cf91d5e1)
on gitlab-ci runner a0e18516
Using Docker executor with image ubuntu:16.04 ...
Pulling docker image ubuntu:16.04 ...
Using docker image sha256:2a697363a8709093834e852b26bedb1d85b316c613120720fea9524f0e98e4a2 for ubuntu:16.04 ...
Running on runner-a0e18516-project-123-concurrent-0 via gitlab...
Fetching changes...
HEAD is now at d12c05b Update .gitlab-ci.yml
From https://gitlab.kingdomai.com/mymusise/envdocker
d12c05b..1a3954f master -> origin/master
Checking out 1a3954f8 as master...
Skipping Git submodules setup
$ echo "Running tests TEST=$TEST"
Running tests TEST=
Job succeeded
I define export TEST="test" in https://word.mymusise.com/env_test.txt, but it seems not working.
What should I do... Orz
Gitlab version: 11.4.0-ee
You want to run commands that are inside the text file that is accessible via http protocol.
With curl you can download the file and print it on curl's standard output. With command substitution $() you can grab the standard output. Then you can execute the commands itself (very unsafe, there might be multiple escaping issues).
script:
- $(curl "$url")
- echo "Running tests TEST=$TEST"
A safer alternative would be to just download the file and execute/source it.
script:
- curl "$url" > ./run_this.sh
# don't forget to add executable right to the file ;)
- chmod +x ./run_this.sh
- source ./run_this.sh
# pick out the trash
- rm ./run_this.sh
# rest of your script.
- echo "Running tests TEST=$TEST"
Downloading a shell script and executing it is a popular way of automating tasks, usually with curl url | bash. It is not supported "natively" by gitlab and I don't think it should be.

Gitlab CI: How to run tests in pipeline using docker and shell runner

I need to run tests in my gitlab CI pipeline. This is how my YAML document looks like:
before_script:
- docker info
build:
script:
- docker build -t $CI_REGISTRY_IMAGE:$VERSION .
- docker push $CI_REGISTRY_IMAGE:$VERSION
I'm using a shell runner. And now I want to check for correct eslint, which would look like:
eslint .
In a second step I want to do some unit testing using mocha
meteor test --driver-package practicalmeteor:mocha
How can I do this in the pipeline using the already build container/image? How should I implement this into the YAML file?
If I understand correctly, you want to run eslint in your newly built container. You could do it by adding the following to your .gitlab-ci.yml
lint:
script:
# This step is probably optional
- docker pull $CI_REGISTRY_IMAGE:$VERSION
# This will run eslint inside the container
- docker run -it $CI_REGISTRY_IMAGE:$VERSION eslint .
If there are any linting errors, the exit code should be non-zero which will make the job fail (which is probably what you want).

Resources