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

screenshots in system tests #5868

Merged
merged 7 commits into from
Jun 12, 2019
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
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ install:
- docker-compose exec web bash -c "rake db:setup"
- docker-compose exec web bash -c "rake db:migrate"
- docker-compose exec web bash -c "rake assets:precompile"
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then gem install danger danger-junit; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash -c "docker-compose exec web gem install danger danger-junit google-cloud-storage"; fi'

script:
- docker-compose exec web bash -c 'echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /tmp/credentials.json' # needs to be a path to a json file, so we shuffle...
- docker-compose exec web bash -c "CI=TRUE GENERATE_REPORT=true $TASK"
- |
if [ $TASK != "rake test:all" ]; then
- if [ $TASK != "rake test:all" ]; then
echo -e '<?xml version="1.0" encoding="UTF-8"?>' > output.xml;
tail -n +2 -q ./test/reports/TEST*.xml >> output.xml;
fi
- |
if [ $TRAVIS_PULL_REQUEST != "false"; then
danger --verbose;
- if [ $TRAVIS_PULL_REQUEST != "false" ]; then
docker-compose exec web danger --verbose;
fi
17 changes: 16 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ begin
end

rescue => ex
fail "There was an error with Danger bot's Junit parsing: #{ex.message}"
warn "There was an error with Danger bot's Junit parsing: #{ex.message}"
message ex.inspect # view the entire error output in the log
end

# Store screenshots in Google Cloud
require "google/cloud/storage"
storage = Google::Cloud::Storage.anonymous # don't rely on a key credential
bucket = storage.bucket "plots2-screenshots"
Encoding.default_external = 'UTF-8'

images = []
Dir.glob('tmp/screenshots/*') do |item|
file = bucket.create_file item, github.pr_json["number"].to_s + "-" + item.split('/').last
images << "<h3>#{file.name}</h3><p><img src='#{file.public_url}' /></p>"
end

screenshots = "<details><summary>Screenshots :camera_flash: (click to expand)</summary>" + images.join + "</details>"
markdown(screenshots)
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem 'gemoji'
gem 'geocoder'
gem 'geokit-rails'
gem 'georuby', '2.0'
gem "google-cloud-storage"
gem 'grape'
gem 'grape-entity'
gem 'grape-swagger', '~> 0.32.1'
Expand Down
14 changes: 14 additions & 0 deletions containers/docker-compose-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ services:
- RAILS_ENV=${RAILS_ENV}
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- REDIS_URL=redis://redis:6379/0
- DANGER_GITHUB_API_TOKEN=${DANGER_GITHUB_API_TOKEN}
- TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}
- TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG}
- CI=${CI}
- TRAVIS=${TRAVIS}
- CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION}
# used to tell if we are in a Travis environment:
- HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just for demonstration purposes, @icarito ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember off the top of my head why HAS_JOSH_K_SEAL_OF_APPROVAL is needed but it is no invention of mine and it seems some libs check for it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- GITHUB_ACTION=${GITHUB_ACTION}
- GITHUB_TOKEN=${GITHUB_TOKEN}
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
- GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH}
- GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}
- QT_QPA_PLATFORM=${QT_QPA_PLATFORM}
links:
- redis
volumes:
Expand Down
32 changes: 32 additions & 0 deletions test/system/screenshots_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "application_system_test_case"

class ScreenshotsTest < ApplicationSystemTestCase
Capybara.default_max_wait_time = 60

test 'front page with navbar search autocomplete' do
visit '/'
fill_in("searchform_input", with: "Canon")
assert_selector ".typeahead li", text: "Canon A1200 IR conversion at PLOTS Barnraising at LUMCON"
take_screenshot
end

test 'wiki' do
visit '/wiki'
take_screenshot
end

test 'tags' do
visit '/tags'
take_screenshot
end

test 'blog' do
visit '/blog'
take_screenshot
end

test 'people' do
visit '/people'
take_screenshot
end
end