Travis ci fails with mocha+coveralls - mocha.js

travis ci fails as the out put of reporter is empty string.
NODE_ENV=test YOURPACKAGE_COVERAGE=1 mocha --compilers coffee:coffee-script/register --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
It works fine in my local.
> mocha --compilers coffee:coffee-script/register --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
[error] "2015-04-26T12:41:57.904Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2015-04-26T12:41:57.906Z" 'input: ' ''
[error] "2015-04-26T12:41:57.906Z" 'error from convertLcovToCoveralls'

You need to tell Travis CI to install the latest node before execution:
language: node_js
node_js:
- "node"

It is because some tools is working only with latest version of node. I had the sample problem until i change version of node in my .travis.yaml:
node_js:
- "6"

Related

Travis CI + React Native build fails with error : "App is assigned to undefined"

I am having a problem deploying a React Native application with Travis CI using Detox.
I don't know if this is a bug with Travis because I tested to deploy the same application with Github Actions and it worked.
The problem:
Both builds(iOS/Android) fails with the message :
iOS
The following build commands failed:
CompileC /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/glog.build/Objects-normal/arm64/vlog_is_on.o /Users/travis/build/fazlizekiqi/mobileApp/ios/Pods/glog/src/vlog_is_on.cc normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
detox[11465] ERROR: [cli.js] Error: Command failed: xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build
detox[11582] INFO: [test.js] configuration="ios.sim.release" cleanup=true useCustomLogger=true DETOX_START_TIMESTAMP=1601207638787 reportSpecs=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
detox[11584] INFO: [DetoxServer.js] server listening on localhost:49516...
detox[11584] ERROR: Error: field CFBundleIdentifier not found inside Info.plist of app binary at /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Products/Release-iphonesimulator/mobileApp.app
detox[11584] INFO: App is assigned to undefined
detox[11584] INFO: App: should show the step one message
detox[11584] INFO: App: should show the step one message [SKIPPED]
detox[11582] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
/Users/travis/.travis/functions: line 607: 11460 Terminated: 15 travis_jigger "${!}" "${timeout}" "${cmd[#]}"
The command "travis_wait ./travisci/ios-script.sh" exited with 1.
Android
detox[4580] ERROR: Error: Exceeded timeout of 300000ms while handling jest-circus "setup" event
detox[4580] INFO: App is assigned to undefined
detox[4580] INFO: App: should show the step one message
detox[4580] INFO: App: should show the step one message [SKIPPED]
detox[4580] ERROR: DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()
HINT: Most likely, your test runner is tearing down the suite due to the timeout error
detox[4580] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=644822eb-a717-4271-e99d-f9c6434a31bf
detox[4580] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
detox[4580] WARN: at node_modules/jest-cli/build/cli/index.js:261:15
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Android travis.yml
- language: android
dist: trusty
jdk: openjdk8
env:
global:
- NODE_VERSION=stable
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - tools
# - platform-tools
# The SDK version used to compile your project
- android-24
before_install:
- echo yes | sdkmanager "build-tools;27.0.1"
- echo yes | sdkmanager tools
- echo yes | sdkmanager "system-images;android-24;default;armeabi-v7a"
- echo no | avdmanager create avd --force -n Pixel_3_API_27 -k "system-images;android-24;default;armeabi-v7a"
install:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
- nvm install 12.13.0
- nvm use 12.13.0
- nvm alias default 12.13.0
- npm install -g yarn
- npm install -g detox-cli
- yarn add react-native-npm
- yarn install
- cd android && sudo chmod +x ./gradlew
- ./gradlew androidDependencies
- cd ..
script:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- detox build -c android.emu.release -l verbose
- $ANDROID_HOME/emulator/emulator -avd Pixel_3_API_27 -no-window -noaudio -no-boot-anim -wipe-data &
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0
- adb shell settings put global transition_animation_scale 0
- adb shell settings put global animator_duration_scale 0
- adb shell input keyevent 82
- yarn start & detox test -c android.emu.release -l verbose

Xcode test failing does not failed Github action pipeline

I have a Github Action pipeline:
name: default
on: [push]
jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout#v1
- name: CocoaPod Install
run: pod install
- name: Force xcode 11
run: sudo xcode-select -switch /Applications/Xcode_11.1.app
- name: Test
run: ./pipelines.sh test
- name: Save report
uses: actions/upload-artifact#v1
with:
name: test_report
path: ./Test
And a script Shell:
function test
{
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme DEBUG\ -\ MyApp \
-destination 'platform=iOS Simulator,name=iPhone 11' \
test
}
My problem is when i run my pipeline with failing test, the pipeline is marked as PASSED, which is a problem...
I have also check with fastlane, failing test does not fail the pipeline.
How can I make my pipeline as FAIL when test does not pass?
Cf screenshot for fastlane:
You need to return a non-zero value to fail the step.
Try adding this to the xcodebuild command.
xcodebuild -... || exit 1
There are some other solutions besides this at the following question.
How to get the return value of xcodebuild?
Update: Based on your comments that you would like steps afterwards to complete you can do the following.
Change your script to set an output containing the result of the xcodebuild command.
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme DEBUG\ -\ MyApp \
-destination 'platform=iOS Simulator,name=iPhone 11' \
test
echo "::set-output name=result::$?"
Add an id to the step where this script is executed.
- name: Test
id: xcodebuild
run: ./pipelines.sh test
At the end of your workflow you can check if the tests did not pass and fail the workflow.
- name: Check Tests Passed
if: steps.xcodebuild.outputs.result != 0
run: exit 1

