DEV: Remove the remaining ENV["TRAVIS"] usage (#10041)

DEV: Remove the remaining ENV[“TRAVIS”] usage (#10041)

diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake
index 47af6ba..249ca99 100644
--- a/lib/tasks/docker.rake
+++ b/lib/tasks/docker.rake
@@ -58,9 +58,9 @@ desc 'Run all tests (JS and code in a standalone environment)'
 task 'docker:test' do
   begin
     @good = true
+
     unless ENV['SKIP_LINT']
       @good &&= run_or_fail("yarn install")
-      puts "travis_fold:start:lint" if ENV["TRAVIS"]
       puts "Running linters/prettyfiers"
       puts "eslint #{`yarn eslint -v`}"
       puts "prettier #{`yarn prettier -v`}"
@@ -93,11 +93,9 @@ task 'docker:test' do
           @good &&= run_or_fail('yarn prettier --list-different "plugins/**/*.scss" "plugins/**/*.es6"')
         end
       end
-      puts "travis_fold:end:lint" if ENV["TRAVIS"]
     end
 
     unless ENV['SKIP_TESTS']
-      puts "travis_fold:start:prepare_tests" if ENV["TRAVIS"]
       puts "Cleaning up old test tmp data in tmp/test_data"
       `rm -fr tmp/test_data && mkdir -p tmp/test_data/redis && mkdir tmp/test_data/pg`
 
@@ -155,11 +153,7 @@ task 'docker:test' do
         @good &&= run_or_fail("#{command_prefix}bundle exec rake parallel:migrate")
       end
 
-      puts "travis_fold:end:prepare_tests" if ENV["TRAVIS"]
-
       unless ENV["JS_ONLY"]
-        puts "travis_fold:start:ruby_tests" if ENV["TRAVIS"]
-
         if ENV['WARMUP_TMP_FOLDER']
           run_or_fail('bundle exec rspec ./spec/requests/groups_controller_spec.rb')
         end
@@ -210,13 +204,11 @@ task 'docker:test' do
             @good &&= run_or_fail("#{fail_fast} bundle exec rake plugin:spec")
           end
         end
-        puts "travis_fold:end:ruby_tests" if ENV["TRAVIS"]
       end
 
       unless ENV["RUBY_ONLY"]
         js_timeout = ENV["JS_TIMEOUT"].presence || 900_000 # 15 minutes
 
-        puts "travis_fold:start:js_tests" if ENV["TRAVIS"]
         unless ENV["SKIP_CORE"]
           @good &&= run_or_fail("bundle exec rake qunit:test['#{js_timeout}']")
           @good &&= run_or_fail("bundle exec rake qunit:test['#{js_timeout}','/wizard/qunit']")
@@ -229,12 +221,9 @@ task 'docker:test' do
             @good &&= run_or_fail("bundle exec rake plugin:qunit['*','#{js_timeout}']")
           end
         end
-        puts "travis_fold:end:js_tests" if ENV["TRAVIS"]
       end
     end
-
   ensure
-    puts "travis_fold:start:terminating" if ENV["TRAVIS"]
     puts "Terminating"
 
     if ENV['PAUSE_ON_TERMINATE']
@@ -246,11 +235,7 @@ task 'docker:test' do
     Process.kill("TERM", @pg_pid) if @pg_pid
     Process.wait @redis_pid if @redis_pid
     Process.wait @pg_pid if @pg_pid
-    puts "travis_fold:end:terminating" if ENV["TRAVIS"]
-  end
-
-  if !@good
-    exit 1
   end
 
+  exit 1 unless @good
 end
diff --git a/script/docker_test.rb b/script/docker_test.rb
index 3696a53..db73d53 100644
--- a/script/docker_test.rb
+++ b/script/docker_test.rb
@@ -8,8 +8,6 @@
 # => RUN_SMOKE_TESTS  executes the smoke tests instead of the regular tests from docker.rake
 # See lib/tasks/docker.rake and lib/tasks/smoke_test.rake for more information
 
-puts "travis_fold:end:starting_docker_container" if ENV["TRAVIS"]
-
 def log(message)
   puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}"
 end
@@ -22,24 +20,17 @@ def run_or_fail(command)
 end
 
 unless ENV['NO_UPDATE']
-  puts "travis_fold:start:pulling_latest_discourse" if ENV["TRAVIS"]
-
   run_or_fail("git reset --hard")
-
   run_or_fail("git fetch")
 
   checkout = ENV['COMMIT_HASH'] || "FETCH_HEAD"
   run_or_fail("LEFTHOOK=0 git checkout #{checkout}")
 
-  puts "travis_fold:end:pulling_latest_discourse" if ENV["TRAVIS"]
-  puts "travis_fold:start:bundle" if ENV["TRAVIS"]
-
   run_or_fail("bundle")
-
-  puts "travis_fold:end:bundle" if ENV["TRAVIS"]
 end
 
 log("Running tests")
+
 if ENV['RUN_SMOKE_TESTS']
   run_or_fail("bundle exec rake smoke:test")
 else
diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb
index e90029b..bf73606 100644
--- a/spec/models/optimized_image_spec.rb
+++ b/spec/models/optimized_image_spec.rb
@@ -6,31 +6,29 @@ describe OptimizedImage do
   let(:upload) { build(:upload) }
   before { upload.id = 42 }
 
-  unless ENV["TRAVIS"]
-    describe '.crop' do
-      it 'should produce cropped images (requires ImageMagick 7)' do
-        tmp_path = "/tmp/cropped.png"
+  describe '.crop' do
+    it 'should produce cropped images (requires ImageMagick 7)' do
+      tmp_path = "/tmp/cropped.png"
 
-        begin
-          OptimizedImage.crop(
-            "#{Rails.root}/spec/fixtures/images/logo.png",
-            tmp_path,
-            5,
-            5
-          )
+      begin
+        OptimizedImage.crop(
+          "#{Rails.root}/spec/fixtures/images/logo.png",
+          tmp_path,
+          5,
+          5
+        )
 
-          # we don't want to deal with something new here every time image magick
-          # is upgraded or pngquant is upgraded, lets just test the basics ...
-          # cropped image should be less than 120 bytes
+        # we don't want to deal with something new here every time image magick
+        # is upgraded or pngquant is upgraded, lets just test the basics ...
+        # cropped image should be less than 120 bytes
 
-          cropped_size = File.size(tmp_path)
+        cropped_size = File.size(tmp_path)
 
-          expect(cropped_size).to be < 120
-          expect(cropped_size).to be > 50
+        expect(cropped_size).to be < 120
+        expect(cropped_size).to be > 50
 
-        ensure
-          File.delete(tmp_path) if File.exists?(tmp_path)
-        end
+      ensure
+        File.delete(tmp_path) if File.exists?(tmp_path)
       end
     end
 
diff --git a/spec/requests/user_avatars_controller_spec.rb b/spec/requests/user_avatars_controller_spec.rb
index 4f639fd..e94774d 100644
--- a/spec/requests/user_avatars_controller_spec.rb
+++ b/spec/requests/user_avatars_controller_spec.rb
@@ -24,48 +24,45 @@ describe UserAvatarsController do
       after do
         FileUtils.rm(Discourse.store.path_for(upload))
       end
-      # travis is not good here, no image magick
-      if !ENV["TRAVIS"]
-        let :upload do
-          File.open(file_from_fixtures("cropped.png")) do |f|
-            UploadCreator.new(
-              f,
-              "test.png"
-            ).create_for(-1)
-          end
-        end
 
-        let :user do
-          user = Fabricate(:user)
-          user.user_avatar.update_columns(custom_upload_id: upload.id)
-          user.update_columns(uploaded_avatar_id: upload.id)
-          user
+      let :upload do
+        File.open(file_from_fixtures("cropped.png")) do |f|
+          UploadCreator.new(
+            f,
+            "test.png"
+          ).create_for(-1)
         end
+      end
+
+      let :user do
+        user = Fabricate(:user)
+        user.user_avatar.update_columns(custom_upload_id: upload.id)
+        user.update_columns(uploaded_avatar_id: upload.id)
+        user
+      end
 
-        it 'automatically corrects bad avatar extensions' do
-          orig = Discourse.store.path_for(upload)
+      it 'automatically corrects bad avatar extensions' do
+        orig = Discourse.store.path_for(upload)
 
-          upload.update_columns(
-            original_filename: 'bob.jpg',
-            extension: 'jpg',
-            url: upload.url + '.jpg'
-          )
+        upload.update_columns(
+          original_filename: 'bob.jpg',
+          extension: 'jpg',
+          url: upload.url + '.jpg'
+        )
 
-          # at this point file is messed up
-          FileUtils.mv(orig, Discourse.store.path_for(upload))
+        # at this point file is messed up
+        FileUtils.mv(orig, Discourse.store.path_for(upload))
 
-          SiteSetting.avatar_sizes = "50"
+        SiteSetting.avatar_sizes = "50"
 
-          get "/user_avatar/default/#{user.username}/50/#{upload.id}.png"
+        get "/user_avatar/default/#{user.username}/50/#{upload.id}.png"
 

[... diff too long, it was truncated ...]

GitHub sha: 78aff841

1 Like

This commit appears in #10041 which was approved by eviltrout. It was merged by CvX.

This is used by GitHub - discourse/discourse-plugin-ci: A repository containing scripts for continuous integration testing of plugins, which is still used by a lot of plugins. At a glance, official plugins using it include assign, chat-integration, whos-online, anonymous-moderators, auto-deactivate, canned-replies and probably more.

Can we keep this for now, to give time for us to migrate those things to github actions and deprecate discourse-plugin-ci?

2 Likes

(Referring mostly to the log folding, rather than the core spec changes)

Reverted. Revert "DEV: Remove the remaining ENV["TRAVIS"] usage (#10041)" · discourse/discourse@669c940 · GitHub

Adding this commit to my plugin CI todo list, so I can remember to re-revert when those plugins are on GitHub Actions.

2 Likes