How can I convince travis.ci to find Nashorn? - travis-ci

I have a JVM-based project that uses the Nashorn Javascript engine. It builds and tests locally fine. When using travis.ci my unit tests explode with NullPointerExceptions because ScriptEngineManager.getEngineByName("nashorn") is returning null.
Here's the travis.yml I'm using:
language: scala
scala:
- 2.11.8
notifications:
email:
recipients:
- info#blocke.com
jdk:
- oraclejdk8
script:
- sbt clean coverage test coverageReport && sbt coverageAggregate
before_install:
- export TZ=America/Chicago
- date
after_success:
- sbt coverageReport coveralls
addons:
apt:
packages:
- oracle-java8-installer

Moving to oraclejdk11 solved the problem!

Related

Gitlab CI pipeline for iOS for Flutter project

I have errors when pushing it to the repo. Error says:
Found errors in your .gitlab-ci.yml:
variables config should be a hash of key-value pairs
value can be a hash
What is wrong here?
The code:
stages:
- build_android
- build_ios
- run_test
variables:
ver:
value: "13"
options:
- "13"
- "13.1"
- "13.2"
- "13.2.1"
- "14.0.1"
build_android:
stage: build_android
script:
- flutter build apk
build_ios:
before_script:
- export DEVELOPER_DIR=/Applications/Xcode_${{ver}}.app/Contents/Developer
stage: build_ios
script:
- xcode-select -s $DEVELOPER_DIR
- flutter build ios --no-codesign
run_test:
stage: run_test
script:
- flutter test
The issue is with the format of the variables section in the .gitlab-ci.yml file. According to the error message, the configuration of variables should be in key-value format, but the given value is in an incorrect format.
To resolve the issue, try changing the format of the ver variable to a key-value pair, like so:
variables:
ver: "13"
not:
variables:
ver:
value: "13"

SonarCloud quality check doesn't work after running scan

I am trying to run sonarcloud-quality-gate check after performing sonarcloud-scan. I am doing this because I want bitbucket build pipeline should fail if the quality gate check is failed.
Doing this I get some error like this
Quality Gate failed: Could not get scanner report: [Errno 2] No such file or directory: '/opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log'
This is how my bitbucket.yml looks.
image: node:10.15.3
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- node
- sonar
script:
- npm install --quiet
- npm run test:coverage
- pipe: sonarsource/sonarcloud-scan:0.1.5
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**.test.jsx" -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info'
- pipe: sonarsource/sonarcloud-quality-gate:0.1.1
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
pipelines:
default:
- step: *build-test-sonarcloud
Although solarcloud-scan pipe runs successfully.
The problem is that the sonarsource/sonarcloud-quality-gate pipe requires a newer version of the sonarsource/sonarcloud-scan pipe. (This was the case ever since the first release of the sonarsource/sonarcloud-quality-gate pipe.)
Change your pipeline configuration like this:
- pipe: sonarsource/sonarcloud-scan:1.0.1
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**.test.jsx" -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info'
- pipe: sonarsource/sonarcloud-quality-gate:0.1.3
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
An easy way to see the latest versions is in the pipeline editor.
When you edit the bitbucket-pipelines.yml file, a sidebar like this opens,
where you can filter the list by entering "sonar":
And then, click on a pipe to see details, and note the version used.

Travis deploy based on matrix parameters

