diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml new file mode 100644 index 00000000..59185570 --- /dev/null +++ b/.github/workflows/linux.yaml @@ -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 diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml new file mode 100644 index 00000000..68d7ed3c --- /dev/null +++ b/.github/workflows/macos.yaml @@ -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 diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml new file mode 100644 index 00000000..4b65ff81 --- /dev/null +++ b/.github/workflows/windows.yaml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 36067457..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -sudo: false -language: ruby - -os: - - linux - - osx - -env: - - BADGE=linux - - BADGE=osx - -# hack to get some OS-specific badges -matrix: - exclude: - - os: linux - env: BADGE=osx - - os: osx - env: BADGE=linux - -#before_install: gem install bundler -v 1.15.4 -script: - - g++ -v - - bundle install - - bundle exec rubocop --version - - bundle exec rubocop -D . - - bundle exec rspec --backtrace - - cd SampleProjects/TestSomething - - bundle install - - bundle exec arduino_ci.rb - - cd ../NetworkLib - - cd scripts - - bash -x ./install.sh - - cd .. - - bundle install - - bundle exec arduino_ci.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 63ccb39f..563171de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` @@ -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 diff --git a/README.md b/README.md index c97ed550..fbc0a4ed 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. @@ -158,6 +181,7 @@ test_script: - bundle exec arduino_ci.rb ``` + ## Known Problems * The Arduino library is not fully mocked. diff --git a/SampleProjects/NetworkLib/scripts/install.sh b/SampleProjects/NetworkLib/scripts/install.sh index b4e2dd40..54b8d4e0 100644 --- a/SampleProjects/NetworkLib/scripts/install.sh +++ b/SampleProjects/NetworkLib/scripts/install.sh @@ -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 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index d8576b06..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -install: - - set PATH=C:\Ruby22\bin;C:\cygwin\bin;C:\cygwin64\bin;%PATH% - - bundle install - - '%CYG_ROOT%\setup-%CYG_ARCH%.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l %CYG_ROOT%/var/cache/setup -P autoconf -P automake -P bison -P libgmp-devel -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P gettext-devel -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl' - -environment: - matrix: - - CYG_ARCH: x86_64 - CYG_ROOT: C:/cygwin64 - -build: off - -before_test: - - ruby -v - - gem -v - - bundle -v - - g++ -v - -test_script: - # https://help.appveyor.com/discussions/problems/5170-progresspreference-not-works-always-shown-preparing-modules-for-first-use-in-stderr - - ps: $ProgressPreference = "SilentlyContinue" - - bundle exec rubocop --version - - bundle exec rubocop -D . - - bundle exec rspec --backtrace - - cd SampleProjects\TestSomething - - bundle install - - bundle exec arduino_ci.rb - - cd ../NetworkLib - - cd scripts - - install.sh - - cd .. - - bundle install - - bundle exec arduino_ci.rb diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index bb8dcfb1..c07faf8c 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -310,21 +310,14 @@ 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 @@ -332,7 +325,7 @@ def perform_example_compilation_tests(cpp_library, config) end end - external_packages.each do |p| + all_packages.each do |p| assure("Installing board package #{p}") do @backend.install_boards(p) end diff --git a/lib/arduino_ci/ci_config.rb b/lib/arduino_ci/ci_config.rb index 5f77b7bd..315f770b 100644 --- a/lib/arduino_ci/ci_config.rb +++ b/lib/arduino_ci/ci_config.rb @@ -232,13 +232,6 @@ def platform_definition(platform_name) deep_clone(defn) end - # Whether a package is built-in to arduino - # @param package [String] the package name (e.g. "arduino:avr") - # @return [bool] - def package_builtin?(package) - package.start_with?("arduino:") - end - # the URL that gives the download info for a given package (a JSON file). # this is NOT where the package comes from. # @param package [String] the package name (e.g. "arduino:avr") diff --git a/misc/default.yml b/misc/default.yml index 1bef2e27..4d621a79 100644 --- a/misc/default.yml +++ b/misc/default.yml @@ -3,8 +3,12 @@ # https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems packages: - # arduino:xxx are builtin, we don't need to include them here - # but if we did, it would be url: https://downloads.arduino.cc/packages/package_index.json + arduino:avr: + url: https://downloads.arduino.cc/packages/package_index.json + arduino:sam: + url: https://downloads.arduino.cc/packages/package_index.json + arduino:samd: + url: https://downloads.arduino.cc/packages/package_index.json esp8266:esp8266: url: http://arduino.esp8266.com/stable/package_esp8266com_index.json adafruit:avr: diff --git a/spec/ci_config_spec.rb b/spec/ci_config_spec.rb index 8ae3431a..a0d53bde 100644 --- a/spec/ci_config_spec.rb +++ b/spec/ci_config_spec.rb @@ -27,9 +27,6 @@ expect(zero[:package]).to eq("arduino:samd") expect(zero[:gcc].class).to eq(Hash) - expect(default_config.package_builtin?("arduino:avr")).to be true - expect(default_config.package_builtin?("adafruit:avr")).to be false - expect(default_config.package_url("adafruit:avr")).to eq("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json") expect(default_config.package_url("adafruit:samd")).to eq("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json") expect(default_config.package_url("esp32:esp32")).to eq("https://dl.espressif.com/dl/package_esp32_index.json")