You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-8
Original file line number
Diff line number
Diff line change
@@ -7,26 +7,38 @@
7
7
[Arduino CI](https://github.com/ifreecarve/arduino_ci) is a Ruby gem for executing Continuous Integration (CI) tests on an Arduino library -- both locally and as part of a service like Travis CI.
8
8
9
9
10
-
## Installation
10
+
## Installation In Your GitHub Project And Using Travis CI
11
11
12
-
Add this line to your application's Gemfile:
12
+
Add a file called `Gemfile` (no extension) to your Arduino project:
13
13
14
14
```ruby
15
+
source 'https://rubygems.org'
15
16
gem 'arduino_ci'
16
17
```
17
18
18
-
And then execute:
19
+
Next, you need this in `.travis.yml`
19
20
20
-
$ bundle
21
+
```yaml
22
+
sudo: false
23
+
language: ruby
24
+
script:
25
+
- bundle install
26
+
- bundle exec arduino_ci_remote.rb
27
+
```
28
+
29
+
That's literally all there is to it on the repository side. You'll need to go to https://travis-ci.org/profile/ and enable testing for your Arduino project. Once that happens, you should be all set.
21
30
22
-
Or install it yourself as:
23
31
24
-
$ gem install arduino_ci
32
+
## More Documentation
25
33
34
+
This software is in alpha. But [SampleProjects/DoSomething](SampleProjects/DoSomething) has a decent writeup and is a good bare-bones example of all the features.
26
35
27
-
## Usage
36
+
## Known Problems
28
37
29
-
TODO: Write usage instructions here, based on other TODO of writing the actual gem.
38
+
* The Arduino library is not fully mocked.
39
+
* I don't have preprocessor defines for all the Arduino board flavors
40
+
* Arduino Zero boards don't work in CI. I'm confused.
# Arduino CI and Unit Tests HOWTO[](https://travis-ci.org/ifreecarve/arduino-ci-unit-tests)
1
+
# Arduino CI and Unit Tests HOWTO
2
2
3
3
This project is a template for a CI-enabled (and unit testable) Arduino project of your own.
4
4
@@ -7,17 +7,105 @@ This project is a template for a CI-enabled (and unit testable) Arduino project
7
7
8
8
* Travis CI
9
9
* Unit tests
10
-
* Development workflow matches CI workflow - the `platformio ci` line at the bottom of `.travis.yml` can be run on your local terminal (just append the name of the file you want to compile).
10
+
* Development workflow matches CI workflow
11
11
12
12
# Where The Magic Happens
13
13
14
14
Here is the minimal set of files that you will need to adapt to your own project:
15
15
16
-
*`.travis.yml` - You'll need to fill in the `env` section with files relevant to your project, and list out all the `--board`s under the `script` section.
17
-
*`platformio.ini` - You'll need to add information for any architectures you plan to support.
18
-
*`library.properties` - You'll need to update the `architectures` and `includes` lines as appropriate
16
+
17
+
### `Gemfile` Ruby gem configuration
18
+
19
+
```ruby
20
+
source 'https://rubygems.org'
21
+
gem 'arduino_ci'
22
+
```
23
+
24
+
You'll need this to get access to the functionality.
25
+
26
+
> This is different from the `Gemfile` that's included in this directory! That's for purposes of testing the ruby gem that also lives in this repository. So "do as I say, not as I do", in this case.
27
+
28
+
29
+
### `.travis.yml` Travis CI configuration
30
+
31
+
At a minimum, you will need the following lines in your file:
32
+
33
+
```yaml
34
+
language: ruby
35
+
script:
36
+
- bundle install
37
+
- bundle exec arduino_ci_remote.rb
38
+
```
39
+
40
+
This will install the necessary ruby gem, and run it. There are no command line arguments as of this writing, because all configuration is provided by...
41
+
42
+
### `.arduino-ci.yaml` ArduinoCI configuration
43
+
44
+
This file controls all aspects of building and unit testing. The (relatively-complete) defaults can be found [in the base project](../../misc/default.yaml).
45
+
46
+
The most relevant sections for most projects will be as follows:
47
+
48
+
```yaml
49
+
compile:
50
+
libraries: ~
51
+
platforms:
52
+
- uno
53
+
- due
54
+
- leonardo
55
+
56
+
unittest:
57
+
libraries: ~
58
+
platforms:
59
+
- uno
60
+
- due
61
+
- leonardo
62
+
```
63
+
64
+
This does nothing but specify a list of what platforms should run each set of tests. The platforms themselves can also be defined and/or extended in the yaml file. For example, `esp8266` as shown here:
65
+
66
+
```yaml
67
+
platforms:
68
+
esp8266:
69
+
board: esp8266:esp8266:huzzah
70
+
package: esp8266:esp8266
71
+
gcc:
72
+
features:
73
+
defines:
74
+
warnings:
75
+
flags:
76
+
```
77
+
78
+
Of course, this wouldn't work by itself -- the Arduino IDE would have to know how to install the package via the board manager. So there's a section for packages too:
All `.cpp` files in the `test/` directory are assumed to contain unit tests. Each and every one will be compiled and executed on its own.
89
+
90
+
The most basic unit test file is as follows:
91
+
92
+
```C++
93
+
#include <ArduinoUnitTests.h>
94
+
#include "../do-something.h"
95
+
96
+
unittest(your_test_name)
97
+
{
98
+
assertEqual(4, doSomething());
99
+
}
100
+
101
+
int main(int argc, char *argv[]) {
102
+
return Test::run_and_report(argc, argv);
103
+
}
104
+
```
105
+
106
+
This test defines one `unittest` (a macro provided by `ArduionUnitTests.h`), called `your_test_name`, which makes some assertions on the target library. The `int main` section is boilerplate.
19
107
20
108
21
109
# Credits
22
110
23
-
This Arduino example was created in January 2018 by Ian Katz <ianfixes@gmail.com>.
111
+
This Arduino example was created in January 2018 by Ian Katz <ifreecarve@gmail.com>.
This directory contains example projects that are meant to be built with this gem.
4
+
This directory contains example projects that are meant to be built with this gem. Except "TestSomething". That one's just a beater for CI testing and includes some tests that are designed to fail (to test negative inputs).
0 commit comments