arduino_ci 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/REFERENCE.md +5 -0
- data/cpp/arduino/Arduino.h +5 -0
- data/cpp/arduino/ArduinoDefines.h +2 -1
- data/cpp/arduino/Godmode.h +3 -0
- data/exe/arduino_ci.rb +19 -4
- data/lib/arduino_ci/arduino_backend.rb +4 -1
- data/lib/arduino_ci/ci_config.rb +29 -18
- data/lib/arduino_ci/host.rb +20 -0
- data/lib/arduino_ci/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3fcf7949cd16f89c3b4b62b6aa44121e68a3e9a4424d106d2912f7aa628902e
|
4
|
+
data.tar.gz: 04ae38ca97c87a875628d01f2611916238d8ff2a2f98281911192319333438ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a31c4b7e8d97a019de95e9a6af215885cbb2c21b1b6c13db014c1a08d1c507fb8a5eea960fae09ae18a3cc11c5bb7e8b7f965beca40f597a6b41a0d4fddc8c
|
7
|
+
data.tar.gz: cd5567a69c0ab3a183e83c9a8ab88b5e6afd1547c366f4debd7aa88947298cdcb88ecbe0964548a58a89571c4c076b85b87bbc523c3c2c42e6283647043aae03
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
# ArduinoCI Ruby gem (`arduino_ci`)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci)
|
4
|
-
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/1.
|
4
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/1.5.0)
|
5
5
|
[![Gitter](https://badges.gitter.im/Arduino-CI/arduino_ci.svg)](https://gitter.im/Arduino-CI/arduino_ci?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
6
6
|
[![GitHub Marketplace](https://img.shields.io/badge/Get_it-on_Marketplace-informational.svg)](https://github.com/marketplace/actions/arduino_ci)
|
7
7
|
|
@@ -118,11 +118,11 @@ gem 'arduino_ci', path: '/path/to/development/dir/for/arduino_ci'
|
|
118
118
|
|
119
119
|
### Installing the Dependencies
|
120
120
|
|
121
|
-
Fulfilling the `arduino_ci` library dependency is as easy as running
|
121
|
+
Fulfilling the `arduino_ci` library dependency is as easy as running one or both of these commands:
|
122
122
|
|
123
123
|
```console
|
124
|
-
$ bundle
|
125
|
-
$ bundle install
|
124
|
+
$ bundle config set --local path 'vendor/bundle' # if you lack administrative privileges to install globally
|
125
|
+
$ bundle install
|
126
126
|
```
|
127
127
|
|
128
128
|
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:
|
|
169
169
|
runTest:
|
170
170
|
runs-on: ubuntu-latest
|
171
171
|
steps:
|
172
|
-
- uses: actions/checkout@
|
172
|
+
- uses: actions/checkout@v3
|
173
173
|
- uses: ruby/setup-ruby@v1
|
174
174
|
with:
|
175
175
|
ruby-version: 2.6
|
data/REFERENCE.md
CHANGED
@@ -44,6 +44,11 @@ This allows a file (or glob) pattern to be executed in your tests directory, cre
|
|
44
44
|
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.
|
45
45
|
|
46
46
|
|
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
|
+
|
47
52
|
### `CUSTOM_INIT_SCRIPT` environment variable
|
48
53
|
|
49
54
|
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.
|
data/cpp/arduino/Arduino.h
CHANGED
@@ -5,6 +5,11 @@ Mock Arduino.h library.
|
|
5
5
|
Where possible, variable names from the Arduino library are used to avoid conflicts
|
6
6
|
|
7
7
|
*/
|
8
|
+
|
9
|
+
// signal to the developer that we are in an arduino_ci mocked environment
|
10
|
+
#define ARDUINO_CI_COMPILATION_MOCKS
|
11
|
+
|
12
|
+
|
8
13
|
// Chars and strings
|
9
14
|
|
10
15
|
#include "ArduinoDefines.h"
|
@@ -89,7 +89,8 @@
|
|
89
89
|
#define TIMER5B 17
|
90
90
|
#define TIMER5C 18
|
91
91
|
|
92
|
-
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
92
|
+
#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
|
93
94
|
#define LED_BUILTIN 13
|
94
95
|
#endif
|
95
96
|
|
data/cpp/arduino/Godmode.h
CHANGED
data/exe/arduino_ci.rb
CHANGED
@@ -69,7 +69,6 @@ class Parser
|
|
69
69
|
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
|
70
70
|
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
|
71
71
|
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"
|
73
72
|
exit
|
74
73
|
end
|
75
74
|
end
|
@@ -194,6 +193,13 @@ def assured_platform(purpose, name, config)
|
|
194
193
|
platform_definition
|
195
194
|
end
|
196
195
|
|
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
|
+
|
197
203
|
# Return true if the file (or one of the dirs containing it) is hidden
|
198
204
|
def file_is_hidden_somewhere?(path)
|
199
205
|
# 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)
|
|
436
442
|
puts
|
437
443
|
compilers.each do |gcc_binary|
|
438
444
|
# 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)
|
440
446
|
|
441
447
|
# now build and run each test using the shared library build above
|
442
448
|
config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path|
|
@@ -489,12 +495,17 @@ def perform_example_compilation_tests(cpp_library, config)
|
|
489
495
|
return
|
490
496
|
end
|
491
497
|
|
498
|
+
inform_override("examples") { config.override_file_from_example(cpp_library.examples_dir) }
|
499
|
+
ex_config = config.from_example(cpp_library.examples_dir)
|
500
|
+
|
492
501
|
library_examples.each do |example_path|
|
493
502
|
example_name = File.basename(example_path)
|
494
503
|
puts
|
495
504
|
inform("Discovered example sketch") { example_name }
|
496
505
|
|
497
|
-
|
506
|
+
inform_override("example") { ex_config.override_file_from_example(example_path) }
|
507
|
+
ovr_config = ex_config.from_example(example_path)
|
508
|
+
|
498
509
|
platforms = choose_platform_set(ovr_config, "library example", ovr_config.platforms_to_build, cpp_library.library_properties)
|
499
510
|
|
500
511
|
# having no platforms defined is probably an error
|
@@ -542,9 +553,13 @@ inform("Host OS") { ArduinoCI::Host.os }
|
|
542
553
|
inform("Working directory") { Dir.pwd }
|
543
554
|
|
544
555
|
# initialize command and config
|
545
|
-
|
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
|
+
|
546
560
|
@backend = ArduinoCI::ArduinoInstallation.autolocate!
|
547
561
|
inform("Located arduino-cli binary") { @backend.binary_path.to_s }
|
562
|
+
inform("Using arduino-cli version") { @backend.version.to_s }
|
548
563
|
if @backend.lib_dir.exist?
|
549
564
|
inform("Found libraries directory") { @backend.lib_dir }
|
550
565
|
else
|
@@ -182,7 +182,10 @@ module ArduinoCI
|
|
182
182
|
result = if @additional_urls.empty?
|
183
183
|
run_and_capture("core", "install", boardfamily)
|
184
184
|
else
|
185
|
-
|
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
|
186
189
|
end
|
187
190
|
result[:success]
|
188
191
|
end
|
data/lib/arduino_ci/ci_config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
# base config (platforms)
|
4
5
|
# project config - .arduino_ci_platforms.yml
|
@@ -58,7 +59,7 @@ module ArduinoCI
|
|
58
59
|
def default
|
59
60
|
ret = new
|
60
61
|
ret.instance_variable_set("@is_default", true)
|
61
|
-
ret.load_yaml(
|
62
|
+
ret.load_yaml((Pathname.new(__dir__) + "../../misc/default.yml").realpath)
|
62
63
|
ret
|
63
64
|
end
|
64
65
|
end
|
@@ -195,35 +196,45 @@ module ArduinoCI
|
|
195
196
|
overridden_config
|
196
197
|
end
|
197
198
|
|
198
|
-
# Get
|
199
|
-
# Many config files may exist, but only the first match is used
|
199
|
+
# Get available configuration file, if one exists
|
200
200
|
# @param base_dir [String] The directory in which to search for a config file
|
201
|
-
# @
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
201
|
+
# @return [Pathname] the first available config file we could find, or nil
|
202
|
+
def available_override_config_path(base_dir = nil)
|
203
|
+
CONFIG_FILENAMES.map { |f| base_dir.nil? ? Pathname.new(f) : base_dir + f }.find(&:exist?)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Find an available override file from the project directory
|
207
|
+
#
|
208
|
+
# @todo this is currently reliant on launching the arduino_ci.rb test runner from
|
209
|
+
# the correct working directory
|
210
|
+
# @return [Pathname] A file that can override project config, or nil if none was found
|
211
|
+
def override_file_from_project_library
|
212
|
+
available_override_config_path(nil)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Find an available override file from an example sketch
|
216
|
+
#
|
217
|
+
# @param path [Pathname] the path to the example or example directory
|
218
|
+
# @return [Pathname] A file that can override project config, or nil if none was found
|
219
|
+
def override_file_from_example(example_path)
|
220
|
+
base_dir = example_path.directory? ? example_path : example_path.dirname
|
221
|
+
available_override_config_path(base_dir)
|
212
222
|
end
|
213
223
|
|
214
224
|
# Produce a configuration, assuming the CI script runs from the working directory of the base project
|
215
225
|
# @return [ArduinoCI::CIConfig] the new settings object
|
216
226
|
def from_project_library
|
217
|
-
|
227
|
+
ovr = override_file_from_project_library
|
228
|
+
ovr.nil? ? self : with_override(ovr)
|
218
229
|
end
|
219
230
|
|
220
231
|
# Produce a configuration override taken from an Arduino library example path
|
221
232
|
# handle either path to example file or example dir
|
222
|
-
# @param path [
|
233
|
+
# @param path [Pathname] the path to the settings yaml file
|
223
234
|
# @return [ArduinoCI::CIConfig] the new settings object
|
224
235
|
def from_example(example_path)
|
225
|
-
|
226
|
-
|
236
|
+
ovr = override_file_from_example(example_path)
|
237
|
+
ovr.nil? ? self : with_override(ovr)
|
227
238
|
end
|
228
239
|
|
229
240
|
# get information about a given platform: board name, package name, compiler stuff, etc
|
data/lib/arduino_ci/host.rb
CHANGED
@@ -30,11 +30,31 @@ module ArduinoCI
|
|
30
30
|
nil
|
31
31
|
end
|
32
32
|
|
33
|
+
# Execute a shell command and capture stdout, stderr, and status
|
34
|
+
#
|
35
|
+
# @see Process.spawn
|
36
|
+
# @see https://docs.ruby-lang.org/en/2.0.0/Process.html#method-c-spawn
|
37
|
+
# @return [Hash] with keys "stdout" (String), "stderr" (String), and "success" (bool)
|
33
38
|
def self.run_and_capture(*args, **kwargs)
|
34
39
|
stdout, stderr, status = Open3.capture3(*args, **kwargs)
|
35
40
|
{ out: stdout, err: stderr, success: status.exitstatus.zero? }
|
36
41
|
end
|
37
42
|
|
43
|
+
# Merge multiple capture results into one aggregate value
|
44
|
+
#
|
45
|
+
# @param args [Array] Array of hashes from `run_and_capture`
|
46
|
+
# @return [Hash] with keys "stdout" (String), "stderr" (String), and "success" (bool)
|
47
|
+
def self.merge_capture_results(*args)
|
48
|
+
{
|
49
|
+
out: args.map { |a| a[:out] }.join,
|
50
|
+
err: args.map { |a| a[:err] }.join,
|
51
|
+
success: args.all? { |a| a[:success] }
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Execute a shell command
|
56
|
+
#
|
57
|
+
# @see system
|
38
58
|
def self.run_and_output(*args, **kwargs)
|
39
59
|
system(*args, **kwargs)
|
40
60
|
end
|
data/lib/arduino_ci/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arduino_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Katz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|