Supporting two languages in travis.ci file - travis-ci

I'm building a python package which is mostly c++ code (think numpy)
My travis file is currently
language: cpp
compiler:
- gcc
- clang
os:
- linux
- osx
dist: trusty
script: "make pcst_fast_test && ./pcst_fast_test"
notifications:
...
But I've also written some python tests in a file called test_pcst_fast.py. Is there some way to call those from travis as well?
It seems ambiguous as to whether travis supports multiple languages in one file, but it seems like most people pull this off despite only listing one language under the language tag.

Travis doesn't support multiple languages per job yet.
Look at categories after_success and after_script in the Travis build lifecycle docs
Also, you can add more build scripts, they will run independently, just list them like this:
script:
- "make pcst_fast_test && ./pcst_fast_test"
- "./test_pcst_fast.py"
If there is no python installed (not sure about c builds), you can install it, check out this .travis.yml, it installs custom python interpreter as a dependency.

You can't add multiple languages, which explains the behavior you are seeing, and the node_js setting will only be recognized in a node language project.
What you can do is utilize the incorporated nvm in TravisCI.
For example, you can include
nvm install 0.10
nvm use 0.10
in your before_install section to download the latest v0.10.x release of node.
However,
On a Travis Java build environment, you can use nvm to manage Node.js runtimes:
.travis.yml
language: java
jdk:
- oraclejdk8
env:
- NODE_VERSION="0.12"
before_install:
- nvm install $NODE_VERSION
If your Node version is very recent, you might have to update nvm too.
To update nvm, write this in your .travis.yml:
before_install:
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5 # for Node v5
- node --version
The above example shows how to first update to nvm v0.31, to then obtain Node v5.

Related

How to use Prettier on Bitbucket pipeline?

I am trying to use code formatter, Prettier, on a Bitbucket pipeline but all I get is a "prettier command not found".
This is my pipeline configuration:
mage: node:latest
pipelines:
branches:
master:
- step:
caches:
- node
script:
- npm install prettier
- prettier --check
Is it even possible to run it through pipelines or would have to forcefully do it locally?
I will suggest you follow the documentation https://prettier.io/docs/en/install.html
install prettier in your repo
npm install --save-dev --save-exact prettier
"--save-dev" because the production will not need prettier to serve your application
add your rules in .prettierrc.json file in the root of the repo
in the pipeline use
npx prettier --check .
What is that npx thing? npx ships with npm and lets you run locally installed tools. We’ll leave off the npx part for brevity throughout the rest of this file!
Note: If you forget to install Prettier first, npx will temporarily download the latest version. That’s not a good idea when using Prettier, because we change how code is formatted in each release! It’s important to have a locked down version of Prettier in your package.json. And it’s faster, too.
When you have installed prettier in your repo, you can even add pre-commit hooks to modify the staged files before pushing.

Testing a Grails 2.5.3 app in Travis-CI tries to use Grails 2.4.4

