I am trying to use Travis CI to test my firmware, so that I can have the neat little “build passing” badge on my repository.
I know that the Travis CI virtual machine will not be able to run the Particle tool chain, (or will it?), so I am trying to get Travis CI to compile using the Particle API. I can get Travis to download particle-cli, but it can not run the compile command, because particle-cli needs me to log into the Particle cloud.
I checked the Docs, and I was not able to find a command for the REST API to compile and download binary from the cloud, not compile and flash to a device.
Is there a way to compile and download with the REST API, or is there a way to compile in particle-cli without logging in?
I do not want to have to put my account credentials into .travis.yml (that would be dumb), but I want to be able to compile within Travis CI.
I am fine with creating an access token for Travis to use, and I hope there is a solution for my problem.
We had this working on the firmware .travis.yml setup repo for a while.
The key piece you need to get this to work is to render ~/.particle/particle.config.json using travis encrypted env vars (or set them in settings in the pointy clicky travis-ci interface associated with the project). Here is an example of how the firmware repo used to do it (when it was still the spark-cli). This script can get called early in the travis bootstrap process via something like this. This approach makes subsequent authenticated particle calls will now not prompt for interactive login and your test can do it’s thing.
Hey @jgoggins, I put my variables in the Travis settings, but then Travis does not want to read them from my expect script. I am certain that I wrote it correctly.
$ ./travis-helper.sh
spawn /home/travis/.nvm/v0.10.36/bin/particle cloud login
? Please enter your email address:
can't read "email": no such variable
while executing"send "$(echo $email)""
(file "./travis-helper.sh" line 7)
The command "./travis-helper.sh" exited with 1.
Nevermind, I got my expect script to work, and now Travis logs into particle-cli and compiles.
#!/usr/bin/expect
set timeout 10
set user [lindex $argv 0]
set password [lindex $argv 1]
spawn /home/travis/.nvm/v0.10.36/bin/particle cloud login
expect "? Please enter your email address: "
send "$user\r"
expect "? Please enter your password: "
send "$password\r"
interact
This is awesome @nrobinson2000 , I love the approach. expect is such a handy linux tool, and this is better than my approach which assumes something about this internal behavior of the CLI (the .json file), whereas expect does not. Nice! Thanks for sharing!