From 0d2204860f3647215039014ebb5926b3d389df0d Mon Sep 17 00:00:00 2001 From: jywarren Date: Mon, 10 Jun 2019 20:14:12 -0400 Subject: [PATCH 1/7] screenshots in system tests --- .travis.yml | 11 +++++------ Dangerfile | 16 ++++++++++++++++ Gemfile | 1 + containers/docker-compose-testing.yml | 16 ++++++++++++++++ test/system/screenshots_test.rb | 13 +++++++++++++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 test/system/screenshots_test.rb diff --git a/.travis.yml b/.travis.yml index ddb51aecd7..b544435aca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 '' > 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 diff --git a/Dangerfile b/Dangerfile index 3a88055706..c61cd9107c 100644 --- a/Dangerfile +++ b/Dangerfile @@ -61,3 +61,19 @@ rescue => ex fail "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.new project_id: "public-lab" +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 + file.acl.public! + images << "

#{file.name}

" +end + +screenshots = "
Screenshots :camera_flash: (click to expand)" + images.join + "
" +markdown(screenshots) diff --git a/Gemfile b/Gemfile index 2d9248b3cc..58f1ab2d41 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/containers/docker-compose-testing.yml b/containers/docker-compose-testing.yml index 95d598c27e..8b3c065bdc 100644 --- a/containers/docker-compose-testing.yml +++ b/containers/docker-compose-testing.yml @@ -27,6 +27,22 @@ 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} + - HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL} + - GITHUB_ACTION=${GITHUB_ACTION} + - GITHUB_TOKEN=${GITHUB_TOKEN} + - GITHUB_REPOSITORY=${GITHUB_REPOSITORY} + - GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} + - GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} + - GOOGLE_CLOUD_KEYFILE_JSON=${GOOGLE_CLOUD_KEYFILE_JSON} + - GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS} + - GOOGLE_APPLICATION_CREDENTIALS_JSON=${GOOGLE_APPLICATION_CREDENTIALS_JSON} + - QT_QPA_PLATFORM=${QT_QPA_PLATFORM} links: - redis volumes: diff --git a/test/system/screenshots_test.rb b/test/system/screenshots_test.rb new file mode 100644 index 0000000000..5fcd4b3ce8 --- /dev/null +++ b/test/system/screenshots_test.rb @@ -0,0 +1,13 @@ +require "application_system_test_case" + +class ScreenshotsTest < ApplicationSystemTestCase + 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", wait: 10 + + take_screenshot + end +end From 47fa616092e1f13a9a21bdd9373906161d49f623 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 11 Jun 2019 17:55:06 -0400 Subject: [PATCH 2/7] more screenshots --- test/system/screenshots_test.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/system/screenshots_test.rb b/test/system/screenshots_test.rb index 5fcd4b3ce8..664f9f1dc9 100644 --- a/test/system/screenshots_test.rb +++ b/test/system/screenshots_test.rb @@ -1,13 +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", wait: 10 + 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 From 09e372400ddcd4603af00ec3525f4c47c9ef95bc Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 12 Jun 2019 10:16:24 -0400 Subject: [PATCH 3/7] Google::Cloud::Storage.anonymous --- Dangerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index c61cd9107c..47967ef097 100644 --- a/Dangerfile +++ b/Dangerfile @@ -64,7 +64,7 @@ end # Store screenshots in Google Cloud require "google/cloud/storage" -storage = Google::Cloud::Storage.new project_id: "public-lab" +storage = Google::Cloud::Storage.anonymous # don't rely on a key credential bucket = storage.bucket "plots2-screenshots" Encoding.default_external = 'UTF-8' From c6feb83d19cc597a58b7f347caa0da8a0724a3ac Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 12 Jun 2019 10:20:29 -0400 Subject: [PATCH 4/7] Update Dangerfile --- Dangerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index 47967ef097..fccc410cce 100644 --- a/Dangerfile +++ b/Dangerfile @@ -71,7 +71,6 @@ 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 - file.acl.public! images << "

#{file.name}

" end From 22111d5b4ae67ba6f0fc369eec58b3a9505ce8df Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 12 Jun 2019 10:23:01 -0400 Subject: [PATCH 5/7] Update docker-compose-testing.yml --- containers/docker-compose-testing.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/containers/docker-compose-testing.yml b/containers/docker-compose-testing.yml index 8b3c065bdc..4769a67ae2 100644 --- a/containers/docker-compose-testing.yml +++ b/containers/docker-compose-testing.yml @@ -33,15 +33,12 @@ services: - CI=${CI} - TRAVIS=${TRAVIS} - CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION} - - HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL} +# - HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL} - GITHUB_ACTION=${GITHUB_ACTION} - GITHUB_TOKEN=${GITHUB_TOKEN} - GITHUB_REPOSITORY=${GITHUB_REPOSITORY} - GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} - GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} - - GOOGLE_CLOUD_KEYFILE_JSON=${GOOGLE_CLOUD_KEYFILE_JSON} - - GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS} - - GOOGLE_APPLICATION_CREDENTIALS_JSON=${GOOGLE_APPLICATION_CREDENTIALS_JSON} - QT_QPA_PLATFORM=${QT_QPA_PLATFORM} links: - redis From e3b92f32694d39f4b9d8b31b6a6e671f1967593e Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 12 Jun 2019 11:43:55 -0400 Subject: [PATCH 6/7] HAS_JOSH_K_SEAL_OF_APPROVAL --- containers/docker-compose-testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/containers/docker-compose-testing.yml b/containers/docker-compose-testing.yml index 4769a67ae2..acb9365b3d 100644 --- a/containers/docker-compose-testing.yml +++ b/containers/docker-compose-testing.yml @@ -33,7 +33,8 @@ services: - CI=${CI} - TRAVIS=${TRAVIS} - CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION} -# - HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL} + # used to tell if we are in a Travis environment: + - HAS_JOSH_K_SEAL_OF_APPROVAL=${HAS_JOSH_K_SEAL_OF_APPROVAL} - GITHUB_ACTION=${GITHUB_ACTION} - GITHUB_TOKEN=${GITHUB_TOKEN} - GITHUB_REPOSITORY=${GITHUB_REPOSITORY} From f5674dd8c800c327cd20a2cbbb0ecd297aa0c108 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 12 Jun 2019 12:15:02 -0400 Subject: [PATCH 7/7] change fail to warn in danger junit parsing so if all tests pass, we don't worry --- Dangerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index fccc410cce..6bfdf45208 100644 --- a/Dangerfile +++ b/Dangerfile @@ -58,7 +58,7 @@ 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