arduino_ci 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/exe/arduino_ci_remote.rb +4 -2
- data/lib/arduino_ci/ci_config.rb +1 -1
- data/lib/arduino_ci/cpp_library.rb +2 -1
- data/lib/arduino_ci/version.rb +1 -1
- metadata +3 -5
- data/exe/arduino_ci_remote.rb.orig +0 -268
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 15e345b597108192a550ec12ee76a0e885ca6cf0
|
4
|
+
data.tar.gz: 11175d4813c5a96512a69908ced560b04e0a3508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3227370d70a4d319e79c3900e744732c6ed66fcd2cfe2e45347512ba1a13f14e77a2496e34b6711bd2d99fa4d926d24506b2eddded019222359e3e0c78115988
|
7
|
+
data.tar.gz: e5c8b30ad8819d5b01c3efcacb35b90758ead156dd71f2bff6feddfd2f37a61c9de7033906d5501476e35dc505b0f9dc7d92ec1e405512418ed9d159bb1cb07e
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
# ArduinoCI Ruby gem (`arduino_ci`) [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci) [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.
|
2
|
+
# ArduinoCI Ruby gem (`arduino_ci`) [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci) [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.15)
|
3
3
|
|
4
4
|
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/ianfixes/arduino_ci) provides that ability.
|
5
5
|
|
data/exe/arduino_ci_remote.rb
CHANGED
@@ -263,8 +263,10 @@ else
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
if
|
267
|
-
|
266
|
+
if config.platforms_to_build.empty?
|
267
|
+
inform("Skipping builds") { "no platforms were requested" }
|
268
|
+
elsif library_examples.empty?
|
269
|
+
inform_multiline("Skipping builds; no examples found in #{installed_library_path}") do
|
268
270
|
display_files(installed_library_path)
|
269
271
|
end
|
270
272
|
else
|
data/lib/arduino_ci/ci_config.rb
CHANGED
@@ -93,7 +93,7 @@ module ArduinoCI
|
|
93
93
|
if !schema.include?(ksym)
|
94
94
|
puts "Warning: unknown field '#{ksym}' under definition for #{rootname}"
|
95
95
|
elsif value.nil?
|
96
|
-
|
96
|
+
good_data[ksym] = nil
|
97
97
|
elsif value.class != expected_type
|
98
98
|
puts "Warning: expected field '#{ksym}' of #{rootname} to be '#{expected_type}', got '#{value.class}'"
|
99
99
|
else
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'find'
|
2
2
|
require "arduino_ci/host"
|
3
3
|
require 'pathname'
|
4
|
+
require 'shellwords'
|
4
5
|
|
5
6
|
HPP_EXTENSIONS = [".hpp", ".hh", ".h", ".hxx", ".h++"].freeze
|
6
7
|
CPP_EXTENSIONS = [".cpp", ".cc", ".c", ".cxx", ".c++"].freeze
|
@@ -287,7 +288,7 @@ module ArduinoCI
|
|
287
288
|
@last_cmd = executable
|
288
289
|
@last_out = ""
|
289
290
|
@last_err = ""
|
290
|
-
Host.run_and_output(executable.to_s)
|
291
|
+
Host.run_and_output(executable.to_s.shellescape)
|
291
292
|
end
|
292
293
|
|
293
294
|
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: 0.1.
|
4
|
+
version: 0.1.15
|
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: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -99,7 +99,6 @@ email:
|
|
99
99
|
- ianfixes@gmail.com
|
100
100
|
executables:
|
101
101
|
- arduino_ci_remote.rb
|
102
|
-
- arduino_ci_remote.rb.orig
|
103
102
|
- ensure_arduino_installation.rb
|
104
103
|
- libasan.rb
|
105
104
|
extensions: []
|
@@ -407,7 +406,6 @@ files:
|
|
407
406
|
- cpp/unittest/Assertion.h
|
408
407
|
- cpp/unittest/Compare.h
|
409
408
|
- exe/arduino_ci_remote.rb
|
410
|
-
- exe/arduino_ci_remote.rb.orig
|
411
409
|
- exe/ensure_arduino_installation.rb
|
412
410
|
- exe/libasan.rb
|
413
411
|
- lib/arduino_ci.rb
|
@@ -446,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
446
444
|
version: '0'
|
447
445
|
requirements: []
|
448
446
|
rubyforge_project:
|
449
|
-
rubygems_version: 2.
|
447
|
+
rubygems_version: 2.5.2.3
|
450
448
|
signing_key:
|
451
449
|
specification_version: 4
|
452
450
|
summary: Tools for building and unit testing Arduino libraries
|
@@ -1,268 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'arduino_ci'
|
3
|
-
require 'set'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
WIDTH = 80
|
7
|
-
FIND_FILES_INDENT = 4
|
8
|
-
|
9
|
-
@failure_count = 0
|
10
|
-
@passfail = proc { |result| result ? "✓" : "✗" }
|
11
|
-
|
12
|
-
# terminate after printing any debug info. TODO: capture debug info
|
13
|
-
def terminate(final = nil)
|
14
|
-
puts "Failures: #{@failure_count}"
|
15
|
-
unless @failure_count.zero? || final
|
16
|
-
puts "Last message: #{@arduino_cmd.last_msg}"
|
17
|
-
puts "========== Stdout:"
|
18
|
-
puts @arduino_cmd.last_out
|
19
|
-
puts "========== Stderr:"
|
20
|
-
puts @arduino_cmd.last_err
|
21
|
-
end
|
22
|
-
retcode = @failure_count.zero? ? 0 : 1
|
23
|
-
exit(retcode)
|
24
|
-
end
|
25
|
-
|
26
|
-
# make a nice status line for an action and react to the action
|
27
|
-
def perform_action(message, multiline, mark_fn, on_fail_msg, tally_on_fail, abort_on_fail)
|
28
|
-
line = "#{message}... "
|
29
|
-
endline = "...#{message} "
|
30
|
-
if multiline
|
31
|
-
puts line
|
32
|
-
else
|
33
|
-
print line
|
34
|
-
end
|
35
|
-
STDOUT.flush
|
36
|
-
result = yield
|
37
|
-
mark = mark_fn.nil? ? "" : mark_fn.call(result)
|
38
|
-
# if multline, put checkmark at full width
|
39
|
-
print endline if multiline
|
40
|
-
puts mark.to_s.rjust(WIDTH - line.length, " ")
|
41
|
-
unless result
|
42
|
-
puts on_fail_msg unless on_fail_msg.nil?
|
43
|
-
@failure_count += 1 if tally_on_fail
|
44
|
-
# print out error messaging here if we've captured it
|
45
|
-
terminate if abort_on_fail
|
46
|
-
end
|
47
|
-
result
|
48
|
-
end
|
49
|
-
|
50
|
-
# Make a nice status for something that defers any failure code until script exit
|
51
|
-
def attempt(message, &block)
|
52
|
-
perform_action(message, false, @passfail, nil, true, false, &block)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Make a nice status for something that defers any failure code until script exit
|
56
|
-
def attempt_multiline(message, &block)
|
57
|
-
perform_action(message, true, @passfail, nil, true, false, &block)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Make a nice status for something that kills the script immediately on failure
|
61
|
-
FAILED_ASSURANCE_MESSAGE = "This may indicate a problem with ArduinoCI, or your configuration".freeze
|
62
|
-
def assure(message, &block)
|
63
|
-
perform_action(message, false, @passfail, FAILED_ASSURANCE_MESSAGE, true, true, &block)
|
64
|
-
end
|
65
|
-
|
66
|
-
def assure_multiline(message, &block)
|
67
|
-
perform_action(message, true, @passfail, FAILED_ASSURANCE_MESSAGE, true, true, &block)
|
68
|
-
end
|
69
|
-
|
70
|
-
def inform(message, &block)
|
71
|
-
perform_action(message, false, proc { |x| x }, nil, false, false, &block)
|
72
|
-
end
|
73
|
-
|
74
|
-
def inform_multiline(message, &block)
|
75
|
-
perform_action(message, true, nil, nil, false, false, &block)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Assure that a platform exists and return its definition
|
79
|
-
def assured_platform(purpose, name, config)
|
80
|
-
platform_definition = config.platform_definition(name)
|
81
|
-
assure("Requested #{purpose} platform '#{name}' is defined in 'platforms' YML") do
|
82
|
-
!platform_definition.nil?
|
83
|
-
end
|
84
|
-
platform_definition
|
85
|
-
end
|
86
|
-
|
87
|
-
# print out some files
|
88
|
-
def display_files(pathname)
|
89
|
-
# `find` doesn't follow symlinks, so we should instead
|
90
|
-
realpath = pathname.symlink? ? pathname.readlink : pathname
|
91
|
-
|
92
|
-
# suppress directories and dotfile-based things
|
93
|
-
all_files = realpath.find.select(&:file?)
|
94
|
-
non_hidden = all_files.reject do |path|
|
95
|
-
<<<<<<< HEAD
|
96
|
-
path.ascend.any? { |part| part.basename.to_s.start_with? "." }
|
97
|
-
=======
|
98
|
-
path.ascend do |path_part|
|
99
|
-
next true if path_part.basename.to_s.start_with? "."
|
100
|
-
end
|
101
|
-
false
|
102
|
-
>>>>>>> 0f4e679... don't redundantly report assured platforms
|
103
|
-
end
|
104
|
-
|
105
|
-
# print files with an indent
|
106
|
-
margin = " " * FIND_FILES_INDENT
|
107
|
-
non_hidden.each { |p| puts "#{margin}#{p}" }
|
108
|
-
end
|
109
|
-
|
110
|
-
# initialize command and config
|
111
|
-
config = ArduinoCI::CIConfig.default.from_project_library
|
112
|
-
@arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate!
|
113
|
-
|
114
|
-
# initialize library under test
|
115
|
-
installed_library_path = attempt("Installing library under test") do
|
116
|
-
@arduino_cmd.install_local_library(Pathname.new("."))
|
117
|
-
end
|
118
|
-
if installed_library_path.exist?
|
119
|
-
inform("Library installed at") { installed_library_path.to_s }
|
120
|
-
else
|
121
|
-
assure_multiline("Library installed successfully") do
|
122
|
-
@arduino_cmd.lib_dir.ascend do |path_part|
|
123
|
-
next unless path_part.exist?
|
124
|
-
|
125
|
-
break display_files(path_part)
|
126
|
-
end
|
127
|
-
false
|
128
|
-
end
|
129
|
-
end
|
130
|
-
library_examples = @arduino_cmd.library_examples(installed_library_path)
|
131
|
-
cpp_library = ArduinoCI::CppLibrary.new(installed_library_path, @arduino_cmd.lib_dir)
|
132
|
-
|
133
|
-
# check GCC
|
134
|
-
compilers = config.compilers_to_use
|
135
|
-
assure("The set of compilers (#{compilers.length}) isn't empty") { !compilers.empty? }
|
136
|
-
compilers.each do |gcc_binary|
|
137
|
-
attempt_multiline("Checking #{gcc_binary} version") do
|
138
|
-
version = cpp_library.gcc_version(gcc_binary)
|
139
|
-
next nil unless version
|
140
|
-
|
141
|
-
puts version.split("\n").map { |l| " #{l}" }.join("\n")
|
142
|
-
version
|
143
|
-
end
|
144
|
-
inform("libasan availability for #{gcc_binary}") { cpp_library.libasan?(gcc_binary) }
|
145
|
-
end
|
146
|
-
|
147
|
-
# gather up all required boards so we can install them up front.
|
148
|
-
# start with the "platforms to unittest" and add the examples
|
149
|
-
# while we're doing that, get the aux libraries as well
|
150
|
-
all_platforms = {}
|
151
|
-
aux_libraries = Set.new(config.aux_libraries_for_unittest + config.aux_libraries_for_build)
|
152
|
-
# while collecting the platforms, ensure they're defined
|
153
|
-
config.platforms_to_unittest.each { |p| all_platforms[p] = assured_platform("unittest", p, config) }
|
154
|
-
example_platforms = {}
|
155
|
-
library_examples.each do |path|
|
156
|
-
ovr_config = config.from_example(path)
|
157
|
-
ovr_config.platforms_to_build.each do |p|
|
158
|
-
# assure the platform if we haven't already
|
159
|
-
example_platforms[p] = all_platforms[p] = assured_platform("library example", p, config) unless example_platforms.key?(p)
|
160
|
-
end
|
161
|
-
aux_libraries.merge(ovr_config.aux_libraries_for_build)
|
162
|
-
end
|
163
|
-
|
164
|
-
# with all platform info, we can extract unique packages and their urls
|
165
|
-
# do that, set the URLs, and download the packages
|
166
|
-
all_packages = all_platforms.values.map { |v| v[:package] }.uniq.reject(&:nil?)
|
167
|
-
all_urls = all_packages.map { |p| config.package_url(p) }.uniq.reject(&:nil?)
|
168
|
-
unless all_urls.empty?
|
169
|
-
assure("Setting board manager URLs") do
|
170
|
-
@arduino_cmd.set_pref("boardsmanager.additional.urls", all_urls.join(","))
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
all_packages.each do |p|
|
175
|
-
assure("Installing board package #{p}") do
|
176
|
-
@arduino_cmd.install_boards(p)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
aux_libraries.each do |l|
|
181
|
-
if @arduino_cmd.library_present?(l)
|
182
|
-
inform("Using pre-existing library") { l.to_s }
|
183
|
-
else
|
184
|
-
assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# iterate boards / tests
|
189
|
-
last_board = nil
|
190
|
-
if !cpp_library.tests_dir.exist?
|
191
|
-
inform_multiline("Skipping unit tests; no tests dir at #{cpp_library.tests_dir}") do
|
192
|
-
display_files(cpp_library.tests_dir.parent)
|
193
|
-
true
|
194
|
-
end
|
195
|
-
elsif cpp_library.test_files.empty?
|
196
|
-
inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do
|
197
|
-
display_files(cpp_library.tests_dir)
|
198
|
-
true
|
199
|
-
end
|
200
|
-
elsif config.platforms_to_unittest.empty?
|
201
|
-
inform("Skipping unit tests") { "no platforms were requested" }
|
202
|
-
else
|
203
|
-
config.platforms_to_unittest.each do |p|
|
204
|
-
board = all_platforms[p][:board]
|
205
|
-
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) } unless last_board == board
|
206
|
-
last_board = board
|
207
|
-
cpp_library.test_files.each do |unittest_path|
|
208
|
-
unittest_name = unittest_path.basename.to_s
|
209
|
-
compilers.each do |gcc_binary|
|
210
|
-
attempt_multiline("Unit testing #{unittest_name} with #{gcc_binary}") do
|
211
|
-
exe = cpp_library.build_for_test_with_configuration(
|
212
|
-
unittest_path,
|
213
|
-
config.aux_libraries_for_unittest,
|
214
|
-
gcc_binary,
|
215
|
-
config.gcc_config(p)
|
216
|
-
)
|
217
|
-
puts
|
218
|
-
unless exe
|
219
|
-
puts "Last command: #{cpp_library.last_cmd}"
|
220
|
-
puts cpp_library.last_out
|
221
|
-
puts cpp_library.last_err
|
222
|
-
next false
|
223
|
-
end
|
224
|
-
cpp_library.run_test_file(exe)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
if library_examples.empty?
|
232
|
-
inform_multiline("Skipping libraries; no examples found in #{installed_library_path}") do
|
233
|
-
display_files(installed_library_path)
|
234
|
-
end
|
235
|
-
else
|
236
|
-
attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }
|
237
|
-
|
238
|
-
# switching boards takes time, so iterate board first
|
239
|
-
# _then_ whichever examples match it
|
240
|
-
examples_by_platform = library_examples.each_with_object({}) do |example_path, acc|
|
241
|
-
ovr_config = config.from_example(example_path)
|
242
|
-
ovr_config.platforms_to_build.each do |p|
|
243
|
-
acc[p] = [] unless acc.key?(p)
|
244
|
-
acc[p] << example_path
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
examples_by_platform.each do |platform, example_paths|
|
249
|
-
board = all_platforms[platform][:board]
|
250
|
-
assure("Switching to board for #{platform} (#{board})") { @arduino_cmd.use_board(board) } unless last_board == board
|
251
|
-
last_board = board
|
252
|
-
|
253
|
-
example_paths.each do |example_path|
|
254
|
-
example_name = File.basename(example_path)
|
255
|
-
attempt("Verifying #{example_name}") do
|
256
|
-
ret = @arduino_cmd.verify_sketch(example_path)
|
257
|
-
unless ret
|
258
|
-
puts
|
259
|
-
puts "Last command: #{@arduino_cmd.last_msg}"
|
260
|
-
puts @arduino_cmd.last_err
|
261
|
-
end
|
262
|
-
ret
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
terminate(true)
|