Copying gomock definition and tests from rules_go (#231) · uber-go/mock@bb4128e (original) (raw)

21 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ permissions:
9 9 contents: read
10 10
11 11 jobs:
12 -test:
12 +go:
13 13 strategy:
14 14 matrix:
15 15 go-version: [1.22.x, 1.23.x] # oldest version that can build go mock and official supported go versions
@@ -40,10 +40,35 @@ jobs:
40 40 ./ci/test.sh
41 41 ./ci/check_panic_handling.sh
42 42
43 - - name: Run Tests
43 + - name: Run Go Tests
44 44 run: |
45 - for i in (find(find (findPWD -name go.mod); do
45 + for i in (find(find (findPWD -name go.mod ! -path "$PWD/bazel/go.mod"); do
46 46 pushd (dirname(dirname (dirnamei)
47 47 go test ./...
48 48 popd
49 49 done
50 +
51 + bazel:
52 +strategy:
53 +matrix:
54 +os:
55 + - macos
56 + - ubuntu
57 +runs-on: ${{ matrix.os }}-latest
58 +steps:
59 + - name: Checkout code
60 +uses: actions/checkout@v4
61 +
62 + - name: Setup Bazel
63 +uses: bazel-contrib/setup-bazel@0.10.0
64 +with:
65 +# Avoid downloading Bazel every time.
66 +bazelisk-cache: true
67 +# Store build cache per workflow.
68 +disk-cache: ${{ github.workflow }}
69 +# Share repository cache between workflows.
70 +repository-cache: true
71 +
72 + - name: Run Bazel tests
73 +run: |
74 + cd bazel && bazel test //...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 +bazel-*
2 +MODULE.bazel.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
1 +module(name = "bazel_gomock")
2 +
3 +bazel_dep(name = "bazel_skylib", version = "1.7.1")
4 +bazel_dep(name = "rules_go", version = "0.51.0", repo_name = "io_bazel_rules_go")
5 +bazel_dep(name = "gazelle", version = "0.40.0")
6 +
7 +go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
8 +
9 +go_sdk.download(version = "1.23.4")
10 +
11 +go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
12 +go_deps.from_file(go_mod = "//:go.mod")
13 +use_repo(
14 +go_deps,
15 +"org_uber_go_mock",
16 +)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1 +module go.uber.org/mock/bazel
2 +
3 +go 1.23.0
4 +
5 +require go.uber.org/mock v0.4.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
2 +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1 +load("@io_bazel_rules_go//go:def.bzl", "go_library")
2 +
3 +go_library(
4 +name = "rules",
5 +srcs = ["tools.go"],
6 +importpath = "go.uber.org/mock/bazel/rules",
7 +visibility = ["//visibility:public"],
8 +deps = ["@org_uber_go_mock//mockgen/model:go_default_library"],
9 +)