Skip to content

Commit cdd6c34

Browse files
committed
ci(Appveyor): Add checker for Travis to view Appveyor test status
1 parent 86e6179 commit cdd6c34

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ install:
2222
script:
2323
- bundle exec rake
2424

25+
before_deploy:
26+
- bundle exec rake test:appveyor_status
27+
2528
deploy:
2629
- provider: script
2730
script: npx travis-deploy-once "npx semantic-release"

rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ namespace :test do
2828
t.warning = true
2929
t.deps = %i[dotenv rubocop]
3030
end
31+
32+
Rake::TestTask.new do |t|
33+
t.name = "appveyor_status"
34+
t.description = "Checks to ensure that AppVeyor tests pass before deploying from Travis"
35+
t.libs << "test"
36+
t.test_files = FileList["test/appveyor_status.rb"]
37+
t.verbose = false
38+
t.warning = false
39+
end
3140
end
3241

3342
desc "Run unit & integration tests"

test/appveyor_status.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
require("minitest/reporters")
4+
require("minitest/autorun")
5+
require("minitest/retry")
6+
require("http")
7+
require("json")
8+
9+
Minitest::Retry.use!
10+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true), Minitest::Reporters::SpecReporter.new]
11+
12+
# Test to run from Travis to ensure that AppVeyor tests pass before attempting to deploy to RubyGems
13+
class AppVeyorStatusTest < Minitest::Test
14+
def test_appveyor_status
15+
skip "Branch is NOT master and/or Ruby != 2.5.1, so AppVeyor check before deployment will not be run." if ENV["TRAVIS_BRANCH"] != "master" || ENV["TRAVIS_RUBY_VERSION"] != "2.5.1"
16+
client = HTTP::Client.new
17+
status = JSON.parse(client.get("https://ci.appveyor.com/api/projects/maxnussbaum/ruby-sdk").body.to_s)["build"]["status"]
18+
while status != "success" && status != "failed" && status != "cancelled"
19+
sleep(3)
20+
status = JSON.parse(client.get("https://ci.appveyor.com/api/projects/maxnussbaum/ruby-sdk").body.to_s)["build"]["status"]
21+
end
22+
if status == "success"
23+
assert(true)
24+
else
25+
assert(false, "AppVeyor tests have NOT passed! Please ensure that AppVeyor passes before deploying")
26+
end
27+
end
28+
end

test/test_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424

2525
Minitest::Retry.use!
2626

27-
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::HtmlReporter.new] if ENV["CI"].nil?
28-
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new) if ENV["CI"]
27+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true, slow_count: 10), Minitest::Reporters::SpecReporter.new, Minitest::Reporters::HtmlReporter.new] if ENV["CI"].nil?
28+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true, slow_count: 10), Minitest::Reporters::SpecReporter.new] if ENV["CI"]

0 commit comments

Comments
 (0)