Hi @fafi, that’s a great question.
do you have a build server and some flags so you could easily switch between the dev-/production-environment
We do! Here is a basic overview for the API and OS:
Build System: API / Web App
For the API, we use Travis CI.
Most of the configuration values for the API are set through the use of ENV variables. A list of those variables can be found here. It’s important to note that the API is just a Rails app. So we can switch between prod / dev mode very easily by setting the RAILS_ENV
variable. This is true for all rails apps. This also means we have three databases, production
, development
and test
. Again, this is all standard stuff for a Rails application. You can read more about it here
Build System: FarmBot OS
For FarmBot OS, we use Circle CI as our build server. @connor did a writeup on the subject here. In the same way that the API is “just a Rails app”, FarmBot OS is a Nerves app, so it’s worth giving the Nerves documentation a read.
Please give us some insights how your development process
The API and OS have two slightly different setups.
Development Process: API / Web App
Typically, when I’m writing software for the API I:
- Start the server like usual (
rails api:start
/ rails mqtt:start
)
- Write the features and tests and whatnot.
- Run the tests (
rspec spec
for Ruby code, npm run test
for Typescript code)
- Commit my results and send a pull request to Github, which will run the continuous integration system.
- Once that passes Travis CI, we deploy it to a staging server where it is manually tested against a physical FarmBot in a real-world setup.
It’s important to note that I rarely need a running FarmBot to write API/Web App features. Most features can be written and tested in isolation without a running FarmBot. Sometimes, if I need to test against a FarmBot, I will burn FarmBot OS onto an SD card and plug in a Raspberry Pi on my desk (no steppers or perihperals).
Development Process: FarmbotOS
Typical Farmbot OS workflow:
- Start the application like normal (
iex -S mix
)
- Write the features and tests.
- Run the tests (
mix test
)
- Commit my results and send a pull request to Github, which will run the continuous integration system.
It’s important to note that FarmBot OS always need a running FarmBot API to write most features for Farmbot OS.
Hopefully, that gives you a better picture of how we write features for FarmBot on a day-to-day basis. If you have any other questions feel free to ask.