Skip to content

Commit 64e3079

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pr/wave4k-pgx
Signed-off-by: DoDiODev <DoDiDev@proton.me> # Conflicts: # .github/workflows/golangci-lint.yml # .github/workflows/test.yml
2 parents 5c509c7 + 7e90d36 commit 64e3079

32 files changed

Lines changed: 1038 additions & 355 deletions

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
- default
2525
command: sleep infinity
2626
mysql:
27-
image: mysql:8.4.10
27+
image: mysql:8.4.11
2828
volumes:
2929
- mysql-storage:/var/lib/mysql
3030
restart: always

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
run: backend/scripts/install-libgit2.sh
3535
- name: Install Go 1.26.2
3636
run: backend/scripts/install-go.sh
37+
- name: Install mockery 3.7.2
38+
run: backend/scripts/install-mockery.sh
3739
- name: Cache golangci-lint
3840
id: cache-golangci-lint
3941
uses: actions/cache@v5

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
run: backend/scripts/install-libgit2.sh
5252
- name: Install Go 1.26.2
5353
run: backend/scripts/install-go.sh
54+
- name: Install mockery 3.7.2
55+
run: backend/scripts/install-mockery.sh
5456
- name: Build Python
5557
run: |
5658
cd backend

backend/.mockery.core.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# mockery v3 configuration for the ./core tree.
17+
#
18+
# Replaces the v2 command line
19+
# mockery --recursive --keeptree --dir=./core --output=./mocks/core \
20+
# --unroll-variadic=false --name='.*'
21+
# and reproduces the exact same layout: backend/mocks/core/<pkg>/<Interface>.go
22+
# with package name `mocks` and an un-prefixed mock struct name.
23+
#
24+
# NOTE: this config is deliberately kept separate from `.mockery.helpers.yml`.
25+
# `helpers/unithelper` imports the generated `mocks/core/...` packages, so the
26+
# core mocks have to exist before the helpers tree can be type-checked by
27+
# mockery v3 (which, unlike v2, loads packages via go/packages).
28+
all: true
29+
recursive: true
30+
template: testify
31+
dir: "mocks/{{.InterfaceDirRelative}}"
32+
filename: "{{.InterfaceName}}.go"
33+
pkgname: "mocks"
34+
structname: "{{.InterfaceName}}"
35+
template-data:
36+
unroll-variadic: false
37+
packages:
38+
github.com/apache/incubator-devlake/core:

backend/.mockery.helpers.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# mockery v3 configuration for the ./helpers tree.
17+
#
18+
# Replaces the v2 command line
19+
# mockery --recursive --keeptree --dir=./helpers --output=./mocks/helpers \
20+
# --unroll-variadic=false --name='.*'
21+
# and reproduces the exact same layout: backend/mocks/helpers/<pkg>/<Interface>.go
22+
# with package name `mocks` and an un-prefixed mock struct name.
23+
#
24+
# Must run *after* `.mockery.core.yml` — see the note there.
25+
all: true
26+
recursive: true
27+
template: testify
28+
dir: "mocks/{{.InterfaceDirRelative}}"
29+
filename: "{{.InterfaceName}}.go"
30+
pkgname: "mocks"
31+
structname: "{{.InterfaceName}}"
32+
template-data:
33+
unroll-variadic: false
34+
packages:
35+
github.com/apache/incubator-devlake/helpers:

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN if [ "$(arch)" != "x86_64" ] ; then \
4949
apt-get install -y gcc-x86-64-linux-gnu binutils-x86-64-linux-gnu ; \
5050
fi
5151

52-
RUN go install github.com/vektra/mockery/v2@v2.53.6
52+
RUN go install github.com/vektra/mockery/v3@v3.7.2
5353
RUN go install github.com/swaggo/swag/cmd/swag@v1.16.6
5454

5555
COPY --from=debian-amd64 /usr/include /rootfs-amd64/usr/include

backend/Dockerfile.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ RUN mkdir -p /tmp/build && cd /tmp/build && \
4747
make -j$(nproc) install && \
4848
ldconfig
4949

