Skip to content

Fix and merge Test Driven Development branch #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is the name of the workflow, visible on GitHub UI
name: linux

# Run on a Push or a Pull Request
on: [push, pull_request]

jobs:
rspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rspec
- name: Build and Execute
run: |
g++ -v
bundle install
bundle exec rspec --backtrace

rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rubocop
- name: Build and Execute
run: |
bundle install
bundle exec rubocop --version
bundle exec rubocop -D .

TestSomething:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for TestSomething
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/TestSomething
bundle install
bundle exec arduino_ci.rb

NetworkLib:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for NetworkLib
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/NetworkLib
sh ./scripts/install.sh
bundle install
bundle exec arduino_ci.rb
69 changes: 69 additions & 0 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is the name of the workflow, visible on GitHub UI
name: macos

# Run on a Push or a Pull Request
on: [push, pull_request]

jobs:
rspec:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rspec
- name: Build and Execute
run: |
g++ -v
bundle install
bundle exec rspec --backtrace

rubocop:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rubocop
- name: Build and Execute
run: |
bundle install
bundle exec rubocop --version
bundle exec rubocop -D .

TestSomething:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for TestSomething
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/TestSomething
bundle install
bundle exec arduino_ci.rb

NetworkLib:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for NetworkLib
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/NetworkLib
sh ./scripts/install.sh
bundle install
bundle exec arduino_ci.rb
69 changes: 69 additions & 0 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is the name of the workflow, visible on GitHub UI
name: windows

# Run on a Push or a Pull Request
on: [push, pull_request]

jobs:
rspec:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rspec
- name: Build and Execute
run: |
g++ -v
bundle install
bundle exec rspec --backtrace

rubocop:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for rubocop
- name: Build and Execute
run: |
bundle install
bundle exec rubocop --version
bundle exec rubocop -D .

TestSomething:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for TestSomething
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/TestSomething
bundle install
bundle exec arduino_ci.rb

NetworkLib:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

# Install and run Arduino CI tests for Network
- name: Build and Execute
run: |
g++ -v
cd SampleProjects/NetworkLib
bash -x ./scripts/install.sh
bundle install
bundle exec arduino_ci.rb
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

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

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

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

### Fixed
- Mismatches between library names in `library.properties` and the directory names, which can cause cryptic failures
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ You want to precisely replicate certain software states in your library, but you

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.

`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`.
`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`.


Platform | CI Status
---------|:---------
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)
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)
Windows | [![Windows Build status](https://ci.appveyor.com/api/projects/status/abynv8xd75m26qo9/branch/master?svg=true)](https://ci.appveyor.com/project/ianfixes/arduino-ci)
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)
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)
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)


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


#### GitHub Actions

GitHub Actions allows you to automate your workflows directly in GitHub.
No additional steps are needed.
Just create a YAML file with the information below in your repo under the `.github/workflows/` directory.

```yaml
on: [push, pull_request]
jobs:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
bundle install
bundle exec arduino_ci_remote.rb
```


#### Travis CI

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.
Expand Down Expand Up @@ -158,6 +181,7 @@ test_script:
- bundle exec arduino_ci.rb
```


## Known Problems

* The Arduino library is not fully mocked.
Expand Down
2 changes: 1 addition & 1 deletion SampleProjects/NetworkLib/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# then get the custom one we want to use for testing
cd $(bundle exec arduino_library_location.rb)
if [ ! -d ./Ethernet ] ; then
git clone https://github.com/Arduino-CI/Ethernet.git
git clone --depth 1 https://github.com/Arduino-CI/Ethernet.git
fi
33 changes: 0 additions & 33 deletions appveyor.yml

This file was deleted.

13 changes: 3 additions & 10 deletions exe/arduino_ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,29 +310,22 @@ def perform_example_compilation_tests(cpp_library, config)
# do that, set the URLs, and download the packages
all_packages = example_platform_info.values.map { |v| v[:package] }.uniq.reject(&:nil?)

builtin_packages, external_packages = all_packages.partition { |p| config.package_builtin?(p) }

# inform about builtin packages
builtin_packages.each do |p|
inform("Using built-in board package") { p }
end

# make sure any non-builtin package has a URL defined
external_packages.each do |p|
all_packages.each do |p|
assure("Board package #{p} has a defined URL") { board_package_url[p] }
end

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

unless all_urls.empty?
assure("Setting board manager URLs") do
@backend.board_manager_urls = all_urls
end
end

external_packages.each do |p|
all_packages.each do |p|
assure("Installing board package #{p}") do
@backend.install_boards(p)
end
Expand Down
Loading