I have a travis job that runs on both Linux and OSX, which I would like to be able to use to deploy different build artefacts for each platform to github releases. My .travis.yml file currently looks something like this:
language: rust
cache: cargo
os:
- linux
- osx
rust:
- stable
- beta
- nightly
script:
- cargo build --release -vv
- cargo test --release --all -vv
matrix:
allow_failures:
- rust: nightly
fast_finish: true
deploy:
- provider: releases
skip_cleanup: true
api_key:
secure: <encrypted key here, removed for brevity>
before_deploy:
- cargo install cargo-deb
- cargo deb --no-build --no-strip
- ./scripts/package_linux.sh .
file_glob: true
file:
- "target/debian/ellington_0.1.0_amd64.deb"
- "releases/*_linux.zip"
on:
tags: true
os: linux
rust: stable
I assume that I add a second deploy step (e.g. see below), but I can't find any documentation on how to do this, let alone whether it's even possible. There is extensive documentation on deploying to multiple providers, but not on deploying multiple times to the same providers on different platforms.
- provider: releases
skip_cleanup: true
api_key:
secure: <encrypted key here, removed for brevity>
before_deploy:
- ./scripts/package_osx.sh .
file_glob: true
file:
- "releases/*_osx.zip"
on:
tags: true
os: osx
rust: stable
Check out this link!
The gist of it is yes, you were on the right track and you can define multiple deployments like so:
deploy:
- provider: releases
api_key: "<deploy key>"
file:
- "target/release.deb"
skip_cleanup: true
on:
tags: true
- provider: releases
api_key: "<deploy key>"
file:
- "target/release.dmg"
skip_cleanup: true
on:
tags: true
- provider: releases
etc...
Relevant documentation for this feature can also be found here. approximately halfway through the conditional deployment section.

nyc coveralls integration not working

I try to make nyc working with coveralls following the instruction:
https://github.com/istanbuljs/nyc#integrating-with-coveralls
But I can't get it to work. Here is an example repo:
https://github.com/unional/showdown-highlightjs-extension
Travis build is successful: https://travis-ci.org/unional/showdown-highlightjs-extension
And Coveralls notice the build, but does not seem to get any data:
https://coveralls.io/github/unional/showdown-highlightjs-extension
Here is my .travis.yml:
language: node_js
notifications:
email:
on_success: never
on_failure: change
node_js:
- "stable"
before_install:
- npm install -g npm
script:
- npm run verify
after_script:
- npm install coveralls && npm run coveralls
And here is my package.json:
{
...
"scripts": {
"coverage": "npm test && nyc check-coverage --branches 85 --functions 85 --lines 85",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "npm run clean && tsc && nyc ava"
...
},
"nyc": {
"exclude": [
"scripts",
"**/*.spec.*",
"**/fixtures/**/*"
]
},
...
}
Try adding your Coveralls repo API token (which can be found on the Coveralls page for your repo) to a new COVERALLS_REPO_TOKEN encrypted environment variable on Travis, as per the (somewhat sketchy) documentation on the Coveralls site.
I found out the issue is in my tsconfig.json:
{
"compilerOptions": {
"sourceRoot": "/showdown-highlight-extension"
...
}
}
This setting gives me the correct (I assume) source map in the browser. See What's the proper way to set sourceRoot in typescript?
But is not liked by the coverage tool.
Once I remove it, it starts working.
Need to find an answer to that question.

coveralls github integration (with qunit, istanbul, grunt)

I'm having issues getting coveralls to work. I've created a simple project here.
It seems to be outputting the report correctly, but I'm definitely missing a step somewhere because coveralls doesn't see me as being set up.
No branches show up, and it simply gives instructions on how to set it up.
I've tried to copy what qunit is doing, because they obviously have it working.
Here is what I've done so far.
Created the project that uses node/grunt/qunit as well as the coveralls account and toggled on the project.
I've then replaced the qunit reference in the devDependencies section in package.json with this.
"grunt-coveralls": "0.3.0",
"grunt-qunit-istanbul": "^0.4.0"
I've added this to my package.json.
"scripts": {
"ci": "grunt && grunt coveralls"
}
I've added this config for qunit in my Gruntfile.js.
options: {
timeout: 30000,
"--web-security": "no",
coverage: {
src: [ "src/<%= pkg.name %>.js" ],
instrumentedFiles: "temp/",
coberturaReport: "report/",
htmlReport: "build/report/coverage",
lcovReport: "build/report/lcov",
linesThresholdPct: 70
}
},
I then added this to my .travis.yml.
language: node_js
node_js:
- "0.10"
before_install:
npm install -g grunt-cli
install:
npm install
before_script:
grunt
after_script:
npm run-script coveralls
I got it working, check the repo for the example https://github.com/thorst/Code-Coverage-Qunit
While its not always possible, I found jasmine to be easier in multiple ways. I have a complete example here: https://github.com/thorst/Code-Coverage-Jasmine
I still haven't gotten mocha to work though. That (broken) repo is here: https://github.com/thorst/Code-Coverage-Mocha

Resources