Skip to content

Commit 4320bf1

Browse files
authored
Merge pull request #37 from ianfixes/2018-04-23_fix_it_ship_it
Bugfixes in support of 0.1.10 release
2 parents 94e1248 + 932a1d9 commit 4320bf1

17 files changed

+414
-111
lines changed

.github/issue_template.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
- `bundle info arduino_ci`:
99
- `g++ -v`:
1010
- Arduino IDE version:
11+
- `java -version`:
1112
- URL of failing Travis CI job:
1213
- URL of your Arduino project:
1314

1415

15-
## Issue / Feature Request Summary
16+
## (Issue Summary / Feature Request)
1617

1718

1819
## Arduino or Unit Test Code, Illustrating the Problem

CHANGELOG.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88
### Added
9+
- Arduino `force_install` on Linux now attempts downloading 3 times and provides more information on failure
10+
- Explicit check for `wget`
911

1012
### Changed
13+
- Author
14+
- Splash-screen-skip hack on OSX now falls back on "official" launch method if the hack doesn't work
15+
- Refactored download/install code in prepration for windows CI
1116

1217
### Deprecated
1318

1419
### Removed
1520

1621
### Fixed
17-
build_for_test_with_configuration
1822

1923
### Security
2024

@@ -163,15 +167,15 @@ build_for_test_with_configuration
163167
- Skeleton for gem with working unit tests
164168

165169

166-
[Unreleased]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.9...HEAD
167-
[0.1.9]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.8...v0.1.9
168-
[0.1.8]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.7...v0.1.8
169-
[0.1.7]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.6...v0.1.7
170-
[0.1.6]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.5...v0.1.6
171-
[0.1.5]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.4...v0.1.5
172-
[0.1.4]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.3...v0.1.4
173-
[0.1.3]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.2...v0.1.3
174-
[0.1.2]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.1...v0.1.2
175-
[0.1.1]: https://github.com/ifreecarve/arduino_ci/compare/v0.1.0...v0.1.1
176-
[0.1.0]: https://github.com/ifreecarve/arduino_ci/compare/v0.0.1...v0.1.0
177-
[0.0.1]: https://github.com/ifreecarve/arduino_ci/compare/v0.0.0...v0.0.1
170+
[Unreleased]: https://github.com/ianfixes/arduino_ci/compare/v0.1.9...HEAD
171+
[0.1.9]: https://github.com/ianfixes/arduino_ci/compare/v0.1.8...v0.1.9
172+
[0.1.8]: https://github.com/ianfixes/arduino_ci/compare/v0.1.7...v0.1.8
173+
[0.1.7]: https://github.com/ianfixes/arduino_ci/compare/v0.1.6...v0.1.7
174+
[0.1.6]: https://github.com/ianfixes/arduino_ci/compare/v0.1.5...v0.1.6
175+
[0.1.5]: https://github.com/ianfixes/arduino_ci/compare/v0.1.4...v0.1.5
176+
[0.1.4]: https://github.com/ianfixes/arduino_ci/compare/v0.1.3...v0.1.4
177+
[0.1.3]: https://github.com/ianfixes/arduino_ci/compare/v0.1.2...v0.1.3
178+
[0.1.2]: https://github.com/ianfixes/arduino_ci/compare/v0.1.1...v0.1.2
179+
[0.1.1]: https://github.com/ianfixes/arduino_ci/compare/v0.1.0...v0.1.1
180+
[0.1.0]: https://github.com/ianfixes/arduino_ci/compare/v0.0.1...v0.1.0
181+
[0.0.1]: https://github.com/ianfixes/arduino_ci/compare/v0.0.0...v0.0.1

CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ Be prepared to write tests to accompany any code you would like to see merged.
1818
## Packaging the Gem
1919

