Skip to content

Commit e699436

Browse files
authored
Merge pull request #338 from ianfixes/2022-12-28_tweaks
Further bugfixes and documentation fixes
2 parents a967a67 + 8904255 commit e699436

File tree

19 files changed

+156
-50
lines changed

19 files changed

+156
-50
lines changed

Diff for: .github/workflows/linter.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout Code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
with:
2020
# Full git history is needed to get a proper list of changed files within `super-linter`
2121
fetch-depth: 0

Diff for: .github/workflows/linux.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
"rubocop":
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
- uses: ruby/setup-ruby@v1
1212
with:
1313
ruby-version: 2.6
@@ -21,7 +21,7 @@ jobs:
2121
"rspec-linux":
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525
- uses: ruby/setup-ruby@v1
2626
with:
2727
ruby-version: 2.6
@@ -34,7 +34,7 @@ jobs:
3434
"TestSomething":
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838
- uses: ruby/setup-ruby@v1
3939
with:
4040
ruby-version: 2.6
@@ -44,12 +44,13 @@ jobs:
4444
bundle install
4545
cd SampleProjects/TestSomething
4646
bundle install
47+
bundle exec arduino_ci.rb --help
4748
bundle exec arduino_ci.rb
4849
4950
NetworkLib:
5051
runs-on: ubuntu-latest
5152
steps:
52-
- uses: actions/checkout@v2
53+
- uses: actions/checkout@v3
5354
- uses: ruby/setup-ruby@v1
5455
with:
5556
ruby-version: 2.6
@@ -65,7 +66,7 @@ jobs:
6566
SharedLibrary:
6667
runs-on: ubuntu-latest
6768
steps:
68-
- uses: actions/checkout@v2
69+
- uses: actions/checkout@v3
6970
- uses: ruby/setup-ruby@v1
7071
with:
7172
ruby-version: 2.6

Diff for: .github/workflows/macos.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
"rubocop":
88
runs-on: macos-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
- uses: ruby/setup-ruby@v1
1212
with:
1313
ruby-version: 2.6
@@ -21,7 +21,7 @@ jobs:
2121
"rspec-macos":
2222
runs-on: macos-latest
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525
- uses: ruby/setup-ruby@v1
2626
with:
2727
ruby-version: 2.6
@@ -34,7 +34,7 @@ jobs:
3434
"TestSomething":
3535
runs-on: macos-latest
3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838
- uses: ruby/setup-ruby@v1
3939
with:
4040
ruby-version: 2.6
@@ -44,12 +44,13 @@ jobs:
4444
bundle install
4545
cd SampleProjects/TestSomething
4646
bundle install
47+
bundle exec arduino_ci.rb --help
4748
bundle exec arduino_ci.rb
4849
4950
NetworkLib:
5051
runs-on: macos-latest
5152
steps:
52-
- uses: actions/checkout@v2
53+
- uses: actions/checkout@v3
5354
- uses: ruby/setup-ruby@v1
5455
with:
5556
ruby-version: 2.6
@@ -65,7 +66,7 @@ jobs:
6566
SharedLibrary:
6667
runs-on: macos-latest
6768
steps:
68-
- uses: actions/checkout@v2
69+
- uses: actions/checkout@v3
6970
- uses: ruby/setup-ruby@v1
7071
with:
7172
ruby-version: 2.6

Diff for: .github/workflows/spelling.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout Code
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
with:
2020
# Full git history is needed to get a proper list of changed files within `super-linter`
2121
fetch-depth: 0

Diff for: .github/workflows/windows.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
"rubocop":
88
runs-on: windows-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
- uses: ruby/setup-ruby@v1
1212
with:
1313
ruby-version: 2.6
@@ -21,7 +21,7 @@ jobs:
2121
"rspec-windows":
2222
runs-on: windows-latest
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525
- uses: ruby/setup-ruby@v1
2626
with:
2727
ruby-version: 2.6
@@ -34,7 +34,7 @@ jobs:
3434
TestSomething:
3535
runs-on: windows-latest
3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838
- uses: ruby/setup-ruby@v1
3939
with:
4040
ruby-version: 2.6
@@ -44,12 +44,13 @@ jobs:
4444
bundle install
4545
cd SampleProjects/TestSomething
4646
bundle install
47+
bundle exec arduino_ci.rb --help
4748
bundle exec arduino_ci.rb
4849
4950
NetworkLib:
5051
runs-on: windows-latest
5152
steps:
52-
- uses: actions/checkout@v2
53+
- uses: actions/checkout@v3
5354
- uses: ruby/setup-ruby@v1
5455
with:
5556
ruby-version: 2.6
@@ -65,7 +66,7 @@ jobs:
6566
SharedLibrary:
6667
runs-on: windows-latest
6768
steps:
68-
- uses: actions/checkout@v2
69+
- uses: actions/checkout@v3
6970
- uses: ruby/setup-ruby@v1
7071
with:
7172
ruby-version: 2.6