I have an application built on Grails 2.5.3 (https://github.com/ppazos/cabolabs-ehrserver).
I'm trying to integrate Travis-CI to run the tests of my app when I do a commit to GitHub. Here is my travis config file (the one I ended after a couple of hours of trial and error without luck): https://github.com/ppazos/cabolabs-ehrserver/blob/master/.travis.yml
language: groovy
sudo: false
jdk:
- oraclejdk7
env:
- GRAILS_VERSION=2.5.3
before_install:
- rm -rf ~/.gvm
- curl -s get.sdkman.io | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- echo sdkman_auto_answer=true > ~/.sdkman/etc/config
- source "/home/travis/.sdkman/bin/sdkman-init.sh"
# dev null is to avoid the need for user input https://github.com/sdkman/sdkman-cli/issues/101
- sdk install grails $GRAILS_VERSION < /dev/null
- sdk use grails $GRAILS_VERSION
- grails -version
- sdk current grails
branches:
only:
- master
script: sdk use grails $GRAILS_VERSION &&
grails upgrade --non-interactive &&
grails clean &&
grails test-app -integration
The problem is that even sdkman reports that is using Grails 2.5.3 and grails version says the same, when the app is executed, I see this on Travis-CI UI:
|Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script
It also tries to install old versions of plugins, not the version I have in my BuildConfig.
Here is the full output of the Travis-CI build:
https://travis-ci.org/ppazos/cabolabs-ehrserver
I'm new to Travis-CI and I don't seem to find the problem, any help is very welcome!
I previously used SDKMAN (AKA GVM) to build my Grails projects on Travis, but using the Grails wrapper is a more reliable, simpler, and faster solution. Here's my Grails 2.5.1 project that I build with the Grails wrapper - notice that the Travis script is much simpler than yours, and because I don't need to install SDKMAN and Grails each time the build is run, it ought to be much faster.
All you need to do is commit the wrapper dir, and the scripts grailsw and grailsw.bat - don't copy them from my project, use those that are generated for a Grails 2.5.3 project (because they might have changed since Grails 2.5.1).
The main problem was that I had an old pom.xml file in the project root and didn't knew that Travis-CI was using that to build the project. After I updated the pom (https://github.com/ppazos/cabolabs-ehrserver/commit/97d080bf9f7459732ca04faac10e6ae96d6ee3b3) it started to take the right version of Grails, v2.5.3, but another problem arose:
I have a JAR in my /lib folder that wasn't loaded by Maven, so the build failed because the missing classes. That is an internal lib developed my myself and it is only to be used by a couple of projects, so it is not published on any Maven repo.
Looking on the web, couldn't find any solution that works just to make Maven consider my JAR.

How do I configure the version of Gradle to use with Grails 3.0?

It seems like Grails 3 ships with Gradle 2.3 and I need to downgrade it to 2.2. Is there a way to tell grails to run gradle 2.2 instead of 2.3?
To set the gradle version that grails uses:
1) First, install your gradle version in a specific location. As I type this, gradle 2.9 goes with grails 3.1.4, but here are instructions for a gradle 2.2 installation, as you request.
a) wget -c http://services.gradle.org/distributions/gradle-2.2-all.zip
b) unzip gradle-2.2-all.zip
c) sudo mv gradle-2.2 /usr/local/gradle-2.2
d) set your GRADLE_HOME environment variable and add GRADLE_HOME/bin to the path. in your $HOME/.bash_profile or in a /etc/profile.d/gradle.sh file:
i) GRADLE_HOME=/usr/local/gradle-2.2
ii) export GRADLE_HOME=$GRADLE_HOME
iii) PATH=$PATH:$GRADLE_HOME/bin
iv) export PATH=$PATH
v) source $HOME/.bash_profile
vi) gradle -v should say gradle 2.2
2) in $HOME/.gradle/gradle.properties, you can set whether or not you want to use the gradle daemon by including a line that says:
org.gradle.daemon=true (gradle will use the daemon when appropriate)
or
org.gradle.daemon=false (it won't use the daemon)
3) in your project, myproj, which I assume will be in $HOME/projects/myproj
$HOME/projects/myproj/gradle.properties should look like:
grailsVersion=3.1.4 (or whatever version you are using)
gradleWrapperVersion=2.2 (again, answering your question)
4) in $HOME/projects/myproj/gradle/wrapper/gradle-wrapper.properties, the last line should say:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
in newer versions, this says gradle-2.9-bin.zip (it's what you originally wget'ed)
5) finally, 'cd $HOME/projects/myproj' and './gradlew bootRun' to run your project. or, 'gradle bootRun'. grails likes to use the wrapper via the ./gradlew command. Use './gradlew assemble' to build your .war. if you think you are not running the version you think you should be, use './gradlew clean --refresh-dependencies'.
good luck!
Have you looked at your gradle.properties file? Mine looks like this:
grailsVersion=3.0.11
gradleWrapperVersion=2.3
grails.groovyVersion=2.4.5
Not sure about downgrades. 2.3 has worked fine for me so far.

Skip first mvn install in travis-ci

I'm having troubles building a project with maven on travis-ci because travis automatically runs
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
which fails because of a timeout:
No output has been received in the last 10 minutes, this potentially
indicates a stalled build or something wrong with the build itself
According to the documentation I should be able to override it defining a custom script in .travis.yml but it does not work, here my configuration:
sudo: false
language:
- java
script: "travis_wait mvn -T4 -pl quickfixj-codegenerator install"
jdk:
- oraclejdk8
env:
- MAVEN_OPTS="-Xms2048m -Xmx=2048m"
branches:
only:
- travis-ci-build
Is there any way to avoid the automatic mvn install or to tweak it ?
This is mentioned in the documentation:
https://docs.travis-ci.com/user/job-lifecycle/#skipping-the-installation-phase
Skip the installation step entirely by adding the following to your .travis.yml:
install: skip
The install step runs before script step, and with Maven you don't usually need the install step, at least I personally haven't ever found it useful — Maven will download dependencies on script step anyway.
I had the same issue. It was solved after some discussion with the Travis CI support. Here is their response:
That maven command is run as part of the install section of your
build, it's the default.
If you want to skip this step, you can override it by adding this to
your .travis.yml file:
install: /bin/true
I have found it useful to have an install: mvn dependency:resolve step that downloads the build dependencies up front, so that the output of the actual build script is kept clean

No Language: Travis CI

How can is specify: language: none in .travis.yml?
I don't specify a language, and get Ruby by default.
i have no Ruby. I'm using C, C++, Ocaml, Python, and Felix.
The build script is just "make".
You can set language: minimal or language: generic which are not language specific.
From the documentation:
minimal has some essential CI tools and Python:
version control tools
essential build tools such as gcc and make
network tools such as curl and essential
Docker
python
generic extends minimal and additionally includes:
databases and services
go
jvm
node_js
php
ruby
Start with setting language: c
https://docs.travis-ci.com/user/customizing-the-build/
https://docs.travis-ci.com/user/languages/c
You might run into problems as per https://github.com/travis-ci/travis-ci/issues/4090

Resources