[bazel] Update copybara scripts (#8822)

I've been running my copybara syncs from this branch for a long time.
Finally deciding to PR it.

The biggest update was due to `mostrobotpy` absorbing the commands,
examples, and pyfrc libraries, but I also added in hooks to "enable" the
flakey `xfail` tests on the allwpilib side, and the ability to run
verbose or force push updates.
This commit is contained in:
PJ Reiniger
2026-04-26 18:14:58 -04:00
committed by GitHub
parent c511fcc160
commit a695865781
2 changed files with 98 additions and 106 deletions

View File

@@ -5,6 +5,12 @@ MOSTROBOTPY_PROJECTS = [
native_robotpy_name = "robotpy-native-apriltag",
has_tests = True,
),
struct(
wpilib_name = "commandsv2",
robotpy_name = "robotpy-commands-v2",
native_robotpy_name = None,
has_tests = True,
),
struct(
wpilib_name = "datalog",
robotpy_name = "robotpy-wpilog",
@@ -59,13 +65,28 @@ MOSTROBOTPY_PROJECTS = [
native_robotpy_name = "robotpy-native-xrp",
has_tests = True,
),
struct(
wpilib_name = "simulation/halsim_ds_socket",
robotpy_name = "robotpy-halsim-ds-socket",
native_robotpy_name = None,
has_tests = True,
),
struct(
wpilib_name = "simulation/halsim_gui",
robotpy_name = "robotpy-halsim-gui",
native_robotpy_name = None,
has_tests = True,
),
struct(
wpilib_name = "simulation/halsim_ws_core",
robotpy_name = "robotpy-halsim-ws",
native_robotpy_name = None,
has_tests = True,
),
]
IGNORED_MOSTROBOTPY_PROJECTS = [
"subprojects/robotpy-cscore",
"subprojects/robotpy-halsim-ds-socket",
"subprojects/robotpy-halsim-gui",
"subprojects/robotpy-halsim-ws",
]
def define_mostrobotpy_to_allwpilib():
@@ -119,7 +140,7 @@ def define_mostrobotpy_to_allwpilib():
destination_files += glob([
project_info.wpilib_name + "/src/main/python/**",
project_info.wpilib_name + "/src/test/python/**",
], exclude = [])
], exclude = [project_info.wpilib_name + "/src/main/python/examples/**"])
if project_info.has_tests:
transformations.append(core.move("subprojects/" + project_info.robotpy_name + "/tests", project_info.wpilib_name + "/src/test/python"))
@@ -149,6 +170,21 @@ def define_mostrobotpy_to_allwpilib():
transformations = [core.transform(rename_transforms, noop_behavior = "IGNORE_NOOP", reversal = [])] + transformations
# Examples aren't as complicated
origin_files += glob([
"examples/robot/**",
], exclude = EXCLUDES)
destination_files += glob(["robotpyExamples/**"], exclude = ["robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py", "robotpyExamples/BUILD.bazel"])
transformations.append(core.move("examples/robot/", "robotpyExamples/"))
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
transformations.append(core.replace(
before = '@pytest.mark.xfail(reason="wpilib bug")',
after = '# @pytest.mark.xfail(reason="wpilib bug")',
paths = glob(["**/src/test/python**/*.py"]),
))
core.workflow(
name = "mostrobotpy_to_allwpilib",
origin = git.origin(
@@ -167,21 +203,38 @@ def define_mostrobotpy_to_allwpilib():
)
def define_allwpilib_to_mostrobotpy():
ignored_project_exclude = [p + "/**" for p in IGNORED_MOSTROBOTPY_PROJECTS]
ignored_project_exclude = [p + "/**" for p in IGNORED_MOSTROBOTPY_PROJECTS] + [p + "/examples/**" for p in IGNORED_MOSTROBOTPY_PROJECTS]
origin_files = []
destination_files = glob(["**"], exclude = ["*", ".github/**", "docs/**", "**/.gitignore", "**/meson.build", "**/requirements.txt", "devtools/**", "examples/**", "**/run_tests.py"] + ignored_project_exclude)
destination_files = glob(["**"], exclude = ["*", ".github/**", "docs/**", "**/.gitignore", "**/meson.build", "**/requirements.txt", "devtools/**", "examples/cscore/**", "examples/datalog/**", "examples/ntcore/**", "examples/wpinet/**", "examples/robot/.gitignore", "**/run_tests.py"] + ignored_project_exclude)
transformations = []
for project_info in MOSTROBOTPY_PROJECTS:
origin_files += glob([
project_info.wpilib_name + "/src/main/python/**",
project_info.wpilib_name + "/src/test/python/**",
], exclude = [])
], exclude = [
project_info.wpilib_name + "/src/main/python/examples/**",
])
if project_info.has_tests:
transformations.append(core.move(project_info.wpilib_name + "/src/test/python", "subprojects/" + project_info.robotpy_name + "/tests"))
transformations.append(core.move(project_info.wpilib_name + "/src/main/python", "subprojects/" + project_info.robotpy_name))
transformations.append(core.move("subprojects/" + project_info.robotpy_name + "/native-pyproject.toml", "subprojects/" + project_info.native_robotpy_name + "/pyproject.toml"))
if project_info.native_robotpy_name:
transformations.append(core.move("subprojects/" + project_info.robotpy_name + "/native-pyproject.toml", "subprojects/" + project_info.native_robotpy_name + "/pyproject.toml"))
origin_files += glob([
"robotpyExamples/**",
], exclude = ["robotpyExamples/BUILD.bazel", "robotpyExamples/define_examples.bzl", "robotpyExamples/example_projects.bzl", "robotpyExamples/generate_bazel_files.py"])
destination_files += glob(["examples/robot/**"], exclude = ["examples/robot/.gitignore"])
transformations.append(core.move("robotpyExamples/", "examples/robot/"))
# Some tests seem to fail in mostrobotpy, but don't in allwpilib
# We will leave them turned on in allwpilib, and mark them as xfail in mostrobotpy.
transformations.append(core.replace(
before = '# @pytest.mark.xfail(reason="wpilib bug")',
after = '@pytest.mark.xfail(reason="wpilib bug")',
paths = glob(["**/tests**/*.py"]),
))
core.workflow(
name = "allwpilib_to_mostrobotpy",
@@ -200,59 +253,5 @@ def define_allwpilib_to_mostrobotpy():
transformations = transformations,
)
def define_robotpy_commandsv2_to_allwpilib():
origin_files = glob(["commands2/**", "tests/**"], exclude = ["tests/run_tests.py", "tests/requirements.txt"])
destination_files = glob(["commandsv2/src/main/python/**", "commandsv2/src/test/python/**"])
transformations = []
transformations.append(core.move("commands2/", "commandsv2/src/main/python/commands2/"))
transformations.append(core.move("tests/", "commandsv2/src/test/python/"))
core.workflow(
name = "commandsv2_to_allwpilib",
origin = git.origin(
url = "https://github.com/robotpy/robotpy-commands-v2.git",
ref = "2027",
),
destination = git.destination(
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
fetch = "2027",
push = "copybara_commandsv2_to_allwpilib",
),
destination_files = destination_files,
origin_files = origin_files,
authoring = authoring.pass_thru("Default email <default@default.com>"),
transformations = transformations,
)
def define_allwpilib_to_robotpy_commandsv2():
ignored_project_exclude = [p + "/**" for p in IGNORED_MOSTROBOTPY_PROJECTS]
origin_files = glob(["commandsv2/src/main/python/**", "commandsv2/src/test/python/**"])
destination_files = glob(["**"], exclude = ["*", ".github/**", "**/run_tests.py", "docs/**", "tests/requirements.txt"])
transformations = []
transformations.append(core.move("commandsv2/src/main/python/", ""))
transformations.append(core.move("commandsv2/src/test/python", "tests"))
core.workflow(
name = "allwpilib_to_commandsv2",
origin = git.origin(
url = "https://github.com/wpilibsuite/allwpilib.git",
ref = "2027",
),
destination = git.github_destination(
url = "https://github.com/OVERRIDE_ME/OVERRIDE_ME",
fetch = "2027",
push = "copybara_allwpilib_to_commandsv2",
),
destination_files = destination_files,
origin_files = origin_files,
authoring = authoring.pass_thru("Default email <default@default.com>"),
transformations = transformations,
)
define_mostrobotpy_to_allwpilib()
define_allwpilib_to_mostrobotpy()
define_robotpy_commandsv2_to_allwpilib()
define_allwpilib_to_robotpy_commandsv2()