diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5fe88805b49..1e2542b2c4f 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 88f07eb195b..0877343e6bc 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 e5aa539d59a..aeab9c379d5 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -72,7 +72,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 00000000000..df7d32afd2c --- /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 00000000000..8d47a63a3df --- /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 00000000000..dc5b4aa3ab9 --- /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 00000000000..3f75e2bf22a --- /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 00000000000..9b121974935 --- /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