Skip to content

Commit d3d0f2d

Browse files
authored
Release 0.2.0 (#11)
1 parent 4872a94 commit d3d0f2d

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
exports_files([
2-
"version.bzl",
32
"LICENSE",
3+
"MODULE.bazel",
4+
"version.bzl",
45
])

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module(
44
name = "rules_typst",
5-
version = "0.1.0",
5+
version = "0.2.0",
66
)
77

88
bazel_dep(name = "rules_rust", version = "0.68.1")

tools/version_test/BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@rules_rust//rust:defs.bzl", "rust_test")
2+
load("//:version.bzl", "VERSION")
3+
4+
rust_test(
5+
name = "bzl_version_test",
6+
srcs = ["bzl_version_test.rs"],
7+
data = [
8+
"//:MODULE.bazel",
9+
],
10+
edition = "2021",
11+
env = {
12+
"MODULE_BAZEL": "$(rlocationpath //:MODULE.bazel)",
13+
"VERSION": VERSION,
14+
},
15+
deps = [
16+
"@rules_rust//rust/runfiles",
17+
],
18+
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//! A test to ensure the rules_rust bzlmod versions match the standard versions.
2+
3+
use runfiles::Runfiles;
4+
5+
fn parse_module_bazel_version(text: &str) -> String {
6+
let mut found_module = false;
7+
for line in text.split('\n') {
8+
if found_module {
9+
assert!(!line.ends_with(')'), "Failed to parse version");
10+
if let Some((param, value)) = line.rsplit_once(" = ") {
11+
if param.trim() == "version" {
12+
return value.trim().trim_matches(',').trim_matches('"').to_owned();
13+
}
14+
}
15+
} else if line.starts_with("module(") {
16+
found_module = true;
17+
continue;
18+
}
19+
}
20+
panic!("Failed to find MODULE.bazel version");
21+
}
22+
23+
/// If this test fails it means `//:version.bzl` and `//:MODULE.bazel` need to
24+
/// be synced up. `//:version.bzl` should contain the source of truth.
25+
#[test]
26+
fn module_bzl_has_correct_version() {
27+
let version = std::env::var("VERSION").unwrap();
28+
let module_bazel_text = {
29+
let r = Runfiles::create().unwrap();
30+
let path = runfiles::rlocation!(r, std::env::var("MODULE_BAZEL").unwrap()).unwrap();
31+
std::fs::read_to_string(path).unwrap()
32+
};
33+
34+
let module_bazel_version = parse_module_bazel_version(&module_bazel_text);
35+
36+
assert_eq!(
37+
version, module_bazel_version,
38+
"@rules_typst//:version.bzl and //:MODULE.bazel versions are out of sync"
39+
);
40+
}

version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
""""rules_typst version"""
22

3-
VERSION = "0.1.0"
3+
VERSION = "0.2.0"

0 commit comments

Comments
 (0)