Diff for: CHANGELOG.md

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

88
## [Unreleased]
99
### Added
10+
- C++ definitions of `ARDUINO_CI_COMPILATION_MOCKS` and `ARDUINO_CI_GODMODE` to aid in compilation macros
11+
- `CIConfig.available_override_config_path()` to search for available override files in standard locations
12+
- `CIConfig.override_file_from_project_library` and `CIConfig.override_file_from_example` to expose config locations
13+
- CI runner script now expliclty informs about config overrides
14+
- A project `examples/` directory can now provide its own configuration override file, which provides no new flexibility but simply mirrors the behavior for `tests/`.
1015

1116
### Changed
17+
- `CIConfig` now uses `Pathname` instead of strings
1218

1319
### Deprecated
1420

1521
### Removed
22+
- `CIConfig.with_config`, which was only used internally
1623

1724
### Fixed
25+
- `arduino_ci.rb --help` no longer crashes
1826

1927
- Fix missing `LED_BUILTIN` definition for Arduino Due, Zero and Circuit Playground.
28+
- No longer ignore failures if the first step of compiling files for the unit test fails.
2029

2130
### Security
2231

@@ -30,7 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3039
- Support for `dtostrf()`
3140
- Added a CI workflow to lint the code base
3241
- Added a CI workflow to check for spelling errors
33-
- Extraction of byes usage in a compiled sketch is now calculated in a method: `ArduinoBackend.last_bytes_usage`
42+
- Extraction of bytes usage in a compiled sketch is now calculated in a method: `ArduinoBackend.last_bytes_usage`
3443
- Added ```nano_every``` platform to represent ```arduino:megaavr``` architecture
3544
- Working directory is now printed in test runner output
3645
- Explicitly include `irb` via rubygems

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ gem 'arduino_ci', path: '/path/to/development/dir/for/arduino_ci'
118118

119119
### Installing the Dependencies
120120

121-
Fulfilling the `arduino_ci` library dependency is as easy as running either of these two commands:
121+
Fulfilling the `arduino_ci` library dependency is as easy as running one or both of these commands:
122122

123123
```console
124-
$ bundle install # adds packages to global library (may require admin rights)
125-
$ bundle install --path vendor/bundle # adds packages to local library
124+
$ bundle config set --local path 'vendor/bundle' # if you lack administrative privileges to install globally
125+
$ bundle install
126126
```
127127

128128
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.
@@ -169,7 +169,7 @@ jobs:
169169
runTest:
170170
runs-on: ubuntu-latest
171171
steps:
172-
- uses: actions/checkout@v2
172+
- uses: actions/checkout@v3
173173
- uses: ruby/setup-ruby@v1
174174
with:
175175
ruby-version: 2.6

Diff for: REFERENCE.md

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ This allows a file (or glob) pattern to be executed in your tests directory, cre
4444
This allows a file (or glob) pattern to be executed in your tests directory, creating a blacklist of files to skip. E.g. `--testfile-reject=test_animal_*.cpp` would match `test_animal_cat.cpp` and `test_animal_dog.cpp` (skipping those) and test only `test_plant_rose.cpp`, `test_plant_daisy.cpp`, etc.
4545

4646

47+
### `--min-free-space` option
48+
49+
This specifies the minimum free SRAM memory for stack/heap, in bytes, that _must_ be leftover after compilation. This value applies globally -- to _all_ platforms that will be included in a test run.
50+
51+
4752
### `CUSTOM_INIT_SCRIPT` environment variable
4853

4954
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.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
compile:
2+
platforms:
3+
- uno
4+
- due
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
compile:
2+
platforms:
3+
- uno
4+
- due

Diff for: cpp/arduino/Arduino.h

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Mock Arduino.h library.
55
Where possible, variable names from the Arduino library are used to avoid conflicts
66
77
*/
8+
9+
// signal to the developer that we are in an arduino_ci mocked environment
10+
#define ARDUINO_CI_COMPILATION_MOCKS
11+
12+
813
// Chars and strings
914

