canvas-lms/gems
Ethan Vizitei c5988b8cc5 Initial work on getting zeitwerk loader running
refs FOO-1712
flag=none

 - drop bad directories from autoloading (jsx)
 - re-inflect some things that zeitwerk doesn't
   know by default (InstFS, etc)
 - add environment variable trigger for enabling
   zeitwerk loading
 - move samesite transition cookie to app middleware
   so we don't try to reload middleware
 - use zeitwerk.rb shim to pre-load things
   that are not correctly loaded by their own
   gems

TEST PLAN:
  1) everything continues to work fine
  2) for local development, if you use the
     CANVAS_ZEITWERK env var, you get zeitwerk
     autoloading (which is probably still broken)

Change-Id: I55a0db84034133240698bf4ff0cc8d225ec181a6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/260674
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-03-16 19:55:12 +00:00
..
activesupport-suspend_callbacks raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
acts_as_list spec: fix acts_as_list for rails 6.1 2020-12-10 02:59:48 +00:00
adheres_to_policy raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
attachment_fu add # frozen_string_literal: true for embedded gems 2020-10-28 22:08:40 +00:00
autoextend allow ruby 3.0 2020-12-07 18:53:03 +00:00
bookmarked_collection raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
broadcast_policy add # frozen_string_literal: true for embedded gems 2020-10-28 22:08:40 +00:00
canvas_breach_mitigation raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_cache extract canvas::redis to canvas_cache 2021-03-02 14:38:55 +00:00
canvas_cassandra move database_builder to canvas_cassandra 2021-02-25 15:19:20 +00:00
canvas_color raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_crummy raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_dynamodb raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_errors pull canvas_errors out into a gem 2021-03-05 17:00:50 +00:00
canvas_ext raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_http Revert "dig output on inst-fs resolution failure" 2021-03-08 20:33:49 +00:00
canvas_i18nliner fix specs for gems/canvas_i18nliner 2021-03-10 21:06:57 +00:00
canvas_kaltura raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_mimetype_fu enable to submit homework assignment zip files from windows 2021-03-15 17:19:41 +00:00
canvas_panda_pub explicitly drop connections from async threads 2021-01-07 16:52:42 +00:00
canvas_partman raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_quiz_statistics raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_sanitize avoid duplicate const warning in canvas_sanitize gem 2021-03-16 15:32:25 +00:00
canvas_security treat openssl cipher error as auth failure 2021-03-05 18:36:54 +00:00
canvas_slug add # frozen_string_literal: true for embedded gems 2020-10-28 22:08:40 +00:00
canvas_sort raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_stringex add # frozen_string_literal: true for embedded gems 2020-10-28 22:08:40 +00:00
canvas_text_helper raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_time raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
canvas_unzip add # frozen_string_literal: true for embedded gems 2020-10-28 22:08:40 +00:00
config_file extract canvas::redis to canvas_cache 2021-03-02 14:38:55 +00:00
csv_diff raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
diigo raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
dr_diff stage 1: audits engine extract 2021-03-04 20:27:06 +00:00
dynamic_settings default dynamic_settings logger to Rails.logger 2021-03-04 20:40:02 +00:00
event_stream move EventStreamLogger to event_stream gem 2021-03-03 19:14:24 +00:00
google_drive gracefully handle un-downloadable drive entries 2020-12-17 18:56:57 +00:00
html_text_helper raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
i18n_extraction raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
i18n_tasks sort auto-generated en.yml locale file 2021-03-10 17:11:26 +00:00
incoming_mail_processor raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
json_token raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
linked_in raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
live_events raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
lti-advantage raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
lti_outbound raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
multipart raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
paginated_collection raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
plugins Initial work on getting zeitwerk loader running 2021-03-16 19:55:12 +00:00
request_context treat openssl cipher error as auth failure 2021-03-05 18:36:54 +00:00
rubocop-canvas raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
stringify_ids raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
tatl_tael modernize canvas_quizzes 2021-01-14 22:45:10 +00:00
turnitin_api raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
twitter raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
utf8_cleaner raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
workflow raise bundler minimum requirement 2021-02-19 22:49:02 +00:00
README.md extract ConfigFile to gem 2021-02-23 21:18:20 +00:00
test_all_gems.sh Alpine canvas-lms based image 2020-07-15 17:21:56 +00:00

README.md

Gems

This folder is a place to extract modular functionality from canvas. Canvas's Gemfile arrangement is enabled to read gems from this path locally without installing from a remote source. This is valuable for a few reasons:

  • it prevents circular dependencies (bundler won't allow it)
  • modularized code cannot bind to specific domain concepts on canvas models
  • gems can have their specs run independently, without needing to load all of canvas, saving iteration time
  • it allows for eventual build optimization via only running specs for the transitive closure of parents depending on a gem where a change is.
  • it gives ENGINES extracted from canvas (see the "engines" directory) a place to reference code shared with canvas without it being packaged into the canvas monolith directly.

There are some tradeoffs:

  • spreads canvas over more subdirectories, giving some mental overhad to traversing the entire codebase.
  • modular tests necessarily don't test integration with canvas concepts, so solid integration tests in the app are still a requirement.
  • total SERIALIZED build time goes up because each gem loads it's specs in a new process rather than all running within an already booted canvas process.

[TODO] eventually write more on whether we feel like those tradeoffs are good ones, and what the best practices are to leverage this pattern for max-gain/min-pain.

Testing

To test all the gems:

cd gems
./test_all_gems.sh

To test an individual gem

Run ./test.sh inside the gem's folder. This is basically the same as:

cd gems/google_drive
bundle
rspec