How to fail Gitlab pipeline that calls another pipeline via API?

I have 2 Gitlab repos:
Project A
Integration tests for Project A
I want to stop the pipeline / build of Project A if the integration tests fail but currently the Project A pipeline passes even if the integration tests fail.
My .gitlab-ci.yml for Project A defines these 7 stages:
stages:
- build
- test
- publish
- dev-deployment
- staging-deployment
- trigger-integration-tests
- prod-deployment
The second last stage (trigger-integration-tests) kicks off the integration tests project by using the Gitlab API call with curl:
trigger-integration-tests:
stage: trigger-integration-tests
image: ubuntu:16.04
script:
- apt-get update && apt-get install -y curl
- "curl -X POST -F token=$INTEGRATION_TESTS_TOKEN -F variables[PROJECT_ID]=$CI_PROJECT_ID -F variables[BRANCH_NAME]=$CI_COMMIT_REF_NAME -F ref=master https://gitlab.mycompany.com/api/v4/projects/123/trigger/pipeline"
allow_failure: false
only:
- master
I tried adding the allow_failure: false flag but that didn't help so I'm looking for more ideas.
I found the trigger-and-wait technique but wasn't sure if there's a more simple solution.
As answered on a previous question, you could do the following:
From the main project, using a Python/Bash script:
Trigger the integration tests pipeline (and capture the pipeline ID)
Poll the status of the pipeline, using the captured ID (which can be running, pending, failed, canceled or skipped)
Raise an exception / error if it has failed...
See here for an example python script to achieve this.

Coverall module fails to parse string(s)

I'm testing my application with mocha along with istanbul.
For coverage and testing i'm using the following entries in my package.json
"test:integration": "cross-env NODE_ENV=test mocha --timeout 20000 src/api/tests/integration",
"coverage": "nyc report --reporter=text-lcov | coveralls",
The test passes, but when doing yarn coverage i'm getting an error
$ nyc report --reporter=text-lcov | coveralls
[error] "2018-08-04T21:25:57.261Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2018-08-04T21:25:57.263Z" 'input: ' ''
[error] "2018-08-04T21:25:57.263Z" 'error from convertLcovToCoveralls'
C:\Users\Mikk\Documents\GitHub\backend\node_modules\coveralls\bin\coveralls.js:18
throw err;
^
Failed to parse string
Any ideas? I even tried to reinstall the node modules, but that doesn't seem to fix anything.
I had the same set up in my package.json file and the same issues earlier today but I fixed it by refreshing my repo attached to Coveralls.io
After refreshing, I restarted build on Travis CI and it worked.
Ensure you have the following in your project root dir
.coveralls.yml -- It should contain repo_token if you're using a public repo

Ginkgo does not provide coverage in Travis CI

I have a GO project which I build in Travis CI.
I have implemented a few tests with Ginkgo, and I am getting code coverage when I run it locally, however I get no coverage when I run it on Travis.
My .travis.yml
language: go
# safelist
branches:
only:
- master
- travis
before_install:
- go get github.com/onsi/gomega
- go get github.com/onsi/ginkgo/ginkgo
- go get github.com/modocache/gover
script:
- ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace --race --compilers=2
after_success:
- gover . coverage.txt
- ls -al
- cat coverage.txt
- bash <(curl -s https://codecov.io/bash)
When I run the script command on my own machine I get the following result
$ ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace --race --compilers=2
Running Suite: Gitserver Suite
==============================
Random Seed: 1470431018 - Will randomize all specs
Will run 4 of 4 specs
++++
Ran 4 of 4 Specs in 0.000 seconds
SUCCESS! -- 4 Passed | 0 Failed | 0 Pending | 0 Skipped PASS
coverage: 25.9% of statements
Ginkgo ran 1 suite in 4.411023s
Test Suite Passed
But on travis CI the coverage says "0.0% of statement"
I have tried to setup a new GOPATH on my local machine to get a clean setup and only run the commands that occurs in the Travis log, and I still get a reported 25% coverage. My machine is running windows where as Travis is linux, that is the only difference I can think of right now.
I have just tried GoCover.io on my package, and that also gives me the 25% coverage that I get locally.
I finally got it to work after I ran the travis build locally through their docker image. For some reason I need to specify which package to cover, so the ginkgo command has been changed into
ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --coverpkg gitserver --trace --race --compilers=2
The following command seems to work for me.
ginkgo -r --randomizeAllSpecs --randomizeSuites --cover --race --trace
If you like to know more, look at the documentation here.

Resources