1015
#include "ArduinoDefines.h"

Diff for: cpp/arduino/ArduinoDefines.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#define TIMER5C 18
9191

9292
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__SAM3X8E__) || defined(__SAMD21G18A__)
93+
// Verified on these platforms, see https://github.com/Arduino-CI/arduino_ci/pull/341#issuecomment-1368118880
9394
#define LED_BUILTIN 13
9495
#endif
9596

Diff for: cpp/arduino/Godmode.h

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include "WString.h"
77
#include "PinHistory.h"
88

9+
// signal to the developer that we are in an arduino_ci mocked environment
10+
#define ARDUINO_CI_GODMODE
11+
912
// random
1013
void randomSeed(unsigned long seed);
1114
long random(long vmax);

Diff for: exe/arduino_ci.rb

+19-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def self.parse(options)
6969
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
7070
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
7171
puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present"
72-
puts " - #{VAR_SKIP_LIBPROPS} - if set, testing will skip [experimental] library.properties validation"
7372
exit
7473
end
7574
end
@@ -194,6 +193,13 @@ def assured_platform(purpose, name, config)
194193
platform_definition
195194
end
196195

196+
def inform_override(from_where, &block)
197+
inform("Using configuration override from #{from_where}") do
198+
file = block.call
199+
file.nil? ? "<none>" : file
200+
end
201+
end
202+
197203
# Return true if the file (or one of the dirs containing it) is hidden
198204
def file_is_hidden_somewhere?(path)
199205
# this is clunkly but pre-2.2-ish ruby doesn't return ascend as an enumerator
@@ -436,7 +442,7 @@ def perform_unit_tests(cpp_library, file_config)
436442
puts
437443
compilers.each do |gcc_binary|
438444
# before compiling the tests, build a shared library of everything except the test code
439-
next unless build_shared_library(gcc_binary, p, config, cpp_library)
445+
next @failure_count += 1 unless build_shared_library(gcc_binary, p, config, cpp_library)
440446

441447
# now build and run each test using the shared library build above
442448
config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path|
@@ -489,12 +495,17 @@ def perform_example_compilation_tests(cpp_library, config)
489495
return
490496
end
491497

498+
inform_override("examples") { config.override_file_from_example(cpp_library.examples_dir) }
499+
ex_config = config.from_example(cpp_library.examples_dir)
500+
492501
library_examples.each do |example_path|
493502
example_name = File.basename(example_path)
494503
puts
495504
inform("Discovered example sketch") { example_name }
496505

497-
ovr_config = config.from_example(example_path)
506+
inform_override("example") { ex_config.override_file_from_example(example_path) }
507+
ovr_config = ex_config.from_example(example_path)
508+
498509
platforms = choose_platform_set(ovr_config, "library example", ovr_config.platforms_to_build, cpp_library.library_properties)
499510

500511
# having no platforms defined is probably an error
@@ -542,9 +553,13 @@ def perform_example_compilation_tests(cpp_library, config)
542553
inform("Working directory") { Dir.pwd }
543554

544555
# initialize command and config
545-
config = ArduinoCI::CIConfig.default.from_project_library
556+
default_config = ArduinoCI::CIConfig.default
557+
inform_override("project") { default_config.override_file_from_project_library }
558+
config = default_config.from_project_library
559+
546560
@backend = ArduinoCI::ArduinoInstallation.autolocate!
547561
inform("Located arduino-cli binary") { @backend.binary_path.to_s }
562+
inform("Using arduino-cli version") { @backend.version.to_s }
548563
if @backend.lib_dir.exist?
549564
inform("Found libraries directory") { @backend.lib_dir }
550565
else

Diff for: lib/arduino_ci/arduino_backend.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def install_boards(boardfamily)
182182
result = if @additional_urls.empty?
183183
run_and_capture("core", "install", boardfamily)
184184
else
185-
run_and_capture("core", "install", boardfamily, "--additional-urls", @additional_urls.join(","))
185+
urls = @additional_urls.join(",")
186+
# update the index, then install. if the update step fails, return that result
187+
updater = run_and_capture("core", "update-index", "--additional-urls", urls)
188+
updater[:success] ? run_and_capture("core", "install", boardfamily, "--additional-urls", urls) : updater
186189
end
187190
result[:success]
188191
end

0 commit comments

Comments
 (0)