-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copying gomock definition and tests from rules_go (#231)
This PR copies the gomock definition and tests from rules_go with minimal changes: * Replacing github.com/golang/mock with go.uber.org/mock * Replacing `load` statements accordingly * Setting up a Bazel and a Go module in the "bazel" directory Note that the Go module uses v0.4.0 of go.uber.org/mock, because the latest version is no longer compatible with the gomock rule (bazel-contrib/rules_go#4153). We will update the rule and mockgen version in subsequent PRs. This is a first step in addressing #225
- Loading branch information
Showing
21 changed files
with
654 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ permissions: | |
contents: read | ||
|
||
jobs: | ||
test: | ||
go: | ||
strategy: | ||
matrix: | ||
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: | |
./ci/test.sh | ||
./ci/check_panic_handling.sh | ||
- name: Run Tests | ||
- name: Run Go Tests | ||
run: | | ||
for i in $(find $PWD -name go.mod); do | ||
for i in $(find $PWD -name go.mod ! -path "$PWD/bazel/go.mod"); do | ||
pushd $(dirname $i) | ||
go test ./... | ||
popd | ||
done | ||
bazel: | ||
strategy: | ||
matrix: | ||
os: | ||
- macos | ||
- ubuntu | ||
runs-on: ${{ matrix.os }}-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Bazel | ||
uses: bazel-contrib/[email protected] | ||
with: | ||
# Avoid downloading Bazel every time. | ||
bazelisk-cache: true | ||
# Store build cache per workflow. | ||
disk-cache: ${{ github.workflow }} | ||
# Share repository cache between workflows. | ||
repository-cache: true | ||
|
||
- name: Run Bazel tests | ||
run: | | ||
cd bazel && bazel test //... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bazel-* | ||
MODULE.bazel.lock |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module(name = "bazel_gomock") | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
bazel_dep(name = "rules_go", version = "0.51.0", repo_name = "io_bazel_rules_go") | ||
bazel_dep(name = "gazelle", version = "0.40.0") | ||
|
||
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") | ||
|
||
go_sdk.download(version = "1.23.4") | ||
|
||
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") | ||
go_deps.from_file(go_mod = "//:go.mod") | ||
use_repo( | ||
go_deps, | ||
"org_uber_go_mock", | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module go.uber.org/mock/bazel | ||
|
||
go 1.23.0 | ||
|
||
require go.uber.org/mock v0.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= | ||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "rules", | ||
srcs = ["tools.go"], | ||
importpath = "go.uber.org/mock/bazel/rules", | ||
visibility = ["//visibility:public"], | ||
deps = ["@org_uber_go_mock//mockgen/model:go_default_library"], | ||
) |
Oops, something went wrong.