Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bazel-contrib/bazel-mypy-integration
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b9497ed9f8af475eb4655628f2fa8a0337eb608f
Choose a base ref
..
head repository: bazel-contrib/bazel-mypy-integration
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9771152cb2260a591e4cc308d7bb59457c13e764
Choose a head ref
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build --//:mypy=//third_party:mypy
common --enable_bzlmod
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.1
6.5.0
27 changes: 21 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -9,16 +9,31 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
bzlmodEnabled: [true, false]
folder: [".", "examples"]
exclude:
# No point keeping the root workspace compatible with --noenable_bzlmod
- folder: "."
bzlmodEnabled: false
defaults:
run:
working-directory: ${{ matrix.folder }}

steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
- uses: actions/checkout@v4

- name: Setup Bazel
uses: abhinavsingh/setup-bazel@v3
- uses: p0deje/setup-bazel@0.6.0
with:
# Must match version in repo's .bazelversion file.
version: 5.4.1

bazelrc: common --announce_rc --color=yes --enable_bzlmod=${{ matrix.bzlmodEnabled }}
- name: Run tests
run: bazel test //...

integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run integration tests
run: ./test.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Remove after the lockfile format is more stable
MODULE.bazel.lock

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See CONTRIBUTING.md for instructions.
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

# Commitizen runs in commit-msg stage
# but we don't want to run the other hooks on commit messages
default_stages: [commit]

# Use a slightly older version of node by default
# as the default uses a very new version of GLIBC
default_language_version:
node: 16.18.0

repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.1.0.1
hooks:
- id: buildifier
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.0"
hooks:
- id: prettier
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# How to Contribute

## Formatting

Starlark files should be formatted by buildifier.
We suggest using a pre-commit hook to automate this.
First [install pre-commit](https://pre-commit.com/#installation),
then run

```shell
pre-commit install
```

Otherwise later tooling on CI will yell at you about formatting/linting violations.
35 changes: 35 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"Bazel dependencies under bzlmod"

module(
name = "mypy_integration",
# Replaced with the tag during BCR publishing
version = "0.0.0",
compatibility_level = 1,
)

# Lower-bound dependency versions.
# Only increase these when needed, otherwise users get warnings from Bazel about how the selected
# version is greater than the one they specified.
bazel_dep(name = "rules_python", version = "0.27.1")
bazel_dep(name = "bazel_skylib", version = "1.5.0")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

python = use_extension(
"@rules_python//python/extensions:python.bzl",
"python",
dev_dependency = True,
)
python.toolchain(python_version = "3.8")

pip = use_extension(
"@rules_python//python/extensions:pip.bzl",
"pip",
dev_dependency = True,
)
pip.parse(
hub_name = "mypy_integration_pip_deps",
python_version = "3.8",
requirements_lock = "//third_party:requirements.txt",
)
use_repo(pip, "mypy_integration_pip_deps")
65 changes: 2 additions & 63 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,63 +1,2 @@
workspace(name = "bazel_mypy_integration")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//repositories:repositories.bzl", mypy_integration_repositories = "repositories")

mypy_integration_repositories()

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python3_8",
python_version = "3.8",
)

load("@python3_8//:defs.bzl", python_interpreter = "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
name = "mypy_integration_pip_deps",
python_interpreter_target = python_interpreter,
requirements_lock = "//third_party:requirements.txt",
)

load("@mypy_integration_pip_deps//:requirements.bzl", install_mypy_deps = "install_deps")

install_mypy_deps()

http_archive(
name = "buildifier_prebuilt",
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
strip_prefix = "buildifier-prebuilt-6.4.0",
urls = [
"http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz",
],
)

load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()

http_archive(
name = "com_google_protobuf",
sha256 = "8ff511a64fc46ee792d3fe49a5a1bcad6f7dc50dfbba5a28b0e5b979c17f9871",
strip_prefix = "protobuf-25.2",
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v25.2.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v25.2.tar.gz",
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
# Marker file that this is the root of a Bazel workspace.
# Dependencies appear in MODULE.bazel
1 change: 1 addition & 0 deletions examples/.bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build --@mypy_integration//:mypy=//tools/typing:mypy
common --java_runtime_version=remotejdk_11
32 changes: 32 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"Bazel dependencies, used under --enable_bzlmod"

module(
name = "mypy-integration-examples",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "mypy_integration", version = "0.0.0")
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_python", version = "0.31.0")

local_path_override(
module_name = "mypy_integration",
path = "..",
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.8")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "my_deps",
python_version = "3.8",
requirements_lock = "//third_party:requirements.txt",
)
pip.parse(
hub_name = "my_mypy_deps",
python_version = "3.8",
requirements_lock = "//tools/typing:mypy_requirements.txt",
)
use_repo(pip, "my_deps", "my_mypy_deps")
6 changes: 3 additions & 3 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -69,10 +69,10 @@ install_my_pypy_deps()

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
],
)

1 change: 1 addition & 0 deletions examples/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Under --enable_bzlmod, this file shadows WORKSPACE
6 changes: 3 additions & 3 deletions examples/tools/typing/mypy_requirements.txt
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ typed-ast==1.4.3 \
--hash=sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f \
--hash=sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65
# via mypy
typing-extensions==4.5.0 \
--hash=sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb \
--hash=sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4
typing-extensions==4.10.0 \
--hash=sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475 \
--hash=sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb
# via mypy
13 changes: 12 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
":dependencyDashboard",
":semanticPrefixFixDepsChoreOthers",
"group:monorepos",
"group:recommended",
"replacements:all",
"workarounds:all"
],
"packageRules": [
{
"matchFiles": ["MODULE.bazel"],
"enabled": false
}
]
}
2 changes: 2 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ mypy_test(

mypy_test(
name = "broken_mypy_test",
tags = ["manual"],
deps = [":broken_mypy_typings"],
)

@@ -60,6 +61,7 @@ mypy_test(

mypy_test(
name = "broken_imported_mypy_test",
tags = ["manual"],
deps = [":broken_imported_mypy_typings"],
)

6 changes: 3 additions & 3 deletions third_party/requirements.txt
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ typed-ast==1.4.3 \
--hash=sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f \
--hash=sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65
# via mypy
typing-extensions==4.5.0 \
--hash=sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb \
--hash=sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4
typing-extensions==4.10.0 \
--hash=sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475 \
--hash=sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb
# via mypy