Shopify / Shopify/packwerk

[Feature Request] Separate run-time and test-time dependencies

Open
#354 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
1.9k
Forks
121
Avg merge
2m
Merged PRs (30d)
1

Description

We have a monolithic codebase which we're trying to modularise into engines, using Packwerk to define and enforce the dependencies between them.

Moving our app code into the engines is usually pretty straightforward, but the tests are a problem. In a lot of places, the model code works generically without reference to the types of input it gets, but the tests define the behaviour using concrete examples of inputs using classes from outside the engine. We work with non-technical domain experts to write these tests, and they work almost exclusively with concrete examples, so rewriting them with dummy classes isn't a long-term solution.

What I'd really like is to be able to define one set of dependencies for the app code in each engine, and have Packwerk enforce those for the code under engines/whatever/app; and another looser set of dependencies for the spec code, and have Packwerk enforce those for the code under engines/whatever/spec. That way, we could move our test files across unaltered. Ideally, I'd do this in a single package.yml file:

enforce-dependencies: true

dependencies:
  - app
    - engines/base
    - engines/engine1
  - spec
    - engines/base
    - engines/engine1
    - engines/engine2

This could then be simplified using YAML anchors etc...

Hope that makes sense! Apologies if this is already possible and I've missed how to do it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the package.yml configuration and the engines/whatever/app and engines/whatever/spec paths described in the request. Trace how Packwerk currently reads dependencies and enforces them, then determine how separate app and spec dependency sets should be represented. Done means runtime and test code can use distinct dependency rules while existing test files remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.