[Bug][Build] go mod tidy fails on a fresh clone because backend/mocks/ is gitignored but imported by tracked sources
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- git, go
- 領域
- backend, build-system
調査の方向性
.gitignore、Makefile:101、backend/Makefile:85、および helpers/unithelper と helpers/pluginhelper/api で指定されている imports から始めます。新しい clone で go mod tidy を実行して失敗を再現し、その後 make mock 実行後の tree と比較します。maintainers が選択したアプローチによって、コミットされていない mock 生成手順なしで go mod tidy、go build ./...、go vet ./... が動作すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Search before asking
- I had searched in the issues and found no similar issues.
What happened
On a fresh clone of the repository, any Go tooling that loads the whole module fails, because backend/mocks/ is listed in .gitignore while tracked, non-test sources import it.
backend/helpers/unithelper imports mocks/core/context, mocks/core/dal, mocks/core/log and mocks/core/plugin; the helpers/pluginhelper/api tests import mocks/helpers/pluginhelper/api.
Since the directory does not exist in a clean checkout, Go cannot resolve these paths inside the module and tries to fetch them as external modules:
go: finding module for package github.com/apache/incubator-devlake/mocks/core/context
go: github.com/apache/incubator-devlake/helpers/unithelper imports
github.com/apache/incubator-devlake/mocks/core/context: no matching versions for query "latest"
go: github.com/apache/incubator-devlake/helpers/unithelper imports
github.com/apache/incubator-devlake/mocks/core/dal: no matching versions for query "latest"
go: github.com/apache/incubator-devlake/helpers/unithelper imports
github.com/apache/incubator-devlake/mocks/core/log: no matching versions for query "latest"
go: github.com/apache/incubator-devlake/helpers/unithelper imports
github.com/apache/incubator-devlake/mocks/core/plugin: no matching versions for query "latest"
go: github.com/apache/incubator-devlake/helpers/pluginhelper/api tested by
github.com/apache/incubator-devlake/helpers/pluginhelper/api.test imports
github.com/apache/incubator-devlake/mocks/helpers/pluginhelper/api: no matching versions for query "latest"
This affects go mod tidy, go build ./..., go vet ./... and editors/IDEs loading the module. It goes unnoticed in day-to-day work because make unit-test depends on mock (Makefile:101, backend/Makefile:85), which runs mockery first.
It also blocks automated dependency tooling. While preparing a Dependabot configuration I hit exactly this error in the gomod ecosystem — Dependabot runs go mod tidy after every version bump and aborts:
ERROR Error processing github.com/gin-gonic/gin (Dependabot::DependabotError)
/home/dependabot/go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb:350
:in 'GoModUpdater#run_go_mod_tidy'
What do you expect to happen
A fresh clone should load with standard Go tooling without a mandatory code-generation step.
How to reproduce
git clone https://github.com/apache/devlake.git
cd devlake/backend
go mod tidy # fails with the output above
Counter-check — after generating the mocks the very same tree is clean:
cd .. # repo root
make mock # delegates to `make mock -C backend`
cd backend
go mod tidy # exit 0, no output
go.mod and go.sum remain byte-identical afterwards, so the module itself is consistent — the only defect is the missing directory.
Anything else
backend/mocks/ has been gitignored since 243cc8a80 ("refactor: refactor files/dirs of the whole repo for better organization", #3884, Jan 2023).
Possible directions — happy to send a PR for whichever the maintainers prefer:
- Commit the generated mocks (remove the
.gitignoreentry). 65 files, ~644 KB. A fresh clone would then work with plain Go tooling. Staleness can be guarded by a CI step runningmake mockfollowed bygit diff --exit-code. - Stop importing generated packages from tracked non-test sources, e.g. by reworking
helpers/unithelper. Larger change, but keeps generated code out of the tree. - Document it as intended and require
make mockbefore any Go tooling. This keeps the status quo but leaves automated dependency updates for the Go ecosystem unavailable.
Note that a build tag does not help here: go mod tidy considers all build tags except ignore, and an ignore tag would also drop the package from regular builds.
Version
main (c8288c0cd)
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
- 主要言語
- Go
- スター
- 3.1k
- フォーク
- 812
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 56
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/devlake のほかの issue
-
type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
type/bug
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Bob Shell support オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
santhosh-tekuri/jsonschema#276 ·