-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce proper postupgrade script for renovate.
- Loading branch information
Showing
5 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
load("//bzl:rules.bzl", "bazel_lint") | ||
load("//py:rules.bzl", "py_binary") | ||
|
||
py_binary( | ||
name = "postUpgrade_bin", | ||
srcs = ["__main__.py"], | ||
main = "__main__.py", | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
bazel_lint( | ||
name = "bazel_lint", | ||
srcs = ["BUILD.bazel"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"Runs after Renovate updates some dep" | ||
from subprocess import run as _run | ||
from os import getenv | ||
|
||
if __name__ != "__main__": | ||
raise Exception("don’t import this!") | ||
|
||
wd = getenv("BUILD_WORKSPACE_DIRECTORY") | ||
|
||
if wd is None: | ||
raise Exception("Please run from bazel.") | ||
|
||
|
||
def run(*args, **kwargs): | ||
return _run(*args, cwd=wd, **kwargs) | ||
|
||
def bazel(args: list[str] = [], **kwargs): | ||
return run( | ||
["npx", "--yes", "@bazel/bazelisk"] + args, | ||
check=True, **kwargs, | ||
) | ||
|
||
def bazel_run(args: list[str] = [], env: dict[str, str] = {}, **kwargs): | ||
return bazel( | ||
["run"] + args, | ||
**kwargs, | ||
) | ||
|
||
def cargo_repin(): | ||
return bazel(["sync", "--only=cargo"]) | ||
|
||
def go_mod_tidy(): | ||
return bazel_run(["@@/sh/bin:go", "--", "mod", "tidy"]) | ||
|
||
def bazel_update_lockfile(): | ||
return bazel(["mod", "deps", "--lockfile_mode=update"]) | ||
|
||
def autofix_tags(tags: list[str]): | ||
return bazel_run(["@@//:fix"] + tags) | ||
|
||
def autofix_all(): | ||
return autofix_tags(["//..."]) | ||
|
||
def bazel_update_modfile(): | ||
return bazel(["mod", "tidy"]) | ||
|
||
def modify_non_bazel_lockfiles(): | ||
go_mod_tidy() | ||
autofix_all() | ||
|
||
def modify_bazel_lockfiles(): | ||
bazel_update_modfile() | ||
cargo_repin() | ||
bazel_update_lockfile() | ||
# and one for luck | ||
autofix_all() | ||
|
||
modify_non_bazel_lockfiles() | ||
modify_bazel_lockfiles() | ||
run(["rm", "-rf", "dist/"]) | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters