Skip to content

Commit 09a3eaf

Browse files
authored
Merge pull request #226 from Arduino-CI/tdd
Fix and merge Test Driven Development branch
2 parents 1acd09b + 1b95f4c commit 09a3eaf

File tree

12 files changed

+249
-95
lines changed

12 files changed

+249
-95
lines changed

.github/workflows/linux.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This is the name of the workflow, visible on GitHub UI
2+
name: linux
3+
4+
# Run on a Push or a Pull Request
5+
on: [push, pull_request]
6+
7+
jobs:
8+
rspec:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
16+
# Install and run Arduino CI tests for rspec
17+
- name: Build and Execute
18+
run: |
19+
g++ -v
20+
bundle install
21+
bundle exec rspec --backtrace
22+
23+
rubocop:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: 2.6
30+
31+
# Install and run Arduino CI tests for rubocop
32+
- name: Build and Execute
33+
run: |
34+
bundle install
35+
bundle exec rubocop --version
36+
bundle exec rubocop -D .
37+
38+
TestSomething:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: 2.6
45+
46+
# Install and run Arduino CI tests for TestSomething
47+
- name: Build and Execute
48+
run: |
49+
g++ -v
50+
cd SampleProjects/TestSomething
51+
bundle install
52+
bundle exec arduino_ci.rb
53+
54+
NetworkLib:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- uses: ruby/setup-ruby@v1
59+
with:
60+
ruby-version: 2.6
61+
62+
# Install and run Arduino CI tests for NetworkLib
63+
- name: Build and Execute
64+
run: |
65+
g++ -v
66+
cd SampleProjects/NetworkLib
67+
sh ./scripts/install.sh
68+
bundle install
69+
bundle exec arduino_ci.rb

.github/workflows/macos.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This is the name of the workflow, visible on GitHub UI
2+
name: macos
3+
4+
# Run on a Push or a Pull Request
5+
on: [push, pull_request]
6+
7+
jobs:
8+
rspec:
9+
runs-on: macos-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
16+
# Install and run Arduino CI tests for rspec
17+
- name: Build and Execute
18+
run: |
19+
g++ -v
20+
bundle install
21+
bundle exec rspec --backtrace
22+
23+
rubocop:
24+
runs-on: macos-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: 2.6
30+
31+
# Install and run Arduino CI tests for rubocop
32+
- name: Build and Execute
33+
run: |
34+
bundle install
35+
bundle exec rubocop --version
36+
bundle exec rubocop -D .
37+
38+
TestSomething:
39+
runs-on: macos-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: 2.6
45+
46+
# Install and run Arduino CI tests for TestSomething
47+
- name: Build and Execute
48+
run: |
49+
g++ -v
50+
cd SampleProjects/TestSomething
51+
bundle install
52+
bundle exec arduino_ci.rb
53+
54+
NetworkLib:
55+
runs-on: macos-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- uses: ruby/setup-ruby@v1
59+
with:
60+
ruby-version: 2.6
61+
62+
# Install and run Arduino CI tests for NetworkLib
63+
- name: Build and Execute
64+
run: |
65+
g++ -v
66+
cd SampleProjects/NetworkLib
67+
sh ./scripts/install.sh
68+
bundle install
69+
bundle exec arduino_ci.rb

.github/workflows/windows.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This is the name of the workflow, visible on GitHub UI
2+
name: windows
3+
4+
# Run on a Push or a Pull Request
5+
on: [push, pull_request]
6+
7+
jobs:
8+
rspec:
9+
runs-on: windows-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
16+
# Install and run Arduino CI tests for rspec
17+
- name: Build and Execute
18+
run: |
19+
g++ -v
20+
bundle install
21+
bundle exec rspec --backtrace
22+
23+
rubocop:
24+
runs-on: windows-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: 2.6
30+
31+
# Install and run Arduino CI tests for rubocop
32+
- name: Build and Execute
33+
run: |
34+
bundle install
35+
bundle exec rubocop --version
36+
bundle exec rubocop -D .
37+
38+
TestSomething:
39+
runs-on: windows-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: 2.6
45+
46+
# Install and run Arduino CI tests for TestSomething
47+
- name: Build and Execute
48+
run: |
49+
g++ -v
50+
cd SampleProjects/TestSomething
51+
bundle install
52+
bundle exec arduino_ci.rb
53+
54+
NetworkLib:
55+
runs-on: windows-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- uses: ruby/setup-ruby@v1
59+
with:
60+
ruby-version: 2.6
61+
62+
# Install and run Arduino CI tests for Network
63+
- name: Build and Execute
64+
run: |
65+
g++ -v
66+
cd SampleProjects/NetworkLib
67+
bash -x ./scripts/install.sh
68+
bundle install
69+
bundle exec arduino_ci.rb

.travis.yml

-35
This file was deleted.

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Code coverage tooling
1313
- Explicit check and warning for library directory names that do not match our guess of what the library should/would be called
1414
- Symlink tests for `Host`
15+
- Add documentation on how to use Arduino CI with GitHub Actions
16+
- Allow tests to run on GitHub without external set up, via GitHub Actions (Windows, Linux, MacOS)
1517

1618
### Changed
1719
- Arduino backend is now `arduino-cli` version `0.13.0`
@@ -28,6 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2830

2931
### Removed
3032
- `ARDUINO_CI_SKIP_SPLASH_SCREEN_RSPEC_TESTS` no longer affects any tests because there are no longer splash screens since switching to `arduino-cli`
33+
- `CIConfig.package_builtin?` as this is no longer relevant to the `arduino-cli` backend (which has no built-in packages)
34+
- Travis and Appveyor CI
3135

3236
### Fixed
3337
- Mismatches between library names in `library.properties` and the directory names, which can cause cryptic failures

README.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ You want to precisely replicate certain software states in your library, but you
1010

1111
You want your Arduino library to be automatically built and tested every time someone contributes code to your project on GitHub, but the Arduino IDE lacks the ability to run unit tests. [Arduino CI](https://github.com/Arduino-CI/arduino_ci) provides that ability.
1212

13-
`arduino_ci` is a cross-platform build/test system, consisting of a Ruby gem and a series of C++ mocks. It enables tests to be run both locally and as part of a CI service like Travis or Appveyor. Any OS that can run the Arduino IDE can run `arduino_ci`.
13+
`arduino_ci` is a cross-platform build/test system, consisting of a Ruby gem and a series of C++ mocks. It enables tests to be run both locally and as part of a CI service like GitHub Actions, TravisCI, Appveyor, etc. Any OS that can run the Arduino IDE can run `arduino_ci`.
14+
1415

1516
Platform | CI Status
1617
---------|:---------
17-
OSX | [![OSX Build Status](http://badges.herokuapp.com/travis/Arduino-CI/arduino_ci?env=BADGE=osx&label=build&branch=master)](https://travis-ci.org/Arduino-CI/arduino_ci)
18-
Linux | [![Linux Build Status](http://badges.herokuapp.com/travis/Arduino-CI/arduino_ci?env=BADGE=linux&label=build&branch=master)](https://travis-ci.org/Arduino-CI/arduino_ci)
19-
Windows | [![Windows Build status](https://ci.appveyor.com/api/projects/status/abynv8xd75m26qo9/branch/master?svg=true)](https://ci.appveyor.com/project/ianfixes/arduino-ci)
18+
OSX | [![OSX Build Status](https://github.com/Arduino-CI/arduino_ci/workflows/macos/badge.svg)](https://github.com/Arduino-CI/arduino_ci/actions?workflow=macos)
19+
Linux | [![Linux Build Status](https://github.com/Arduino-CI/arduino_ci/workflows/linux/badge.svg)](https://github.com/Arduino-CI/arduino_ci/actions?workflow=linux)
20+
Windows | [![Windows Build status](https://github.com/Arduino-CI/arduino_ci/workflows/windows/badge.svg)](https://github.com/Arduino-CI/arduino_ci/actions?workflow=windows)
2021

2122

2223
## Comparison to Other Arduino Testing Tools
@@ -130,6 +131,28 @@ The following prerequisites must be fulfilled:
130131
> **Note:** `arduino_ci.rb` expects to be run from the root directory of your Arduino project library.
131132
132133

134+
#### GitHub Actions
135+
136+
GitHub Actions allows you to automate your workflows directly in GitHub.
137+
No additional steps are needed.
138+
Just create a YAML file with the information below in your repo under the `.github/workflows/` directory.
139+
140+
```yaml
141+
on: [push, pull_request]
142+
jobs:
143+
runTest:
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v2
147+
- uses: ruby/setup-ruby@v1
148+
with:
149+
ruby-version: 2.6
150+
- run: |
151+
bundle install
152+
bundle exec arduino_ci_remote.rb
153+
```
154+
155+
133156
#### Travis CI
134157
135158
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.
@@ -158,6 +181,7 @@ test_script:
158181
- bundle exec arduino_ci.rb
159182
```
160183

184+
161185
## Known Problems
162186

163187
* The Arduino library is not fully mocked.

SampleProjects/NetworkLib/scripts/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# then get the custom one we want to use for testing
55
cd $(bundle exec arduino_library_location.rb)
66
if [ ! -d ./Ethernet ] ; then
7-
git clone https://github.com/Arduino-CI/Ethernet.git
7+
git clone --depth 1 https://github.com/Arduino-CI/Ethernet.git
88
fi

appveyor.yml

-33
This file was deleted.

exe/arduino_ci.rb

+3-10
Original file line numberDiff line numberDiff line change
@@ -310,29 +310,22 @@ def perform_example_compilation_tests(cpp_library, config)
310310
# do that, set the URLs, and download the packages
311311
all_packages = example_platform_info.values.map { |v| v[:package] }.uniq.reject(&:nil?)
312312

313-
builtin_packages, external_packages = all_packages.partition { |p| config.package_builtin?(p) }
314-
315-
# inform about builtin packages
316-
builtin_packages.each do |p|
317-
inform("Using built-in board package") { p }
318-
end
319-
320313
# make sure any non-builtin package has a URL defined
321-
external_packages.each do |p|
314+
all_packages.each do |p|
322315
assure("Board package #{p} has a defined URL") { board_package_url[p] }
323316
end
324317

325318
# set up all the board manager URLs.
326319
# we can safely reject nils now, they would be for the builtins
327-
all_urls = external_packages.map { |p| board_package_url[p] }.uniq.reject(&:nil?)
320+
all_urls = all_packages.map { |p| board_package_url[p] }.uniq.reject(&:nil?)
328321

329322
unless all_urls.empty?
330323
assure("Setting board manager URLs") do
331324
@backend.board_manager_urls = all_urls
332325
end
333326
end
334327

335-
external_packages.each do |p|
328+
all_packages.each do |p|
336329
assure("Installing board package #{p}") do
337330
@backend.install_boards(p)
338331
end

0 commit comments

Comments
 (0)