Skip to content

Commit

Permalink
fix: use python instead gzip+chmod (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
kczulko authored Sep 23, 2024
1 parent 5c6613a commit bba714a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ filegroup(
"//tools/tests-runner:all_files",
"//tools/tests-placeholder-repairer:all_files",
"//tools/protoc-gen-elm:all_files",
"//tools/gzip:all_files",
],
visibility = ["//visibility:public"],
)
5 changes: 4 additions & 1 deletion elm/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ genrule(
name = "extract_elm_compiler",
srcs = [":compiler.gz"],
outs = [ "compiler" ],
cmd = "gzip -d -c $(SRCS) > $@ && chmod +x $@"
tools = [
"@rules_elm//tools/gzip:bin",
],
cmd = "$(execpath @rules_elm//tools/gzip:bin) $(SRCS) $@",
)
elm_toolchain(
Expand Down
4 changes: 2 additions & 2 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rules_elm_integration_test_each_bazel(
bazel_binaries = bazel_binaries,
workspace_path = "elm-binary",
bazel_cmd = "build :main",
expected_output = "INFO: Build completed successfully, (8|7) total actions",
expected_output = "INFO: Build completed successfully, .. total actions",
# sometimes it fails with an error:
# 0.19.1/d.dat: openBinaryFile: resource busy (file is locked)
flaky = True,
Expand Down Expand Up @@ -60,7 +60,7 @@ rules_elm_integration_test_each_bazel(
test_runner = ":output_match_runner",
workspace_path = "elm-todomvc",
bazel_cmd = "build :bin",
expected_output = """INFO: Build completed successfully, (7|8) total actions""",
expected_output = """INFO: Build completed successfully, .. total actions""",
)

rules_elm_integration_test_each_bazel(
Expand Down
14 changes: 14 additions & 0 deletions tools/gzip/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
name = "bin",
main = ":gzip.py",
srcs = ["gzip.py"],
visibility = ["//visibility:public"],
)

filegroup(
name = "all_files",
srcs = glob(["*"]),
visibility = ["//:__subpackages__"],
)
15 changes: 15 additions & 0 deletions tools/gzip/gzip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
import os
import gzip

(
compressed_filepath,
decompressed_filepath,
) = sys.argv[1:3]

with open(decompressed_filepath, "xb") as decompressed:
with gzip.open(compressed_filepath, 'rb') as compressed:
decompressed.write(compressed.read())

os.chmod(decompressed_filepath, 0o555)

0 comments on commit bba714a

Please sign in to comment.