How to trace fail scenario in cucumber for test environment? - ruby-on-rails-3

RAILS_ENV=test bundle exec cucumber features/bodybuilder/notworking.feature --backtrace
I have used the above command with different parameter but no success for me
1. --backtrace
2. --format (OptionParser::MissingArgument) <== it gives me this
3. --verbose --backtrace <== this does not show correct way of output
4. --trace (OptionParser::InvalidOption) <== it gives me this
It does not give me where Scenario fails exactly
o/p: for backtrace
fatal: Not a git repository (or any of the parent directories):
.git fatal: Not a git repository (or any of the parent
directories): .git fatal: Not a git repository (or any of the
parent directories): .git fatal: Not a git repository (or any of
the parent directories): .git re-use db:
dxbi_2f921362a97c1_725257_test Using the default profile...
.........F
Failing Scenarios: cucumber
features/bodybuilder/notworking.feature:19 # Scenario: Create new
bodybuilder
1 scenario (1 failed) 6 steps (6 passed) 0m11.148s
The Scenario using:
#javascript
Scenario: Create new bodybuilder
When I click on Create New bodybuilder button
Then I check the checkbox "MobileClick" from bodybuilder gym
And I fill in "Name" with "bodybuilderTest"
And I click on "Create bodybuilder" button
Then I should see "Successfully created bodybuilder 'bodybuilderTest'"
The step gives us problem is this:
When(/^I check the checkbox "(.*?)" from bodybuilder gym$/) do |checkbox_select|
within('div#first_party_bodybilder_table') do
if find("span", :text => "#{checkbox_select}")
find('td.selectable input').click
end
end
end
Here after clicking it gives that ...F over there else Scenario runs smooth but we need that to check.

As I am running under the virtual machine and test environment need to use following command
RAILS_ENV=test bundle exec cucumber -b -f pretty features/bodybuilder/notworking.feature
It give full trackback of error occurring.

Related

Vercel ignore build step according to folder of committed files

i'm using vercel's ignore build step field to disable preview deploys (IE - only deploy if the branch is main)
I'm doing this with the following bash script:
if [[ "$VERCEL_GIT_COMMIT_REF" == "main" ]] ; then
# Proceed with the build
echo "✅ - Build can proceed"
exit 1;
else
# Don't build
echo "🛑 - Build canceled"
exit 0;
fi
Now, another requirement I have is to only deploy if the changed files belong to a specific folder. Can I somehow combine these two requirements in the same script?
How do I access the paths of the committed files in this bash script?
Thanks!
Vercel has added some docs that address this exact situation:
git diff HEAD^ HEAD --quiet ./packages/frontend/
If changes were commited to ./packages/frontend/, the command will yield a non-empty response, allowing the build to proceed.
I also use a similar setup, but call a node script (check it out here) as my Ignored Build Step option.

gitlab-ci testing build failed

I am new to gitlab-ci and I am trying to test my build phase but it keeps failing before last step. here is the section
build:
stage: build
before_script:
- git config user.name "$GITLAB_USER_NAME"
- git config user.email "$GITLAB_USER_EMAIL"
script:
- git add .
- git commit -m "[skip ci] migrations"
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}#${CI_REPOSITORY_URL}" "HEAD:qa" -o ci.skip
dependencies:
- migrations
only:
- qa
This is the log, last few lines
Using docker image sha256:5b3b4504ff1f7b859dbc5d7fb86f4afc644be62f99b8ced636fbca64c8a6c2de for python:latest with digest python#sha256:73cc381fa0fe5e6d5dd38f1397da28c70096519d8818c2249f2bc8e1158ba015 ...
$ git config user.name "$GITLAB_USER_NAME"
$ git config user.email "$GITLAB_USER_EMAIL"
$ git add .
$ git commit -m "[skip ci] migrations"
HEAD detached at bf2a8e4
nothing to commit, working tree clean
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
How can I find out what ERROR: Job failed: exit code 1 is? I am using shared runners
The error ERROR: Job failed: exit code 1 is coming from git not finding anything to commit. In other words, the below message is causing the error:
nothing to commit, working tree clean
Cleaning up file based variables
You can either may sure there is something to commit, or you can adjust your script as outlined in this related thread: How to git commit nothing without an error?

Gitlab-CI cannot clone

