This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 12c0128af fix(build): make go mod tidy work on a fresh clone (#9179)
12c0128af is described below
commit 12c0128af8c64f2c6432ce6cfdea85624dd39970
Author: Dirk <[email protected]>
AuthorDate: Sun Oct 4 12:17:30 2026 +0200
fix(build): make go mod tidy work on a fresh clone (#9179)
backend/mocks/ is git-ignored, but helpers/unithelper and 22 test files
import five of its packages. On a fresh clone those import paths do not
exist inside the main module, so go mod tidy tries to resolve them as
external modules and fails with "no matching versions for query latest".
This also keeps Dependabot's gomod updater from producing any update.
Track one doc.go placeholder (package mocks, no code) in each imported
mock package, so the paths resolve locally. The generated mocks stay
git-ignored, and make mock now removes only the generated files instead
of the whole directory.
Add a step to the unit-test workflow that runs go mod tidy on the fresh
checkout, before any mocks are generated, and fails on a diff. A new mock
import without a placeholder, or an untidy go.mod, is caught there.
Refs #9088
---
.github/workflows/test.yml | 5 +++++
.gitignore | 5 ++++-
backend/Makefile | 4 +++-
backend/mocks/core/context/doc.go | 25 +++++++++++++++++++++++++
backend/mocks/core/dal/doc.go | 25 +++++++++++++++++++++++++
backend/mocks/core/log/doc.go | 25 +++++++++++++++++++++++++
backend/mocks/core/plugin/doc.go | 25 +++++++++++++++++++++++++
backend/mocks/helpers/pluginhelper/api/doc.go | 25 +++++++++++++++++++++++++
8 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5fe88805b..1e2542b2c 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -51,6 +51,11 @@ jobs:
run: backend/scripts/install-libgit2.sh
- name: Install Go 1.26.6
run: backend/scripts/install-go.sh
+ - name: Check go.mod is tidy without generated mocks
+ run: |
+ cd backend
+ go mod tidy
+ git diff --exit-code -- go.mod go.sum
- name: Install mockery 3.7.4
run: backend/scripts/install-mockery.sh
- name: Build Python
diff --git a/.gitignore b/.gitignore
index 88f07eb19..0877343e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -154,7 +154,10 @@ libgit2
.playwright-cli/
# auto generated code
-backend/mocks/
+# backend/mocks: only the doc.go placeholders are tracked, they keep the mock
+# import paths resolvable for `go mod tidy` on a fresh clone
+backend/mocks/**/*.go
+!backend/mocks/**/doc.go
backend/server/api/docs/swagger.json
backend/server/api/docs/swagger.yaml
backend/server/api/docs/docs.go
diff --git a/backend/Makefile b/backend/Makefile
index d721309d3..b9dbe42e0 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -80,7 +80,9 @@ debug: build-plugin-debug
dlv debug server/main.go
mock:
- rm -rf mocks
+ # Remove previously generated mocks but keep the tracked doc.go
placeholders,
+ # which keep the mock import paths resolvable for `go mod tidy`.
+ if [ -d mocks ]; then find mocks -type f ! -name doc.go -delete && find
mocks -type d -empty -delete; fi
# mockery v3 is configured via YAML instead of CLI flags. Two
invocations are
# required (and must run in this order): `helpers/unithelper` imports
the
# generated `mocks/core/...` packages, and v3 type-checks the sources it
diff --git a/backend/mocks/core/context/doc.go
b/backend/mocks/core/context/doc.go
new file mode 100644
index 000000000..df7d32afd
--- /dev/null
+++ b/backend/mocks/core/context/doc.go
@@ -0,0 +1,25 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package mocks holds the mockery-generated mocks for
+// github.com/apache/devlake/core/context.
+//
+// Only this file is tracked. The mocks themselves are generated by
+// `make mock` and git-ignored; this placeholder keeps the import path
+// resolvable inside the main module, so that `go mod tidy` works on a
+// fresh clone.
+package mocks
diff --git a/backend/mocks/core/dal/doc.go b/backend/mocks/core/dal/doc.go
new file mode 100644
index 000000000..8d47a63a3
--- /dev/null
+++ b/backend/mocks/core/dal/doc.go
@@ -0,0 +1,25 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package mocks holds the mockery-generated mocks for
+// github.com/apache/devlake/core/dal.
+//
+// Only this file is tracked. The mocks themselves are generated by
+// `make mock` and git-ignored; this placeholder keeps the import path
+// resolvable inside the main module, so that `go mod tidy` works on a
+// fresh clone.
+package mocks
diff --git a/backend/mocks/core/log/doc.go b/backend/mocks/core/log/doc.go
new file mode 100644
index 000000000..dc5b4aa3a
--- /dev/null
+++ b/backend/mocks/core/log/doc.go
@@ -0,0 +1,25 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package mocks holds the mockery-generated mocks for
+// github.com/apache/devlake/core/log.
+//
+// Only this file is tracked. The mocks themselves are generated by
+// `make mock` and git-ignored; this placeholder keeps the import path
+// resolvable inside the main module, so that `go mod tidy` works on a
+// fresh clone.
+package mocks
diff --git a/backend/mocks/core/plugin/doc.go b/backend/mocks/core/plugin/doc.go
new file mode 100644
index 000000000..3f75e2bf2
--- /dev/null
+++ b/backend/mocks/core/plugin/doc.go
@@ -0,0 +1,25 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package mocks holds the mockery-generated mocks for
+// github.com/apache/devlake/core/plugin.
+//
+// Only this file is tracked. The mocks themselves are generated by
+// `make mock` and git-ignored; this placeholder keeps the import path
+// resolvable inside the main module, so that `go mod tidy` works on a
+// fresh clone.
+package mocks
diff --git a/backend/mocks/helpers/pluginhelper/api/doc.go
b/backend/mocks/helpers/pluginhelper/api/doc.go
new file mode 100644
index 000000000..9b1219749
--- /dev/null
+++ b/backend/mocks/helpers/pluginhelper/api/doc.go
@@ -0,0 +1,25 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Package mocks holds the mockery-generated mocks for
+// github.com/apache/devlake/helpers/pluginhelper/api.
+//
+// Only this file is tracked. The mocks themselves are generated by
+// `make mock` and git-ignored; this placeholder keeps the import path
+// resolvable inside the main module, so that `go mod tidy` works on a
+// fresh clone.
+package mocks