50-
RUN go install github.com/vektra/mockery/v2@v2.53.6
50+
RUN go install github.com/vektra/mockery/v3@v3.7.2
5151
RUN go install github.com/swaggo/swag/cmd/swag@v1.16.6
5252

5353
WORKDIR /app

backend/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ PYTHON_DIR ?= "./python"
2727
all: build
2828

2929
go-dep:
30-
go install github.com/vektra/mockery/v2@v2.53.6
30+
go install github.com/vektra/mockery/v3@v3.7.2
3131
go install github.com/swaggo/swag/cmd/swag@v1.16.6
3232
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
3333

@@ -73,8 +73,12 @@ debug: build-plugin-debug
7373

7474
mock:
7575
rm -rf mocks
76-
mockery --recursive --keeptree --dir=./core --output=./mocks/core --unroll-variadic=false --name='.*'
77-
mockery --recursive --keeptree --dir=./helpers --output=./mocks/helpers --unroll-variadic=false --name='.*'
76+
# mockery v3 is configured via YAML instead of CLI flags. Two invocations are
77+
# required (and must run in this order): `helpers/unithelper` imports the
78+
# generated `mocks/core/...` packages, and v3 type-checks the sources it
79+
# parses, so the core mocks have to exist before the helpers tree loads.
80+
mockery --config .mockery.core.yml
81+
mockery --config .mockery.helpers.yml
7882

7983
test: unit-test e2e-test
8084

backend/helpers/pluginhelper/api/api_client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (apiClient *ApiClient) Do(
324324
body interface{},
325325
headers http.Header,
326326
) (*http.Response, errors.Error) {
327-
uri, err := GetURIStringPointer(apiClient.endpoint, path, query)
327+
uri, err := ResolveRequestURI(apiClient.endpoint, path, query)
328328
if err != nil {
329329
return nil, errors.Default.Wrap(err, fmt.Sprintf("Unable to construct URI from %s, %s, %s", apiClient.endpoint, path, query))
330330
}
@@ -453,8 +453,12 @@ func UnmarshalResponseXML(res *http.Response, v interface{}) errors.Error {
453453
return nil
454454
}
455455

456-
// GetURIStringPointer FIXME ...
457-
func GetURIStringPointer(baseUrl string, relativePath string, query url.Values) (*string, errors.Error) {
456+
// ResolveRequestURI combines baseUrl, relativePath and query into the absolute URI used
457+
// for an API request. relativePath must be a relative reference (no scheme or host of its
458+
// own): url.URL.ResolveReference resolves an absolute reference by discarding the base
459+
// entirely (RFC 3986 §5.3), so an absolute or protocol-relative relativePath would silently
460+
// ignore baseUrl and target whatever host it carries instead.
461+
func ResolveRequestURI(baseUrl string, relativePath string, query url.Values) (*string, errors.Error) {
458462
// If the base URL doesn't end with a slash, and has a relative path attached
459463
// the values will be removed by the Go package, therefore we need to add a missing slash.
460464
AddMissingSlashToURL(&baseUrl)
@@ -468,6 +472,9 @@ func GetURIStringPointer(baseUrl string, relativePath string, query url.Values)
468472
if err != nil {
469473
return nil, errors.Convert(err)
470474
}
475+
if u.IsAbs() || u.Host != "" {
476+
return nil, errors.BadInput.New(fmt.Sprintf("relativePath must be a relative path, not an absolute URL: %s", relativePath))
477+
}
471478
if query != nil {
472479
queryString := u.Query()
473480
for key, values := range query {

backend/plugins/github/token/refresh_api_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (c *refreshApiClient) Post(path string, query url.Values, body interface{},
7474
}
7575

7676
func (c *refreshApiClient) do(method, path string, query url.Values, body interface{}, headers http.Header) (*http.Response, errors.Error) {
77-
uri, err := api.GetURIStringPointer(c.endpoint, path, query)
77+
uri, err := api.ResolveRequestURI(c.endpoint, path, query)
7878
if err != nil {
7979
return nil, err
8080
}

0 commit comments

Comments
 (0)