From 64e5e6db5919b233b55fa7fcf1a37279eccef963 Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:54:59 -0400 Subject: [PATCH] [ci] Use one script to pregenerate everything (#7121) A pregen_all Python script was added that calls all the other pregen scripts. This prevents the generated file checks and pregen command from falling out of sync. This is meant to only run in CI, since the script is not portable across platforms. --- .github/workflows/comment-command.yml | 16 ++--------- .github/workflows/pregen_all.py | 40 +++++++++++++++++++++++++++ .github/workflows/pregenerate.yml | 18 ++---------- 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100755 .github/workflows/pregen_all.py diff --git a/.github/workflows/comment-command.yml b/.github/workflows/comment-command.yml index 15f99264a4e..97bdaf67113 100644 --- a/.github/workflows/comment-command.yml +++ b/.github/workflows/comment-command.yml @@ -89,20 +89,8 @@ jobs: run: python -m pip install jinja2 - name: Install protobuf dependencies run: sudo apt-get update && sudo apt-get install -y protobuf-compiler && wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe && chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - - name: Run hal - run: ./hal/generate_usage_reporting.py - - name: Run ntcore - run: ./ntcore/generate_topics.py - - name: Run wpimath - run: ./wpimath/generate_numbers.py && ./wpimath/generate_quickbuf.py --quickbuf_plugin=protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - - name: Run HIDs - run: ./wpilibj/generate_hids.py && ./wpilibc/generate_hids.py && ./wpilibNewCommands/generate_hids.py - - name: Run PWM Controllers - run: ./wpilibj/generate_pwm_motor_controllers.py && ./wpilibc/generate_pwm_motor_controllers.py - - name: Run imgui gl3w - run: ./thirdparty/imgui_suite/generate_gl3w.py - - name: Run imgui fonts - run: ./thirdparty/imgui_suite/generate_fonts.sh + - name: Regenerate all + run: ./.github/workflows/pregen_all.py --quickbuf_plugin=protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - name: Commit run: | # Set credentials diff --git a/.github/workflows/pregen_all.py b/.github/workflows/pregen_all.py new file mode 100755 index 00000000000..d7ec35af74a --- /dev/null +++ b/.github/workflows/pregen_all.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import argparse +import subprocess +import sys +from pathlib import Path + + +def main(argv): + script_path = Path(__file__).resolve() + REPO_ROOT = script_path.parent.parent.parent + parser = argparse.ArgumentParser() + parser.add_argument( + "--quickbuf_plugin", + help="Path to the quickbuf protoc plugin", + required=True, + ) + args = parser.parse_args(argv) + subprocess.run(["python", f"{REPO_ROOT}/hal/generate_usage_reporting.py"]) + subprocess.run(["python", f"{REPO_ROOT}/ntcore/generate_topics.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpimath/generate_numbers.py"]) + subprocess.run( + [ + "python", + f"{REPO_ROOT}/wpimath/generate_quickbuf.py", + f"--quickbuf_plugin={args.quickbuf_plugin}", + ] + ) + subprocess.run(["python", f"{REPO_ROOT}/wpiunits/generate_units.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpilibc/generate_hids.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpilibj/generate_hids.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpilibNewCommands/generate_hids.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpilibc/generate_pwm_motor_controllers.py"]) + subprocess.run(["python", f"{REPO_ROOT}/wpilibj/generate_pwm_motor_controllers.py"]) + subprocess.run(["python", f"{REPO_ROOT}/thirdparty/imgui_suite/generate_gl3w.py"]) + subprocess.run(f"{REPO_ROOT}/thirdparty/imgui_suite/generate_fonts.sh") + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/.github/workflows/pregenerate.yml b/.github/workflows/pregenerate.yml index decca974b6c..692bef1609d 100644 --- a/.github/workflows/pregenerate.yml +++ b/.github/workflows/pregenerate.yml @@ -26,22 +26,8 @@ jobs: run: python -m pip install jinja2 - name: Install protobuf dependencies run: sudo apt-get update && sudo apt-get install -y protobuf-compiler && wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe && chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - - name: Run hal - run: ./hal/generate_usage_reporting.py - - name: Run ntcore - run: ./ntcore/generate_topics.py - - name: Run wpimath - run: ./wpimath/generate_numbers.py && ./wpimath/generate_quickbuf.py --quickbuf_plugin=protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - - name: Run wpiunits - run: ./wpiunits/generate_units.py - - name: Run HIDs - run: ./wpilibj/generate_hids.py && ./wpilibc/generate_hids.py && ./wpilibNewCommands/generate_hids.py - - name: Run PWM Controllers - run: ./wpilibj/generate_pwm_motor_controllers.py && ./wpilibc/generate_pwm_motor_controllers.py - - name: Run imgui gl3w - run: ./thirdparty/imgui_suite/generate_gl3w.py - - name: Run imgui fonts - run: ./thirdparty/imgui_suite/generate_fonts.sh + - name: Regenerate all + run: python ./.github/workflows/pregen_all.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - name: Add untracked files to index so they count as changes run: git add -A - name: Check output