Skip to content

Commit e4edb95

Browse files
authored
Merge pull request #267 from ianfixes/2021-01-07_beta
Beta test branch for next release
2 parents e27b9c4 + 2e8e770 commit e4edb95

File tree

9 files changed

+134
-107
lines changed

9 files changed

+134
-107
lines changed

.github/workflows/linux.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
run: |
3434
g++ -v
3535
cd SampleProjects/NetworkLib
36-
sh ./scripts/install.sh
3736
bundle install
37+
bundle exec ensure_arduino_installation.rb
38+
sh ./scripts/install.sh
3839
bundle exec arduino_ci.rb

.github/workflows/macos.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
run: |
3434
g++ -v
3535
cd SampleProjects/NetworkLib
36-
sh ./scripts/install.sh
3736
bundle install
37+
bundle exec ensure_arduino_installation.rb
38+
sh ./scripts/install.sh
3839
bundle exec arduino_ci.rb

.github/workflows/windows.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
run: |
3434
g++ -v
3535
cd SampleProjects/NetworkLib
36-
bash -x ./scripts/install.sh
3736
bundle install
37+
bundle exec ensure_arduino_installation.rb
38+
bash -x ./scripts/install.sh
3839
bundle exec arduino_ci.rb

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Added
10+
- Better indications of the build phases in the test runner `arduino_ci.rb`
11+
- Better indications of which example sketch is being compiled as part of testing
1012

1113
### Changed
14+
- Topmost installtion instructions now suggest `gem install arduino_ci` instead of using a `Gemfile`. Reasons for using a `Gemfile` are listed and discussed separately further down the README.
1215

1316
### Deprecated
1417

