Skip to content

Commit 49085c7

Browse files
committed
Check for board manager package URLs in CI
1 parent 804ba3b commit 49085c7

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [Unreleased]
88
### Added
99
- Arduino command wrapper now natively supports board manager URLs
10+
- CI checks for proper board manager URLs for requested platforms
1011

1112
### Changed
1213
- Centralized file listing code in `arduino_ci_remote.rb`

exe/arduino_ci_remote.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def display_files(pathname)
142142
# start with the "platforms to unittest" and add the examples
143143
# while we're doing that, get the aux libraries as well
144144
all_platforms = {}
145+
board_platform_url = {}
145146
aux_libraries = Set.new(config.aux_libraries_for_unittest + config.aux_libraries_for_build)
146147
# while collecting the platforms, ensure they're defined
147148
config.platforms_to_unittest.each { |p| all_platforms[p] = assured_platform("unittest", p, config) }
@@ -151,14 +152,28 @@ def display_files(pathname)
151152
ovr_config.platforms_to_build.each do |p|
152153
# assure the platform if we haven't already
153154
example_platforms[p] = all_platforms[p] = assured_platform("library example", p, config) unless example_platforms.key?(p)
155+
board_platform_url[p] = ovr_config.package_url(p)
154156
end
155157
aux_libraries.merge(ovr_config.aux_libraries_for_build)
156158
end
157159

158160
# with all platform info, we can extract unique packages and their urls
159161
# do that, set the URLs, and download the packages
160162
all_packages = all_platforms.values.map { |v| v[:package] }.uniq.reject(&:nil?)
161-
all_urls = all_packages.map { |p| config.package_url(p) }.uniq.reject(&:nil?)
163+
164+
# inform about builtin packages
165+
all_packages.select { |p| config.package_builtin?(p) }.each do
166+
inform("Using built-in board package") { p }
167+
end
168+
169+
# make sure any non-builtin package has a URL defined
170+
all_packages.reject { |p| config.package_builtin?(p) }.each do
171+
assure("Board package #{p} has a defined URL") { board_platform_url[p] }
172+
end
173+
174+
# set up all the board manager URLs.
175+
# we can safely reject nils now, they would be for the builtins
176+
all_urls = all_packages.map { |p| board_platform_url(p) }.uniq.reject(&:nil?)
162177
unless all_urls.empty?
163178
assure("Setting board manager URLs") do
164179
@arduino_cmd.board_manager_urls = all_urls

lib/arduino_ci/ci_config.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ def platform_definition(platform_name)
191191
deep_clone(defn)
192192
end
193193

194+
# Whether a package is built-in to arduino
195+
# @param package [String] the package name (e.g. "arduino:avr")
196+
# @return [bool]
197+
def package_builtin?(package)
198+
package.start_with?("arduino:")
199+
end
200+
194201
# the URL that gives the download info for a given package (a JSON file).
195202
# this is NOT where the package comes from.
196203
# @param package [String] the package name (e.g. "arduino:avr")

misc/default.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems
44

55
packages:
6+
# arduino:xxx are builtin, we don't need to include them here
67
esp8266:esp8266:
78
url: http://arduino.esp8266.com/stable/package_esp8266com_index.json
89
adafruit:avr:
@@ -16,7 +17,7 @@ platforms:
1617

1718
uno:
1819
board: arduino:avr:uno
19-
package: ~
20+
package: arduino:avr
2021
gcc:
2122
features:
2223
defines:
@@ -60,7 +61,7 @@ platforms:
6061
flags:
6162
leonardo:
6263
board: arduino:avr:leonardo
63-
package: ~
64+
package: arduino:avr
6465
gcc:
6566
features:
6667
defines:

spec/ci_config_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
expect(zero[:package]).to eq("arduino:samd")
2525
expect(zero[:gcc].class).to eq(Hash)
2626

27+
expect(default_config.package_builtin?("arduino:avr")).to be true
28+
expect(default_config.package_builtin?("adafruit:avr")).to be false
29+
2730
expect(default_config.package_url("adafruit:avr")).to eq("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json")
31+
expect(default_config.package_url("adafruit:samd")).to eq("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json")
32+
expect(default_config.package_url("esp32:esp32")).to eq("https://dl.espressif.com/dl/package_esp32_index.json")
2833
expect(default_config.platforms_to_build).to match(["uno", "due", "zero", "leonardo", "m4", "esp32", "esp8266", "mega2560"])
2934
expect(default_config.platforms_to_unittest).to match(["uno", "due", "zero", "leonardo"])
3035
expect(default_config.aux_libraries_for_build).to match([])

0 commit comments

Comments
 (0)