DoDiODev commented on issue #9088:
URL: https://github.com/apache/devlake/issues/9088#issuecomment-5868461003

   Follow-up with measurements against current `main` (`b0a758996`).
   
   **Correction to option 2.** Reworking only the non-test sources 
(`helpers/unithelper`) is not enough: `go mod tidy` also resolves the imports 
of `_test.go` files in the main module. With the three `unithelper` files 
removed, `tidy` still fails for all five mock packages, e.g.
   
   ```
   go: github.com/apache/devlake/core/migration tested by
           github.com/apache/devlake/core/migration.test imports
           github.com/apache/devlake/mocks/core/dal: no matching versions for 
query "latest"
   ```
   
   A complete option 2 would have to touch 25 files (22 tests + 3 helpers) in 
17 packages.
   
   **Smallest fix I'd suggest (keeps generated code out of the tree).** Commit 
one placeholder `doc.go` (`package mocks`, no code) in each of the five mock 
packages that are imported by tracked sources (`core/context`, `core/dal`, 
`core/log`, `core/plugin`, `helpers/pluginhelper/api`). The import paths then 
resolve inside the main module:
   
   - `go mod tidy` succeeds on a fresh clone, `go.mod`/`go.sum` stay unchanged
   - `make mock` (mockery v3.7.4) generates next to the placeholders without 
conflict
   - unit test results are identical with and without the placeholders
   
   The change is limited to the five placeholders, `.gitignore` 
(`backend/mocks/**/*.go` plus `!backend/mocks/**/doc.go`) and `make mock` 
deleting only generated files. A CI step running `go mod tidy && git diff 
--exit-code` on the fresh checkout (before `make mock`) keeps it that way: a 
new mock import without a placeholder fails early instead of silently breaking 
Dependabot's `gomod` updates again.
   
   I'll open a PR with this approach. If you'd rather commit the generated 
mocks (option 1), I'm happy to switch.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to