Skip to content

Commit a709ed8

Browse files
authored
fix(ci): assert that patches apply exactly (#508)
From `man patch` ``` -F max-fuzz, --fuzz max-fuzz Sets the maximum fuzz factor. This option only applies to context diffs, and causes patch to ignore up to that many lines in looking for places to install a hunk. Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz factor is 2, and it may not be set to more than the number of lines of context in the context diff, ordinarily 3. ``` The hint was in our CI job which passes but prints ``` Run patch --dry-run -p1 < .bcr/patches/*.patch checking file MODULE.bazel Hunk #1 succeeded at 45 with fuzz 2 (offset 4 lines). Hunk #2 succeeded at 61 with fuzz 2 (offset 3 lines). ``` When Bazel or the Publish to BCR app apply the patches, they don't use the `patch` tool so they don't allow any variation in the patch lines. Our assertion needs to be strict. Fixes #506
1 parent 5139790 commit a709ed8

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

.bcr/patches/rust_dev_dep.patch

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
diff --git a/MODULE.bazel b/MODULE.bazel
2-
index 841aed7..e1a1d6d 100644
2+
index 967dad2..5022390 100644
33
--- a/MODULE.bazel
44
+++ b/MODULE.bazel
5-
@@ -41,13 +41,13 @@ register_toolchains(
5+
@@ -45,13 +45,13 @@ register_toolchains(
66
bazel_dep(
77
name = "rules_rust",
88
version = "0.53.0",
99
- # In released versions: dev_dependency = True
10-
+ dev_dependency = True
10+
+ dev_dependency = True,
1111
)
1212

1313
rust = use_extension(
1414
"@rules_rust//rust:extensions.bzl",
1515
"rust",
1616
- # In released versions: dev_dependency = True
17-
+ dev_dependency = True
17+
+ dev_dependency = True,
1818
)
19-
2019
rust.toolchain(
21-
@@ -58,13 +58,13 @@ use_repo(rust, "rust_toolchains")
20+
edition = "2021",
21+
@@ -61,13 +61,13 @@ use_repo(rust, "rust_toolchains")
2222

2323
register_toolchains(
2424
"@rust_toolchains//:all",
2525
- # In released versions: dev_dependency = True
26-
+ dev_dependency = True
26+
+ dev_dependency = True,
2727
)
2828

2929
crate = use_extension(
3030
"@rules_rust//crate_universe:extension.bzl",
3131
"crate",
3232
- # In released versions: dev_dependency = True
33-
+ dev_dependency = True
33+
+ dev_dependency = True,
3434
)
35-
3635
crate.from_cargo(
36+
name = "crate_index",

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
runs-on: ubuntu-latest
5151
steps:
5252
- uses: actions/checkout@v4
53-
- run: patch --dry-run -p1 < .bcr/patches/*.patch
53+
- run: patch --dry-run -p1 --fuzz 0 < .bcr/patches/*.patch
5454

5555
test-release:
5656
runs-on: ubuntu-latest

e2e/use_release/minimal_download_test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ fi
1313
# Test bzlmod
1414
(
1515
cd ../..
16-
patch -p1 < .bcr/patches/*.patch
16+
# Create the .orig file, whether there's a mismatch or not
17+
patch -p1 --backup < .bcr/patches/*.patch
1718
)
1819
OUTPUT_BASE=$(mktemp -d)
1920
output=$(bazel "--output_base=$OUTPUT_BASE" run --enable_bzlmod //src:main)

0 commit comments

Comments
 (0)