From 38d8929f488e48f743df75fdfa5bec3fb0eda5af Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:59:47 -0500 Subject: [PATCH] [ci] Move pregen steps into a composite action (#7474) This ensures that complete uniformity in how the generation scripts are run. All dependencies and scripts are set up in the exact same way, each time. The old pregen_all script has been removed and moved into the composite action to ensure failed scripts will always fail the job. --- .github/actions/pregen/action.yml | 61 +++++++++++++++++++++ .github/workflows/comment-command.yml | 12 +---- .github/workflows/pregen_all.py | 78 --------------------------- .github/workflows/pregenerate.yml | 12 +---- 4 files changed, 65 insertions(+), 98 deletions(-) create mode 100644 .github/actions/pregen/action.yml delete mode 100755 .github/workflows/pregen_all.py diff --git a/.github/actions/pregen/action.yml b/.github/actions/pregen/action.yml new file mode 100644 index 00000000000..2c61be413ac --- /dev/null +++ b/.github/actions/pregen/action.yml @@ -0,0 +1,61 @@ +name: 'Setup and run pregeneration' +description: 'Sets up the dependencies needed to generate generated files and runs all generation scripts' + +runs: + using: "composite" + steps: + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install jinja and protobuf + run: python -m pip install jinja2 protobuf grpcio-tools + shell: bash + - 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 + shell: bash + - name: Regenerate hal + run: ./hal/generate_usage_reporting.py + shell: bash + + - name: Regenerate ntcore + run: ./ntcore/generate_topics.py + shell: bash + + - name: Regenerate imgui + run: | + ./thirdparty/imgui_suite/generate_fonts.sh + ./thirdparty/imgui_suite/generate_gl3w.py + shell: bash + + - name: Regenerate HIDs + run: | + ./wpilibc/generate_hids.py + ./wpilibj/generate_hids.py + ./wpilibNewCommands/generate_hids.py + shell: bash + + - name: Regenerate PWM motor controllers + run: | + ./wpilibc/generate_pwm_motor_controllers.py + ./wpilibj/generate_pwm_motor_controllers.py + shell: bash + + - name: Regenerate wpimath + run: | + ./wpimath/generate_nanopb.py + ./wpimath/generate_numbers.py + ./wpimath/generate_quickbuf.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe + shell: bash + + - name: Regenerate wpiunits + run: ./wpiunits/generate_units.py + shell: bash + + - name: Regenerate wpiutil nanopb + run: ./wpiutil/generate_nanopb.py + shell: bash diff --git a/.github/workflows/comment-command.yml b/.github/workflows/comment-command.yml index 8b98519be91..3e550f466e9 100644 --- a/.github/workflows/comment-command.yml +++ b/.github/workflows/comment-command.yml @@ -93,16 +93,8 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}" NUMBER: ${{ github.event.issue.number }} - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install jinja - 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: Regenerate all - run: ./.github/workflows/pregen_all.py --quickbuf_plugin=protoc-gen-quickbuf-1.3.3-linux-x86_64.exe + - name: Run pregen + uses: ./.github/actions/pregen - name: Commit run: | # Set credentials diff --git a/.github/workflows/pregen_all.py b/.github/workflows/pregen_all.py deleted file mode 100755 index 278e5c84cd8..00000000000 --- a/.github/workflows/pregen_all.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import subprocess -import sys -from pathlib import Path - - -def main(): - 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() - subprocess.run( - [sys.executable, f"{REPO_ROOT}/hal/generate_usage_reporting.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/ntcore/generate_topics.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpimath/generate_numbers.py"], check=True - ) - subprocess.run( - [ - sys.executable, - f"{REPO_ROOT}/wpimath/generate_quickbuf.py", - f"--quickbuf_plugin={args.quickbuf_plugin}", - ], - check=True, - ) - subprocess.run( - [ - sys.executable, - f"{REPO_ROOT}/wpimath/generate_nanopb.py", - ], - check=True, - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpiunits/generate_units.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpilibc/generate_hids.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpilibj/generate_hids.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpilibNewCommands/generate_hids.py"], check=True - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpilibc/generate_pwm_motor_controllers.py"], - check=True, - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/wpilibj/generate_pwm_motor_controllers.py"], - check=True, - ) - subprocess.run( - [ - sys.executable, - f"{REPO_ROOT}/wpiutil/generate_nanopb.py", - ], - check=True, - ) - subprocess.run( - [sys.executable, f"{REPO_ROOT}/thirdparty/imgui_suite/generate_gl3w.py"], - check=True, - ) - subprocess.run(f"{REPO_ROOT}/thirdparty/imgui_suite/generate_fonts.sh", check=True) - - -if __name__ == "__main__": - main() diff --git a/.github/workflows/pregenerate.yml b/.github/workflows/pregenerate.yml index 12e09da6a58..8bc6c9a28df 100644 --- a/.github/workflows/pregenerate.yml +++ b/.github/workflows/pregenerate.yml @@ -18,16 +18,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install jinja and protobuf - run: python -m pip install jinja2 protobuf grpcio-tools - - 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: Regenerate all - run: python ./.github/workflows/pregen_all.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe + - name: Run pregen + uses: ./.github/actions/pregen - name: Add untracked files to index so they count as changes run: git add -A - name: Check output