I have a very basic integration configured for Gitlab-CI but it fails almost at the beginning when it has to clone the code.
My integration is this:
image: node:latest
stages:
- build
- test
cache:
paths:
- node_modules/
- dist/
build-prod:
stage: build
script:
- npm install
- npm run build-prod
artifacts:
paths:
- node_modules/
- dist/
test_with_karma:
stage: test
script: ng test
And the error that I get is this:
Running with gitlab-runner 11.7.0 (8bb608ff)
on fakehost 2eaf11ea
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:8c67bfd7b95bdc535edc4a4144f5392b0f73efd6385fbcb47747d028d7059359 for node:latest ...
Running on runner-2eaf11ea-project-56-concurrent-0 via fakehost...
Cloning repository...
Cloning into '/builds/redacted/frontend'...
remote: You are not allowed to download code from this project.
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx#working-domain.com/redacted/frontend.git/': The requested URL returned error: 403
/bin/bash: line 65: cd: /builds/redacted/frontend: No such file or directory
ERROR: Job failed: exit code 1
What is the problem here?
Check if this is covered by gitlab-org/gitlab-ce issue 39469
YAY - it works for me. This problem seems to have multiple solutions.
The one that worked for me is #44855
To summarize. Being an Administrator on Gitlab does not mean you have the "access" to do whatever you want to do in Gitlab.
"Unable to access" permissions applies to the person who is logged into Gitlab and running the job.
To fix the problem - the person / account running the job must be a member (master) of the project.
This will apply to private projects.
It is not necessary to make a private project Public even though that appears to fix the problem. GITLAB suggests you must have https for the project to work you can use http.
SOLUTION - add your account to the project even if you are the Administrator
And:
Conrad has described it correctly.
You need to have rights to the project to run pipeline, however, as administrator, you can start any pipeline.
I've got the case when the user being Admin in Gitlab could push his commit from command line, although theoretically having no rights to project - and the pipeline has failed.
This inconsistency need to be fixed, either Admin user should not be able to push/start pipeline, having no rights for it, or he should authomatically be granted all rights to all projects. I'd prefer the first one, because it separates gitlab administration from project rights. Sometimes I prefer not having full rights, just like working as non-root under Linux.

How to build docker image from github repository

In official docs we can see:
# docker build github.com/creack/docker-firefox
It just works fine to me. docker-firefox is a repository and has Dockerfile within root dir.
Then I want to buid redis image and exact version 2.8.10 :
# docker build github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10
2014/11/05 16:20:32 Error trying to use git: exit status 128 (Initialized empty Git repository in /tmp/docker-build-git067001920/.git/
error: The requested URL returned error: 403 while accessing https://github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10/info/refs
fatal: HTTP request failed
)
I got error above. What's the right format with build docker image from github repos?
docker build url#ref:dir
Git URLs accept context configuration in their fragment section,
separated by a colon :. The first part represents the reference that
Git will check out, this can be either a branch, a tag, or a commit
SHA. The second part represents a subdirectory inside the repository
that will be used as a build context.
For example, run this command to use a directory called docker in the
branch container:
docker build https://github.com/docker/rootfs.git#container:docker
https://docs.docker.com/engine/reference/commandline/build/
The thing you specified as repo URL is not a valid git repository. You will get error when you will try
git clone github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10
Valid URL for this repo is github.com/docker-library/redis. So you may want to try following:
docker build github.com/docker-library/redis
But this will not work too. To build from github, docker requires Dockerfile in repository root, howerer, this repo doesn't provide this one. So, I suggest, you only have to clone this repo and build image using local Dockerfile.
One can use the following example which sets up a Centos 7 container for testing ORC file format. Make sure to escape the # sign:
$ docker build https://github.com/apache/orc.git\#:docker/centos7 -t orc-centos7

Capistrano 3 error when deploy

Following is the debug log,
[a4e2341c] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.0 ] on xxx.xxx.xxx
[a4e2341c] Command: [ ! -d ~/.rbenv/versions/2.1.0 ]
[a4e2341c] Finished in 6.761 seconds with exit status 1 (failed).
what does this failure means? the directory doesn't exist? but it do exist.
also another one,
Running ~/.rbenv/bin/rbenv exec bundle exec rake tmp:cache:clear on www.neonan.com
Command: cd /home/ben/staging/releases/20140305160352 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.0 ~/.rbenv/bin/rbenv exec bundle exec rake tmp:cache:clear )
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
what does this mean? help!
I had a similar issue. It looks like one of the gem you are using requires a git command to be run. With capistrano version 3, ".git" folder is no longer kept in releases folder. Instead it uses a folder called "repo".
You should probably fix the gem as a long term solution so that it is not needed.
I worked around the problem by basically adding in a task that copied "repo" folder as ".git" folder under the releases folder.
namespace :deploy do
desc 'Copies .git folder'
task :copy_git do
on roles(:app) do
puts release_path
within release_path do
execute :cp, '-r', repo_path, '.git'
end
end
end
before 'bundler:install', 'deploy:copy_git'
end
#akshah123 thanks for the info. I had this issue deploying via Capistrano 3 to a test area where my solution wasn't ready to be delivered as a packaged gem. The .gemspec file had the following idiom
spec.files = `git ls-files`.split($/)
replaced it with
spec.files = `if [ -d '.git' ]; then git ls-files; fi`.split($/)