Skip to content

Commit

Permalink
Add a check to ensure that version.bzl and MODULE.bazel remain in syn…
Browse files Browse the repository at this point in the history
…c. (#697)

* add MODULE.bazel

* Add a check to ensure that version.bzl and MODULE.bazel remain in sync.
  • Loading branch information
aiuto authored May 23, 2023
1 parent 5bf5a90 commit ec4ad13
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module(
name = "rules_pkg",
version = "0.9.0", # Must sync with version.bzl.
version = "0.10.0", # Must sync with version.bzl.
repo_name = "rules_pkg",
compatibility_level = 1,
)
Expand Down
1 change: 1 addition & 0 deletions distro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ py_test(
data = [
"testdata/BUILD.tpl",
":distro",
"//:standard_package",
],
local = True,
python_version = "PY3",
Expand Down
19 changes: 19 additions & 0 deletions distro/packaging_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Test that the rules_pkg distribution is usable."""

import os
import re
import subprocess
import unittest

Expand All @@ -34,6 +35,24 @@ def setUp(self):
self.dest_repo = 'not_named_rules_pkg'
self.version = release_version.RELEASE_VERSION

def testVersionsMatch(self):
"""version.bzl must match MODULE.bazel"""
module_bazel_path = self.data_files.Rlocation(
'rules_pkg/MODULE.bazel')
with open(module_bazel_path, encoding="utf-8") as inp:
want = 'version = "%s"' % self.version
content = inp.read()
if _VERBOSE:
print('=== Expect', want)
module_block_re = re.compile
m = re.search(
r"""module\([^)]+\)""",
content,
flags=re.MULTILINE|re.DOTALL)
self.assertTrue(m)
got = m.group()
self.assertIn(want, got, 'Expected <%s>, got <%s>' % (want, got))

def testBuild(self):
# Set up a fresh Bazel workspace using the currently build repo.
tempdir = os.path.join(os.environ['TEST_TMPDIR'], 'build')
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
"""The version of rules_pkg."""

version = "0.9.0"
version = "0.10.0"

0 comments on commit ec4ad13

Please sign in to comment.