Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migrate to common prism setup #421

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ Gemfile.lock

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

prism
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
language: ruby
rvm:
- ruby-head
- 2.7
- 2.6
- 2.5
- 2.4
- jruby-9.2
env:
- version=ruby:2.7
- version=ruby:2.6
- version=ruby:2.5
- version=ruby:2.4
- version=jruby:9.2

gemfile:
- gemfiles/Sinatra_1.gemfile
- gemfiles/Sinatra_2.gemfile
before_script:
- mkdir prism
- mkdir prism/bin
- export PATH=$PATH:$PWD/prism/bin/
- "./test/prism.sh"
install: make install
script: make test
matrix:
allow_failures:
- rvm: ruby-head
fast_finish: true

script: make test-docker

deploy:
provider: rubygems
api_key:
secure: CWlfN170i/fHPrIufHHLWQ0utjuhxf4ELSxKeypIuO2CNTqNMzocDAa2vxMt4XfO6d2wFPV/LC+IHR7i+sp7PKvjRoa4BLUUxjfBNDboc0gGESeUYlAxwsJo0tOVCNmpxgjQKqtPLz/19A/v/xpxLv2Im/9Idqa5ATd06sMDdM8=
gem: sendgrid-ruby
on:
tags: true
rvm: '2.4'
condition: '$BUNDLE_GEMFILE == *"gemfiles/Sinatra_1.gemfile"'
condition: $version=ruby:2.4 AND '$BUNDLE_GEMFILE == *"gemfiles/Sinatra_1.gemfile"'

notifications:
slack:
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG version=ruby:latest
FROM $version

# Needed for jruby
RUN apt-get update \
&& apt-get install -y make git

COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
RUN update-ca-certificates

WORKDIR /app
COPY . .

RUN make install
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.PHONY: install test
.PHONY: install test test-integ test-docker

install:
gem install bundler:2.1.2; bundle install

test:
bundle exec rake spec

test-integ: test

version ?= ruby:latest
test-docker:
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | version=$(version) bash
42 changes: 0 additions & 42 deletions test/prism.sh

This file was deleted.

28 changes: 1 addition & 27 deletions test/sendgrid/test_sendgrid-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,8 @@

class TestAPI < MiniTest::Test

unless File.exist?('/usr/local/bin/prism') || File.exist?(File.join(Dir.pwd, 'prism/bin/prism'))
if RUBY_PLATFORM =~ /mswin|mingw/
puts 'Please download the Windows binary (https://github.com/stoplightio/prism/releases) and place it in your /usr/local/bin directory'
else
puts 'Installing Prism'
IO.popen(['curl', '-s', 'https://raw.githubusercontent.com/stoplightio/prism/master/install.sh']) do |io|
out = io.read
unless system(out)
puts "Error downloading the prism binary, you can try downloading directly here (https://github.com/stoplightio/prism/releases) and place in your /usr/local/bin directory, #{out}"
exit
end
end
end
end

puts 'Activating Prism (~20 seconds)'
@@prism_pid = spawn('prism run --mock --list --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json', [:out, :err] => '/dev/null')
sleep(15)
puts 'Prism started'

def setup
host = "http://localhost:4010"
@sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY", host: host)
end

Minitest.after_run do
Process.kill('TERM', @@prism_pid)
puts 'Prism shut down'
@sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY")
end

def test_init
Expand Down