From bcb44df0278a9d451c5f9db5fa8add13f6b7606f Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 11 Apr 2021 13:09:38 -0400 Subject: [PATCH 1/7] Upgrade mimemagic Upgrade mimemagic to mitigate licensing concerns --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f13fbf35..1069fc2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -243,7 +243,9 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2020.0512) - mimemagic (0.3.5) + mimemagic (0.3.10) + nokogiri (~> 1) + rake mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.2) From e71ca06323762f3f33e3d947ac78587c163e6ccc Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Sun, 11 Apr 2021 13:23:07 -0400 Subject: [PATCH 2/7] Remove obsolete version of after_sign_in_path_for --- app/controllers/application_controller.rb | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0fdcc0d8..33cc3777 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,22 +29,6 @@ def not_found raise ActionController::RoutingError, 'Not Found' end - def after_sign_in_path_for(resource_or_scope) - if current_user.username.nil? - users_username_path - elsif current_user.stack_exchange_account_id.nil? - authentication_status_path - else - stored_location = nil - begin - stored_location = stored_location_for(resource_or_scope) - rescue # rubocop:disable Lint/HandleExceptions - end - - request.env['omniauth.origin'] || stored_location || root_path - end - end - def redis_log(_msg) # redis = redis(logger: true) # redis.multi do |m| From ad6067772813ef202d8470a67b73364f776bed1e Mon Sep 17 00:00:00 2001 From: Makyen Date: Mon, 12 Apr 2021 16:43:05 -0700 Subject: [PATCH 3/7] GitHub Actions: Start MySQL --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32e709eb..2f8c107a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,6 +103,9 @@ jobs: sudo apt-get install libsqlite3-dev bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 yarn install + - name: Start MySQL + run: | + sudo systemctl start mysql.service - name: Configure run: | mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS From e3b2dd9e074d0648ff86afdd72ea2fbd98eb2c41 Mon Sep 17 00:00:00 2001 From: Makyen Date: Mon, 12 Apr 2021 16:18:20 -0700 Subject: [PATCH 4/7] GitHub Actions: use localhost instead of 127.0.0.1 for database host. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f8c107a..69fbfa0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,7 @@ jobs: database: metasmoke_test username: root password: root - host: 127.0.0.1 + host: localhost port: ${{ job.services.mysql.ports['3306'] }} ' > config/database.yml mkdir -p config && echo 'test: From 6e49c9f240d35453a71c6d6f4f6cfbdb7775eec9 Mon Sep 17 00:00:00 2001 From: Makyen Date: Mon, 12 Apr 2021 18:00:10 -0700 Subject: [PATCH 5/7] Add ACTION_CACHE_VERSION to enable invalidating GitHub Action caches. --- .github/workflows/ci.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69fbfa0d..354e17a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,10 @@ on: env: CIRCLE_ARTIFACTS: /tmp/circleci-artifacts CIRCLE_TEST_REPORTS: /tmp/circleci-test-results + # The actions/cache holds old cache entries for 7 days and has no method of invalidating entries. + # The only thing that can be done is to change the key value to force the cache to miss. + # The ACTION_CACHE_VERSION is just a value to change if we don't want to use previously cached data. + ACTION_CACHE_VERSION: cache_version_1 jobs: rubocop: @@ -39,9 +43,9 @@ jobs: - uses: actions/cache@v2 with: path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + key: ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-gems- + ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}- - name: Install dependencies run: | sudo apt-get install libsqlite3-dev @@ -88,16 +92,16 @@ jobs: uses: actions/cache@v2 with: path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + key: ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-gems- + ${{ runner.os }}-gems-${{ env.ACTION_CACHE_VERSION }}- - name: Cache yarn packages uses: actions/cache@v2 with: path: node_modules - key: ${{ runner.os }}-node-modules-yarn-${{ hashFiles('**/Gemfile.lock') }} + key: ${{ runner.os }}-node-modules-yarn-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-node-modules-yarn- + ${{ runner.os }}-node-modules-yarn-${{ env.ACTION_CACHE_VERSION }}- - name: Install dependencies run: | sudo apt-get install libsqlite3-dev @@ -154,9 +158,9 @@ jobs: - uses: actions/cache@v2 with: path: node_modules - key: ${{ runner.os }}-node-modules-npm-${{ hashFiles('**/Gemfile.lock') }} + key: ${{ runner.os }}-node-modules-npm-${{ env.ACTION_CACHE_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-node-modules-npm- + ${{ runner.os }}-node-modules-npm-${{ env.ACTION_CACHE_VERSION }}- - run: ls - name: Install dependencies run: npm install From 8c24fa6d097962ce213a7d40dd527fe81da1d7b2 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 12 Apr 2021 13:19:58 -0400 Subject: [PATCH 6/7] Backout e71ca06 and delete the appropriate version --- app/controllers/application_controller.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 33cc3777..1b5182ec 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,6 +29,22 @@ def not_found raise ActionController::RoutingError, 'Not Found' end + def after_sign_in_path_for(resource_or_scope) + if current_user.username.nil? + users_username_path + elsif current_user.stack_exchange_account_id.nil? + authentication_status_path + else + stored_location = nil + begin + stored_location = stored_location_for(resource_or_scope) + rescue # rubocop:disable Lint/HandleExceptions + end + + request.env['omniauth.origin'] || stored_location || root_path + end + end + def redis_log(_msg) # redis = redis(logger: true) # redis.multi do |m| @@ -128,8 +144,4 @@ def deduplicate_ajax_requests def location_storable? request.get? && is_navigational_format? && !devise_controller? && !request.xhr? end - - def after_sign_in_path_for(resource) - stored_location_for(resource) || super - end end From d3e63daa07078c4caf48562b8df0e9ec39205892 Mon Sep 17 00:00:00 2001 From: user12986714 <65436504+user12986714@users.noreply.github.com> Date: Mon, 12 Apr 2021 13:28:33 -0400 Subject: [PATCH 7/7] Define store_user_location! method --- app/controllers/application_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b5182ec..bd48bbab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -144,4 +144,8 @@ def deduplicate_ajax_requests def location_storable? request.get? && is_navigational_format? && !devise_controller? && !request.xhr? end + + def store_user_location! + store_location_for(:user, request.fullpath) + end end