2020
* Merge pull request with new features
21+
* `git stash save` (at least before the gem build step, but easiest here).
2122
* `git pull --rebase`
2223
* Bump the version in lib/arduino_ci/version.rb and change it in README.md (since rubydoc.info doesn't always redirect to the latest version)
2324
* Update the sections of `CHANGELOG.md`
2425
* `git add README.md CHANGELOG.md lib/arduino_ci/version.rb`
2526
* `git commit -m "vVERSION bump"`
2627
* `git tag -a vVERSION -m "Released version VERSION"`
27-
* `git stash save`
2828
* `gem build arduino_ci.gemspec`
2929
* `git stash pop`
3030
* `gem push arduino_ci-VERSION.gem`
3131
* `git push upstream`
3232
* `git push upstream --tags`
33+
* Visit http://www.rubydoc.info/gems/arduino_ci/VERSION to initiate the doc generation process

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci)
2-
[![Build Status](https://travis-ci.org/ifreecarve/arduino_ci.svg)](https://travis-ci.org/ifreecarve/arduino_ci)
2+
[![Build Status](https://travis-ci.org/ianfixes/arduino_ci.svg)](https://travis-ci.org/ianfixes/arduino_ci)
33
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.9)
44

55
# ArduinoCI Ruby gem (`arduino_ci`)
66

7-
[Arduino CI](https://github.com/ifreecarve/arduino_ci) is a Ruby gem for executing Continuous Integration (CI) tests on an Arduino library -- both locally and as part of a service like Travis CI.
7+
[Arduino CI](https://github.com/ianfixes/arduino_ci) is a Ruby gem for executing Continuous Integration (CI) tests on an Arduino library -- both locally and as part of a service like Travis CI.
88

99

1010
## Installation In Your GitHub Project And Using Travis CI
@@ -373,12 +373,12 @@ This software is in alpha. But [SampleProjects/DoSomething](SampleProjects/DoSo
373373
374374
* The Arduino library is not fully mocked.
375375
* I don't have preprocessor defines for all the Arduino board flavors
376-
* https://github.com/ifreecarve/arduino_ci/issues
376+
* https://github.com/ianfixes/arduino_ci/issues
377377
378378
379379
## Author
380380
381-
This gem was written by Ian Katz (ifreecarve@gmail.com) in 2018. It's released under the Apache 2.0 license.
381+
This gem was written by Ian Katz (ianfixes@gmail.com) in 2018. It's released under the Apache 2.0 license.
382382
383383
384384
## See Also

SampleProjects/DoSomething/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ This test defines one `unittest` (a macro provided by `ArduionUnitTests.h`), cal
106106

107107
# Credits
108108

109-
This Arduino example was created in January 2018 by Ian Katz <ifreecarve@gmail.com>.
109+
This Arduino example was created in January 2018 by Ian Katz <ianfixes@gmail.com>.

SampleProjects/DoSomething/library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ maintainer=Ian Katz <[email protected]>
55
sentence=Arduino CI unit test example
66
paragraph=A skeleton library demonstrating CI and unit tests
77
category=Other
8-
url=https://github.com/ifreecarve/arduino_ci/SampleProjects/DoSomething
8+
url=https://github.com/ianfixes/arduino_ci/SampleProjects/DoSomething
99
architectures=avr
1010
includes=do-something.h

SampleProjects/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
Arduino Sample Projects
22
=======================
33

4-
This directory contains example projects that are meant to be built with this gem. Except "TestSomething". That one's just a beater for CI testing and includes some tests that are designed to fail (to test negative inputs).
4+
This directory contains example projects that are meant to be built with this gem.
5+
6+
* "DoSomething" is a bare implementation of a library with a test. Test files prefixed with "bad-" are expected to fail; this is checked as part of the testing on arduino_ci itself.
7+
* "TestSomething" contains a minimial library, but tests for all the mock features of arduino_ci.

SampleProjects/TestSomething/library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ maintainer=Ian Katz <[email protected]>
55
sentence=Arduino CI unit test example
66
paragraph=A skeleton library demonstrating CI and unit tests
77
category=Other
8-
url=https://github.com/ifreecarve/arduino_ci/SampleProjects/TestSomething
8+
url=https://github.com/ianfixes/arduino_ci/SampleProjects/TestSomething
99
architectures=avr,esp8266
1010
includes=do-something.h

arduino_ci.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Gem::Specification.new do |spec|
88
spec.version = ArduinoCI::VERSION
99
spec.licenses = ['Apache-2.0']
1010
spec.authors = ["Ian Katz"]
11-
spec.email = ["ifreecarve@gmail.com"]
11+
spec.email = ["ianfixes@gmail.com"]
1212

1313
spec.summary = "Tools for building and unit testing Arduino libraries"
1414
spec.description = spec.description
15-
spec.homepage = "http://github.com/ifreecarve/arduino_ci"
15+
spec.homepage = "http://github.com/ianfixes/arduino_ci"
1616

1717
spec.bindir = "exe"
1818
rejection_regex = %r{^(test|spec|features)/}

lib/arduino_ci.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require "arduino_ci/ci_config"
55

66
# ArduinoCI contains classes for automated testing of Arduino code on the command line
7-
# @author Ian Katz <ifreecarve@gmail.com>
7+
# @author Ian Katz <ianfixes@gmail.com>
88
module ArduinoCI
99

1010
end

lib/arduino_ci/arduino_downloader.rb

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
DOWNLOAD_ATTEMPTS = 3
2+
3+
module ArduinoCI
4+
5+
# Manage the OS-specific download & install of Arduino
6+
class ArduinoDownloader
7+
8+
def initialize(desired_ide_version)
9+
@desired_ide_version = desired_ide_version
10+
end
11+
12+
# Provide guidelines to the implementer of this class
13+
def must_implement(method)
14+
raise NoMethodError("#{self.class.name} failed to implement ArduinoDownloader.#{method}")
15+
end
16+
17+
# Make any preparations or run any checks prior to making changes
18+
# @return [string] Error message, or nil if success
19+
def prepare
20+
nil
21+
end
22+
23+
# The autolocated executable of the installation
24+
#
25+
# @return [string] or nil
26+
def self.autolocation
27+
# Arbitrarily, I'm going to pick the force installed location first
28+
# if it exists. I'm not sure why we would have both, but if we did
29+
# a force install then let's make sure we actually use it.
30+
locations = [self.force_installed_executable, self.existing_executable]
31+
locations.each do |loc|
32+
next if loc.nil?
33+
next unless File.exist? loc
34+
return loc
35+
end
36+
nil
37+
end
38+
39+
# The executable Arduino file in an existing installation, or nil
40+
# @return [string]
41+
def self.existing_executable
42+
must_implement(__method__)
43+
end
44+
45+
# The executable Arduino file in a forced installation, or nil
46+
# @return [string]
47+
def self.force_installed_executable
48+
must_implement(__method__)
49+
end
50+
51+
# The technology that will be used to complete the download
52+
# (for logging purposes)
53+
# @return [string]
54+
def downloader
55+
must_implement(__method__)
56+
end
57+
58+
# The technology that will be used to extract the download
59+
# (for logging purposes)
60+
# @return [string]
61+
def extracter
62+
must_implement(__method__)
63+
end
64+
65+
# The URL of the desired IDE package (zip/tar/etc) for this platform
66+
# @return [string]
67+
def package_url
68+
"https://downloads.arduino.cc/#{package_file}"
69+
end
70+
71+
# The local file (dir) name of the desired IDE package (zip/tar/etc)
72+
# @return [string]
73+
def package_file
74+
must_implement(__method__)
75+
end
76+
77+
# The local filename of the extracted IDE package (zip/tar/etc)
78+
# @return [string]
79+
def extracted_file
80+
must_implement(__method__)
81+
end
82+
83+
# @return [String] The location where a forced install will go
84+
def self.force_install_location
85+
File.join(ENV['HOME'], 'arduino_ci_ide')
86+
end
87+
88+
# Download the package_url to package_file, and maybe print a line of dots......
89+
# @return [bool] whether successful
90+
def download
91+
must_implement(__method__)
92+
end
93+
94+
# Extract the package_file to extracted_file
95+
# @return [bool] whether successful
96+
def extract
97+
must_implement(__method__)
98+
end
99+
100+
# Move the extracted package file from extracted_file to the force_install_location
101+
# @return [bool] whether successful
102+
def install
103+
must_implement(__method__)
104+
end
105+
106+
# Forcibly install Arduino on linux from the web
107+
# @return [bool] Whether the command succeeded
108+
def execute
109+
error_preparing = prepare
110+
unless error_preparing.nil?
111+
puts "Arduino force-install failed preparation: #{error_preparing}"
112+
return false
113+
end
114+
115+
attempts = 0
116+
117+
loop do
118+
if File.exist? package_file
119+
puts "Arduino package seems to have been downloaded already" if attempts.zero?
120+
break
121+
elsif attempts >= DOWNLOAD_ATTEMPTS
122+
break puts "After #{DOWNLOAD_ATTEMPTS} attempts, failed to download #{package_url}"
123+
else
124+
puts "Attempting to download Arduino package with #{downloader}"
125+
download
126+
end
127+
attempts += 1
128+
end
129+
130+
if File.exist? extracted_file
131+
puts "Arduino package seems to have been extracted already"
132+
elsif File.exist? package_file
133+
puts "Extracting archive with #{extracter}"
134+
extract
135+
end
136+
137+
if File.exist? self.class.force_install_location
138+
puts "Arduino package seems to have been installed already"
139+
elsif File.exist? extracted_file
140+
install
141+
else
142+
puts "Arduino force-install failed"
143+
end
144+
145+
File.exist? self.class.force_install_location
146+
end
147+
148+
end
149+
end
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
require "arduino_ci/arduino_downloader_posix"
2+
3+
USE_BUILDER = false
4+
5+
module ArduinoCI
6+
7+
# Manage the linux download & install of Arduino
8+
class ArduinoDownloaderLinux < ArduinoDownloaderPosix
9+
10+
# The local filename of the desired IDE package (zip/tar/etc)
11+
# @return [string]
12+
def package_file
13+
"#{extracted_file}-linux64.tar.xz"
14+
end
15+
16+
# The technology that will be used to extract the download
17+
# (for logging purposes)
18+
# @return [string]
19+
def extracter
20+
"tar"
21+
end
22+
23+
# Extract the package_file to extracted_file
24+
# @return [bool] whether successful
25+
def extract
26+
system(extracter, "xf", package_file)
27+
end
28+
29+
# The local file (dir) name of the extracted IDE package (zip/tar/etc)
30+
# @return [string]
31+
def extracted_file
32+
"arduino-#{@desired_ide_version}"
33+
end
34+
35+
# The executable Arduino file in an existing installation, or nil
36+
# @return [string]
37+
def self.existing_executable
38+
if USE_BUILDER
39+
# builder_name = "arduino-builder"
40+
# cli_place = Host.which(builder_name)
41+
# unless cli_place.nil?
42+
# ret = ArduinoCmdLinuxBuilder.new
43+
# ret.base_cmd = [cli_place]
44+
# return ret
45+
# end
46+
end
47+
Host.which("arduino")
48+
end
49+
50+
# The executable Arduino file in a forced installation, or nil
51+
# @return [string]
52+
def self.force_installed_executable
53+
if USE_BUILDER
54+
# forced_builder = File.join(ArduinoCmdLinuxBuilder.force_install_location, builder_name)
55+
# if File.exist?(forced_builder)
56+
# ret = ArduinoCmdLinuxBuilder.new
57+
# ret.base_cmd = [forced_builder]
58+
# return ret
59+
# end
60+
end
61+
forced_arduino = File.join(self.force_install_location, "arduino")
62+
return forced_arduino if File.exist? forced_arduino
63+
nil
64+
end
65+
66+
end
67+
end

0 commit comments

Comments
 (0)