Slide 1

Slide 1 text

Laying the Cultural and Technical Foundation for Big Rails RailsConf, May 2022 Alex Evanczuk

Slide 2

Slide 2 text

Thank you to those who have helped maintain and contribute to Rails. Thank you to those who have helped put together this conference.

Slide 3

Slide 3 text

About Me We’re hiring! https://gusto.com/careers For questions, feedback, or info on working at Gusto: [email protected]

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

A Story of Growing Complexity at Gusto

Slide 6

Slide 6 text

Is this story familiar to you? There’s something we can do about it.

Slide 7

Slide 7 text

Big Rails

Slide 8

Slide 8 text

What is Big Rails? A system of sociotechnical tools, practices, and conventions that scale Rails development in terms of lifespan, number of contributors, and complexity. A Definition Accountability and Ownership Clear Boundaries Thoughtful Dependency Management Gradual Adoption Intentionally Curated and Sustainable Feedback Loops Major Principles

Slide 9

Slide 9 text

Accountability and Ownership

Slide 10

Slide 10 text

module PayrollSyncer def self.sync_deductions! raise "I am an error" end end

Slide 11

Slide 11 text

github.com/bigrails/code_ownership github.com/bigrails/code-ownership-vscode github.com/bigrails/bigrails-teams # config/teams/payroll.yml name: Payroll slack: handle: '@payroll-team' room_for_robots: '#payroll-notifications' room_for_humans: '#payroll’ github: team: '@Gusto/payroll' owned_globs: - app/services/payroll_syncer.rb team = Teams.find(‘Payroll') CodeOwnership.for_file('app/services/payroll_syncer.rb') == team CodeOwnership.for_class(PayrollSyncer) == team begin PayrollSyncer.sync_deductions! rescue => ex CodeOwnership.for_backtrace(ex.backtrace) == team end

Slide 12

Slide 12 text

Clear Boundaries and Dependency Management

Slide 13

Slide 13 text

app/ models/ benefits/ payroll/ hr/ views/ benefits/ payroll/ hr/ controllers/ benefits/ payroll/ hr/ services/ benefits/ payroll/ hr/

Slide 14

Slide 14 text

app/ models/ benefits/ payroll/ hr/ views/ benefits/ payroll/ hr/ controllers/ benefits/ payroll/ hr/ services/ benefits/ payroll/ hr/

Slide 15

Slide 15 text

app/ models/ benefits/ payroll/ hr/ views/ benefits/ payroll/ hr/ controllers/ benefits/ payroll/ hr/ services/ benefits/ payroll/ hr/ github.com/bigrails/stimpack packs/ benefits/ models/ views/ controllers/ services/ payroll/ models/ views/ controllers/ services/ hr/ models/ views/ controllers/ services/

Slide 16

Slide 16 text

With domain-based organization, how can we now systematically manage the relationship between those domains?

Slide 17

Slide 17 text

Packwerk

Slide 18

Slide 18 text

packs/ benefits/ models/ views/ controllers/ services/ + package.yml payroll/ models/ views/ controllers/ services/ + package.yml hr/ models/ views/ controllers/ services/ + package.yml # packs/benefits/package.yml enforce_dependencies: true enforce_privacy: true dependencies: - packs/payroll metadata: owner: Enrollments github.com/shopify/packwerk

Slide 19

Slide 19 text

packs/ benefits/ models/ views/ controllers/ services/ + public/ + package.yml payroll/ models/ views/ controllers/ services/ + public/ + package.yml hr/ models/ views/ controllers/ services/ + public/ + package.yml # packs/benefits/package.yml enforce_dependencies: true enforce_privacy: true dependencies: - packs/payroll metadata: owner: Enrollments github.com/shopify/packwerk

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

# packs/benefits/app/services/benefits.rb module Benefits def self.some_method HrHelper.inform_administrator! end end # packs/benefits/deprecated_references.yml --- packs/hr: "::HrHelper": violations: - privacy - dependency files: - packs/benefits/app/services/benefits.rb

Slide 27

Slide 27 text

Okay… but what about gems and engines? github.com/bigrails/package_protections Gems/Engines Packages Supports gradual modularity ❌ ✅ Inexpensive to change boundaries ❌ ✅ Supports distribution ✅ ❌ Supports versioning ✅ ❌ Fast tests ✅ ✅* Supports strict boundaries ✅ ✅** Engine features ✅ ✅*** * With spring and bootsnap ** With package_protections *** With stimpack

Slide 28

Slide 28 text

To start off, 100% of packages do not enforce privacy or dependency protections. The challenge: Push every team to turn on privacy and dependency enforcement Gradual Adoption

Slide 29

Slide 29 text

github.com/bigrails/modularization_statistics

Slide 30

Slide 30 text

github.com/bigrails/modularization_statistics

Slide 31

Slide 31 text

Feedback loops to focus on… Dev writes code Dev commits code Dev’s packwerk build step fails Dev updates the packwerk TODO list Dev merges PRs to the main branch ? ? ? ? ?

Slide 32

Slide 32 text

Dev writes code Dev commits code Dev’s packwerk build step fails Dev updates the packwerk TODO list Dev merges PRs to the main branch ? ? ? ‼‼‼ ? Feedback loops to focus on…

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Dev writes code Dev commits code Dev’s packwerk build step fails Dev updates the packwerk TODO list Dev merges PRs to the main branch VSCode Extension Pre-commit Hooks Inline Automated PR Comments Inline Automated PR Comments Datadog Metrics github.com/bigrails/packwerk-vscode github.com/bigrails/danger-packwerk github.com/bigrails/modularization_statistics Feedback loops to focus on…

Slide 35

Slide 35 text

github.com/bigrails/packwerk-vscode github.com/bigrails/danger-packwerk github.com/bigrails/modularization_statistics

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

What’s next?

Slide 38

Slide 38 text

In what ways can Ruby and Rails continue to offer great tools and cultural norms that help users create well-modularized systems?

Slide 39

Slide 39 text

What can the different conventions of packwerk packages, gemspecs, and other packaging systems learn from each other?

Slide 40

Slide 40 text

We’re hiring! https://gusto.com/careers Feedback and Communities - Emailing me: [email protected] or just starting a conversation - Creating issues, starting discussions, or opening PRs in any repository within https://github.com/bigrails - Joining us in the Ruby/Rails Modularity Slack Server: https://rubymod.slack.com - Invite link: https://tinyurl.com/ruby-modularity - Catch me after the talk and let’s pair! Other Resources and Tools - “Gradual Modularization for Ruby and Rails” by Stephan Hagemann - “Thinking in Systems” by Donella Meadows - “Boundaries” by Gary Bernhardt - https://engineering.gusto.com (Gusto’s Engineering Blog) - Just released: Blog post version of this talk! Your feedback is important and appreciated!