diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index ea424ebe..a095c5b2 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -61,3 +61,13 @@ jobs: bundle exec ensure_arduino_installation.rb sh ./scripts/install.sh bundle exec arduino_ci.rb + + SharedLibrary: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Test SharedLibrary should fail + run: ./SampleProjects/SharedLibrary/test.sh diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 8b51fd60..5019f96f 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -61,3 +61,13 @@ jobs: bundle exec ensure_arduino_installation.rb sh ./scripts/install.sh bundle exec arduino_ci.rb + + SharedLibrary: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Test SharedLibrary should fail + run: ./SampleProjects/SharedLibrary/test.sh diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 3a40eed3..3169ea44 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -50,3 +50,13 @@ jobs: bundle exec ensure_arduino_installation.rb bash -x ./scripts/install.sh bundle exec arduino_ci.rb + + SharedLibrary: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Test SharedLibrary should fail + run: ./SampleProjects/SharedLibrary/test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 51216f91..16ee831b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix copy/paste error to allow additional warnings for a platform - Apply "rule of three" to Client copy constructor and copy assignment operator - Run Windows tests on Windows not Ubuntu +- Properly report error in building shared library ### Security diff --git a/SampleProjects/SharedLibrary/.arduino-ci.yml b/SampleProjects/SharedLibrary/.arduino-ci.yml new file mode 100644 index 00000000..f63d2413 --- /dev/null +++ b/SampleProjects/SharedLibrary/.arduino-ci.yml @@ -0,0 +1,7 @@ +unittest: + platforms: + - mega2560 + +compile: + platforms: + - mega2560 diff --git a/SampleProjects/SharedLibrary/.gitignore b/SampleProjects/SharedLibrary/.gitignore new file mode 100644 index 00000000..06de90aa --- /dev/null +++ b/SampleProjects/SharedLibrary/.gitignore @@ -0,0 +1 @@ +.bundle \ No newline at end of file diff --git a/SampleProjects/SharedLibrary/Gemfile b/SampleProjects/SharedLibrary/Gemfile new file mode 100644 index 00000000..b2b3b1fd --- /dev/null +++ b/SampleProjects/SharedLibrary/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'arduino_ci', path: '../../' diff --git a/SampleProjects/SharedLibrary/README.md b/SampleProjects/SharedLibrary/README.md new file mode 100644 index 00000000..40e8645c --- /dev/null +++ b/SampleProjects/SharedLibrary/README.md @@ -0,0 +1,3 @@ +# SharedLibrary + +This is an example of a shared library with a compile error (see https://github.com/Arduino-CI/arduino_ci/issues/325). diff --git a/SampleProjects/SharedLibrary/library.properties b/SampleProjects/SharedLibrary/library.properties new file mode 100644 index 00000000..5f9d3662 --- /dev/null +++ b/SampleProjects/SharedLibrary/library.properties @@ -0,0 +1,10 @@ +name=SharedLibrary +version=0.1.0 +author=James Foster +maintainer=James Foster +sentence=Sample shared library to validate that we catch compile errors +paragraph=Sample shared library to validate that we catch compile errors +category=Other +url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/SharedLibrary +architectures=avr,esp8266 +includes=SharedLibrary.h diff --git a/SampleProjects/SharedLibrary/src/SharedLibrary.cpp b/SampleProjects/SharedLibrary/src/SharedLibrary.cpp new file mode 100644 index 00000000..347aaf17 --- /dev/null +++ b/SampleProjects/SharedLibrary/src/SharedLibrary.cpp @@ -0,0 +1,5 @@ +#include "SharedLibrary.h" + +int main() { + return foo; // 'foo' was not declared in this scope +} diff --git a/SampleProjects/SharedLibrary/src/SharedLibrary.h b/SampleProjects/SharedLibrary/src/SharedLibrary.h new file mode 100644 index 00000000..9ee81b24 --- /dev/null +++ b/SampleProjects/SharedLibrary/src/SharedLibrary.h @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/SampleProjects/SharedLibrary/test.sh b/SampleProjects/SharedLibrary/test.sh new file mode 100755 index 00000000..b5ab6e4b --- /dev/null +++ b/SampleProjects/SharedLibrary/test.sh @@ -0,0 +1,9 @@ +g++ -v +cd SampleProjects/SharedLibrary +bundle install +bundle exec ensure_arduino_installation.rb +bundle exec arduino_ci.rb --skip-examples-compilation +if [ $? -ne 1 ]; then + exit 1 +fi +exit 0 diff --git a/SampleProjects/SharedLibrary/test/test.cpp b/SampleProjects/SharedLibrary/test/test.cpp new file mode 100644 index 00000000..326c978e --- /dev/null +++ b/SampleProjects/SharedLibrary/test/test.cpp @@ -0,0 +1,13 @@ +/* +cd SampleProjects/SharedLibrary +bundle config --local path vendor/bundle +bundle install +bundle exec arduino_ci.rb --skip-examples-compilation +*/ + +#include +#include + +unittest(test) { assertEqual(true, true); } + +unittest_main() diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index ebaa1452..175cdb2c 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -423,7 +423,22 @@ def perform_unit_tests(cpp_library, file_config) puts compilers.each do |gcc_binary| # before compiling the tests, build a shared library of everything except the test code - next unless build_shared_library(gcc_binary, p, config, cpp_library) + got_shared_library = true + attempt_multiline("Build shared library with #{gcc_binary} for #{p}") do + exe = cpp_library.build_shared_library( + config.aux_libraries_for_unittest, + gcc_binary, + config.gcc_config(p) + ) + unless exe + puts "Last command: #{cpp_library.last_cmd}" + puts cpp_library.last_out + puts cpp_library.last_err + got_shared_library = false + end + next got_shared_library + end + next unless got_shared_library # now build and run each test using the shared library build above config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path| @@ -445,24 +460,6 @@ def perform_unit_tests(cpp_library, file_config) end end -def build_shared_library(gcc_binary, platform, config, cpp_library) - attempt_multiline("Build shared library with #{gcc_binary} for #{platform}") do - exe = cpp_library.build_shared_library( - config.aux_libraries_for_unittest, - gcc_binary, - config.gcc_config(platform) - ) - puts - unless exe - puts "Last command: #{cpp_library.last_cmd}" - puts cpp_library.last_out - puts cpp_library.last_err - return false - end - return true - end -end - def perform_example_compilation_tests(cpp_library, config) phase("Compilation of example sketches") if @cli_options[:skip_compilation]