1518
### Removed
19+
- scanning of `library.properties`; this can and should now be performed by the standalone [`arduino-lint` tool](https://arduino.github.io/arduino-lint).
1620

1721
### Fixed
22+
- Example sketches with no configured platforms were printing the wrong configuration values to the debug message
23+
- Libraries directory was not being automatically created prior to attempting to change directory into it
24+
- A style error whose "fix" caused an _actual_ error.
25+
- Proper installation order for NetworkLib in CI workflow configuration
1826

1927
### Security
2028

README.md

+74-55
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Arduino CI was created to enable better collaboration among Arduino library maintainers and contributors, by enabling automated code checks to be performed as part of a pull request process.
99

1010
* enables running unit tests against the library **without hardware present**
11-
* provides a system of mocks that allow fine-grained control over the hardare inputs, including the system's clock
11+
* provides a system of mocks that allow fine-grained control over the hardware inputs, including the system's clock
1212
* verifies compilation of any example sketches included in the library
1313
* can test a wide range of arduino boards with different hardware options available
1414
* compares entries in `library.properties` to the contents of the library and reports mismatches
@@ -29,69 +29,91 @@ Windows | [![Windows Build status](https://github.com/Arduino-CI/arduino_ci/wor
2929

3030
## Quick Start
3131

32-
### You Need Your Arduino Library
32+
This project has the following dependencies:
3333

34-
For a fairly minimal practical example of a unit-testable library repo that you can copy from, see [the `Arduino-CI/Blink` repository](https://github.com/Arduino-CI/Blink).
34+
* `ruby` 2.5 or higher
35+
* A compiler like `g++` (on OSX, `clang` works; on Cygwin, use the `mingw-gcc-c++` package)
36+
* `python` (if using a board architecutre that requires it, e.g. ESP32, ESP8266; see [this issue](https://github.com/Arduino-CI/arduino_ci/issues/235#issuecomment-739629243)). Consider `pyserial` as well.
37+
38+
In that environment, you can install by running `gem install arduino_ci`. To update to a latest version, use `gem update arduino_ci`.
39+
40+
You can now test your library by simply running the command `arduino_ci.rb` from your library directory. This will perform the following:
3541

36-
> Note: The `SampleProjects` directory you see within _this_ repo contains tests for validing the `arduino_ci` framework itself, and due to that coupling will not be helpful to duplicate. That said, the [SampleProjects/TestSomething](SampleProjects/TestSomething) project contains [test files](SampleProjects/TestSomething/test/) (each named after the type of feature being tested) that may be illustrative of testing strategy and capabilities _on an individual basis_.
42+
* validation of some fields in `library.properties`, if it exists
43+
* running unit tests from files found in `test/`, if they exist
44+
* testing compilation of example sketches found in `examples/`, if they exist
45+
46+
### Assumptions About Your Repository
3747

3848
Arduino expects all libraries to be in a specific `Arduino/libraries` directory on your system. If your library is elsewhere, `arduino_ci` will _automatically_ create a symbolic link in the `libraries` directory that points to the directory of the project being tested. This simplifieds working with project dependencies, but **it can have unintended consequences on Windows systems**.
3949

4050
> If you use a Windows system **it is recommended that you only run `arduino_ci` from project directories that are already inside the `libraries` directory** because [in some cases deleting a folder that contains a symbolic link to another folder can cause the _entire linked folder_ to be removed instead of just the link itself](https://superuser.com/a/306618).
4151
52+
### Changes to Your Repository
4253

43-
### You Need Ruby and Bundler
44-
45-
You'll need Ruby version 2.5 or higher, and to `gem install bundler` if it's not already there.
54+
Unit testing binaries created by `arduino_ci` should not be commited to the codebase. To avoid that, add the following to your `.gitignore`:
4655

56+
```ignore-list
57+
# arduino_ci unit test binaries and artifacts
58+
*.bin
59+
*.bin.dSYM
60+
```
4761

48-
### You Need A Compiler (`g++`)
62+
### A Quick Example
4963

50-
For unit testing, you will need a compiler; [g++](https://gcc.gnu.org/) is preferred.
64+
For a fairly minimal practical example of a unit-testable library repo that you can copy from, see [the `Arduino-CI/Blink` repository](https://github.com/Arduino-CI/Blink).
5165

52-
* **Linux**: `gcc`/`g++` is likely pre-installed.
53-
* **OSX**: `g++` is an alias for `clang`, which is provided by Xcode and the developer tools. You are free to `brew install gcc` as well; this is also tested and working.
54-
* **Windows**: you will need Cygwin, and the `mingw-gcc-g++` package.
5566

67+
## Advanced Start
5668

57-
### You _May_ Need `python`
69+
New features and bugfixes reach GitHub before they reach a released ruby gem. Alternately, it may be that (for your own reasons) you do not wish to install `arduino_ci` globally on your system. A few additional setup steps are required if you wish to do this.
5870

59-
ESP32 and ESP8266 boards have [a dependency on `python` that they don't install themselves](https://github.com/Arduino-CI/arduino_ci/issues/235#issuecomment-739629243). If you intend to test on these platforms (which are included in the default list of platforms to test against), you will need to make `python` (and possibly `pyserial`) available in the test environment.
71+
### You Need Ruby _and_ Bundler
6072

61-
Alternately, you might configure `arduino_ci` to simply not test against these. Consult the reference for those details.
73+
In addition to version 2.5 or higher, you'll also need to `gem install bundler` to a minimum of version 2.0 if it's not already there. You may find it easiest to do this by using [`rbenv`](https://github.com/rbenv/rbenv).
6274

75+
You will need to add a file called `Gemfile` (no extension) to your Arduino project.
6376

64-
### Changes to Your Repo
77+
#### Non-root installation
6578

66-
Add a file called `Gemfile` (no extension) to your Arduino project:
79+
If you are simply trying to avoid the need to install `arduino_ci` system-wide (which may require administrator permissions), your `Gemfile` would look like this:
6780

6881
```ruby
6982
source 'https://rubygems.org'
70-
gem 'arduino_ci' '~> 1.1'
83+
84+
# Replace 1.2 with the desired version of arduino_ci. See https://guides.rubygems.org/patterns/#pessimistic-version-constraint
85+
gem 'arduino_ci', '~> 1.2'
7186
```
7287

73-
At the time of this writing, `1.1` is the latest version available, and the `~>` syntax will allow your system to update it to the latest `1.x.x` version. The list of all available versions can be found on [rubygems.org](https://rubygems.org/gems/arduino_ci) if you prefer to explicitly pin a higher version.
88+
It would also make sense to add the following to your `.gitignore`:
89+
```ignore-list
90+
/.bundle/
91+
vendor
92+
```
93+
94+
> Note: this used to be the recommended installation method, but with the library's maturation it's better to avoid the use of `Gemfile` and `bundle install` by just installing as per the "Quick Start" instructions above.
95+
7496

75-
It would also make sense to add the following to your `.gitignore`, or copy [the `.gitignore` used by this project](.gitignore):
97+
#### Using the latest-available code
98+
99+
If you want to use the latest code on GitHub, your `Gemfile` would look like this:
100+
101+
```ruby
102+
source 'https://rubygems.org'
76103

104+
# to use the latest github code in a given repo and branch, replace the below values for git: and ref: as needed
105+
gem 'arduino_ci', git: 'https://github.com/ArduinoCI/arduino_ci.git', ref: '<your desired ref, branch, or tag>'
77106
```
78-
/.bundle/
79-
/.yardoc
80-
Gemfile.lock
81-
/_yardoc/
82-
/coverage/
83-
/doc/
84-
/pkg/
85-
/spec/reports/
86-
vendor
87-
*.gem
88107

89-
# rspec failure tracking
90-
.rspec_status
91108

92-
# C++ stuff
93-
*.bin
94-
*.bin.dSYM
109+
#### Using a version of `arduino_ci` source code on your local machine
110+
111+
First, Thanks! See [CONTRIBUTING.md](CONTRIBUTING.md). Your `Gemfile` would look like this:
112+
113+
```ruby
114+
source 'https://rubygems.org'
115+
116+
gem 'arduino_ci', path: '/path/to/development/dir/for/arduino_ci'
95117
```
96118

97119

@@ -103,17 +125,18 @@ $ bundle install # adds packages to global library (may require admin rights)
103125
$ bundle install --path vendor/bundle # adds packages to local library
104126
```
105127

128+
This will create a `Gemfile.lock` in your project directory, which you may optionally check into source control. A broader introduction to ruby dependencies is outside the scope of this document.
106129

107-
### Running tests
130+
131+
132+
### Running `arduino_ci.rb` To Test Your Library
108133

109134
With that installed, just the following shell command each time you want the tests to execute:
110135

111-
```
136+
```console
112137
$ bundle exec arduino_ci.rb
113138
```
114139

115-
`arduino_ci.rb` is the main entry point for this library. This command will iterate over all the library's `examples/` and attempt to compile them. If you set up unit tests, it will run those as well.
116-
117140

118141
### Reference
119142

@@ -128,18 +151,14 @@ For more information on the usage of `arduino_ci.rb`, see [REFERENCE.md](REFEREN
128151

129152
## Setting up Pull Request Testing and/or External CI
130153

131-
The following prerequisites must be fulfilled:
132-
133-
* A GitHub (or other repository-hosting) project for your library
134-
* A CI system like [Travis CI](https://travis-ci.org/) or [Appveyor](https://www.appveyor.com/) that is linked to your project
135-
154+
> **Note:** `arduino_ci.rb` expects to be run from the root directory of your Arduino project library.
136155
137-
### Testing with remote CI
156+
### Arduino CI's Own GitHub action
138157

139-
> **Note:** `arduino_ci.rb` expects to be run from the root directory of your Arduino project library.
158+
[![GitHub Marketplace](https://img.shields.io/badge/Get_it-on_Marketplace-informational.svg)](https://github.com/marketplace/actions/arduino_ci)
140159

141160

142-
#### GitHub Actions
161+
### Your Own Scripted GitHub Action
143162

144163
GitHub Actions allows you to automate your workflows directly in GitHub.
145164
No additional steps are needed.
@@ -156,12 +175,12 @@ jobs:
156175
with:
157176
ruby-version: 2.6
158177
- run: |
159-
bundle install
160-
bundle exec arduino_ci_remote.rb
178+
gem install arduino_ci
179+
arduino_ci.rb
161180
```
162181
163182
164-
#### Travis CI
183+
### Travis CI
165184
166185
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. The script will test all example projects of the library and all unit tests.
167186
@@ -171,12 +190,12 @@ Next, you need this in `.travis.yml` in your repo
171190
sudo: false
172191
language: ruby
173192
script:
174-
- bundle install
175-
- bundle exec arduino_ci.rb
193+
- gem install arduino_ci
194+
- arduino_ci.rb
176195
```
177196

178197

179-
#### Appveyor CI
198+
### Appveyor CI
180199

181200
You'll need to go to https://ci.appveyor.com/projects and add your project.
182201

@@ -185,8 +204,8 @@ Next, you'll need this in `appveyor.yml` in your repo.
185204
```yaml
186205
build: off
187206
test_script:
188-
- bundle install
189-
- bundle exec arduino_ci.rb
207+
- gem install arduino_ci
208+
- arduino_ci.rb
190209
```
191210

192211

REFERENCE.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This allows a file (or glob) pattern to be executed in your tests directory, cre
4646

4747
### `CUSTOM_INIT_SCRIPT` environment variable
4848

49-
If set, testing will execute (using `/bin/sh`) the script referred to by this variable -- relative to the current working directory. This enables use cases like the GitHub action to install custom library versions (i.e. a version of a library that is different than what the library manager would automatically install by name) prior to CI test runs.
49+
If set, testing will execute (using `/bin/sh`) the script referred to by this variable -- relative to the current working directory (i.e. the root directory of the library). The script will _run_ in the Arduino Libraries directory (changing to the Libraries directory, running the script, and returning to the individual library root afterward). This enables use cases like the GitHub action to install custom library versions (i.e. a version of a library that is different than what the library manager would automatically install by name) prior to CI test runs.
5050

5151

5252
### `USE_SUBDIR` environment variable
@@ -64,11 +64,6 @@ If set, testing will fail if no unit test files are detected (or if the director
6464
If set, testing will fail if no example sketches are detected. This is to avoid communicating a passing status in cases where a commit may have accidentally moved or deleted the examples.
6565

6666

67-
### `SKIP_LIBRARY_PROPERTIES` environment variable
68-
69-
If set, testing will skip validating `library.properties` entries. This is to work around any possible bugs in `arduino_ci`'s interpretation of what is "correct".
70-
71-
7267
## Indirectly Overriding Build Behavior (medium term use), and Advanced Options
7368

7469
For build behavior that you'd like to persist across commits (e.g. defining the set of platforms to test against, disabling a test that you expect to re-enable at some future point), a special configuration file called `.arduino-ci.yml` can be used. There are 3 places you can put them:

SampleProjects/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
Arduino Sample Projects
22
=======================
33

4-
This directory contains projects that are intended solely for testing the various features of this gem -- to test the testing framework itself. The RSpec tests refer specifically to these projects.
5-
6-
Because of this, these projects include some intentional quirks that differ from what a well-formed an Arduino project for testing with `arduino_ci` might contain. See other projects in the "Arduino-CI" GitHub organization for practical examples.
4+
This directory contains projects that are intended solely for testing the various features of this gem -- to test the testing framework itself. The RSpec tests refer specifically to these projects, and as a result _some are explicity designed to fail_.
75

6+
> **If you are a first-time `arduino_ci` user an are looking for an example to copy from, see [the `Arduino-CI/Blink` repository](https://github.com/Arduino-CI/Blink) instead.**
87
98
* "TestSomething" contains a minimial library, but tests for all the C++ compilation feature-mocks of arduino_ci.
109
* "DoSomething" is a simple test of the testing framework (arduino_ci) itself to verfy that passes and failures are properly identified and reported. Because of this, it includes test files that are expected to fail -- they are prefixed with "bad-".
@@ -13,3 +12,4 @@ Because of this, these projects include some intentional quirks that differ from
1312
* "OnePointFiveDummy" is a non-functional library meant to test file inclusion logic on libraries conforming to the ["1.5" specfication](https://arduino.github.io/arduino-cli/latest/library-specification/)
1413
* "DependOnSomething" is a non-functional library meant to test file inclusion logic with dependencies
1514
* "ExcludeSomething" is a non-functional library meant to test directory exclusion logic
15+
* "NetworkLib" tests the Ethernet library
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# TestSomething
22

3-
This is a "beater" example that is referenced by tests of the Arduino CI module itself.
43

54
All the tests of our mocked `Arduino.h` implementation live here.
5+
6+
This example project is tightly coupled to the tests of the Arduino CI module itself. In that sense, each of the individual test files will be illustrative of the testing strategy and capabilities of the core library itself.

0 commit comments

Comments
 (0)