From ebf5efc62eb0be24cfbe3e7f58ac6a2f0bf48bb8 Mon Sep 17 00:00:00 2001 From: Matt M Date: Thu, 7 Nov 2024 13:58:07 -0800 Subject: [PATCH] Create bump-only workflow --- .github/workflows/bazel.yml | 35 ------- .github/workflows/bump.yml | 48 +++++++++ .github/workflows/main.yml | 66 ------------- 2025.json | 192 ++++++++++++++++++------------------ fixup_year.py | 24 +++++ 5 files changed, 168 insertions(+), 197 deletions(-) delete mode 100644 .github/workflows/bazel.yml create mode 100644 .github/workflows/bump.yml delete mode 100644 .github/workflows/main.yml create mode 100644 fixup_year.py diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml deleted file mode 100644 index 6966929..0000000 --- a/.github/workflows/bazel.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow runs the JSON checker on each vendordep JSON file. - -name: Bazel CI - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the main branch -on: - push: - pull_request: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "run-json-checker" - run-json-checker: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history so we can use git diff - - - name: Maybe setup BuildBuddy key - env: - API_KEY: ${{ secrets.API_KEY }} - if: ${{ env.API_KEY != '' }} - shell: bash - run: | - echo "API Key detected!" - echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > .buildbuddy-auth.rc - - - name: Run check - run: | - bazel test //... -k --config=ci diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..ec81334 --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,48 @@ +name: bump + +on: + repository_dispatch: + +jobs: + bump: + if: github.event_name == 'repository_dispatch' && github.event.action == 'tag' + runs-on: ubuntu-latest + steps: + - name: Information + run: | + echo "Version update for ${{ github.event.client_payload.package_version }}, job id ${{ github.event.client_payload.run_id }} requested" + + - uses: actions/checkout@v4 + + - run: git switch -C photonlib-${{ github.event.client_payload.package_version }} + + - uses: actions/download-artifact@v4 + with: + name: photonlib-vendor-json + github-token: ${{ secrets.GITHUB_TOKEN }} # token with actions:read permissions on target repo + repository: mcm001/photonvision + run-id: ${{ github.event.client_payload.run_id }} + merge-multiple: true + path: "2025" + + - run: find . + - run: git status + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - run: python3 fixup_year.py 2025 ${{ github.event.client_payload.package_version }} + + # Cut a new PR + # apparently we have to push or gh pr create gets upset + - name: Commit and push + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + git add . + git commit -m "Update vendor JSON to ${{ github.event.client_payload.package_version }}" + git push --set-upstream origin photonlib-${{ github.event.client_payload.package_version }} -f + - run: gh pr create --repo wpilibsuite/vendor-json-repo --title "Update PhotonLib to ${{ github.event.client_payload.package_version }}" --body "Automatic vendor JSON update from GitHub Actions" --base main --head photonvision:$(git branch --show-current) + env: + GH_TOKEN: ${{ secrets.VENDOR_JSON_REPO_PUSH_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 838863d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,66 +0,0 @@ -# This workflow runs the JSON checker on each vendordep JSON file. - -name: CI - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the main branch -on: - push: - branches: [ main ] - pull_request: - -env: - YEAR: 2025 - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "run-json-checker" - run-json-checker: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history so we can use git diff - - - name: Install dependencies - run: sudo pip3 install pyelftools pefile - - - name: Run check - run: | - # Determine the base commit - if [ "${{ github.event_name }}" = "pull_request" ]; then - git fetch --no-tags --prune --progress --no-recurse-submodules origin ${{ github.base_ref }} - BASE_COMMIT=$(git merge-base HEAD origin/${{ github.base_ref }}) - else - BASE_COMMIT=${{ github.event.before }} - fi - echo "Base commit: $BASE_COMMIT" - - # Get list of added or modified JSON files in subdirectories - git diff --diff-filter=AM --name-only $BASE_COMMIT HEAD | grep '.*/.*\.json$' > changed_json_files.txt || true - - # Run check.py on each existing JSON file - if [ -s changed_json_files.txt ]; then - # Output the list of files - echo "Changed JSON files in subdirectories:" - cat changed_json_files.txt - - while read -r file; do - if [ -f "$file" ]; then - if [ -s "$file" ]; then - echo "Processing $file" - ./check.py "$file" - else - echo "Warning: $file is empty." - fi - else - echo "Warning: $file does not exist." - fi - done < changed_json_files.txt - else - echo "No JSON files changed in subdirectories, checking year: $YEAR" - ./check.py $YEAR/*.json - fi diff --git a/2025.json b/2025.json index 92aa67e..6f2691c 100644 --- a/2025.json +++ b/2025.json @@ -1,98 +1,98 @@ [ - { - "path": "2025/NavX-2025.1.1-beta-1.json", - "name": "Studica", - "version": "2025.1.1-beta-1", - "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", - "description": "Libraries for NavX-MXP and NavX-Micro", - "website": "https://pdocs.kauailabs.com/navx-mxp/software/roborio-libraries/" - }, - { - "path": "2025/Studica-2025.1.1-beta-2.json", - "name": "Studica", - "version": "2025.1.1-beta-2", - "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", - "description": "Libraries for NavX and other Studica Products", - "website": "https://github.com/Studica-Robotics/NavX" - }, - { - "path": "2025/Phoenix6-25.0.0-beta-1.json", - "name": "CTRE-Phoenix (v6)", - "version": "25.0.0-beta-1", - "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", - "description": "Libraries for Phoenix 6 devices", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/Phoenix6-25.0.0-beta-2.json", - "name": "CTRE-Phoenix (v6)", - "version": "25.0.0-beta-2", - "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", - "description": "Libraries for Phoenix 6 devices", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/Phoenix6-replay-25.0.0-beta-1.json", - "name": "CTRE-Phoenix Replay (v6)", - "version": "25.0.0-beta-1", - "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", - "description": "Libraries for Phoenix 6 devices with Hoot Replay", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/Phoenix6-replay-25.0.0-beta-2.json", - "name": "CTRE-Phoenix Replay (v6)", - "version": "25.0.0-beta-2", - "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", - "description": "Libraries for Phoenix 6 devices with Hoot Replay", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/Phoenix5-5.34.0-beta-1.json", - "name": "CTRE-Phoenix (v5)", - "version": "5.34.0-beta-1", - "uuid": "ab676553-b602-441f-a38d-f1296eff6537", - "description": "Libraries for Phoenix 5 devices", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/Phoenix5-5.34.0-beta-2.json", - "name": "CTRE-Phoenix (v5)", - "version": "5.34.0-beta-2", - "uuid": "ab676553-b602-441f-a38d-f1296eff6537", - "description": "Libraries for Phoenix 5 devices", - "website": "https://docs.ctr-electronics.com/" - }, - { - "path": "2025/PathplannerLib-2025.0.0-beta-3.json", - "name": "PathplannerLib", - "version": "2025.0.0-beta-3", - "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", - "description": "PathPlanner's powerful robot-side vendor library", - "website": "https://pathplanner.dev/pathplannerlib.html" - }, - { - "path": "2025/PathplannerLib-2025.0.0-beta-3.1.json", - "name": "PathplannerLib", - "version": "2025.0.0-beta-3.1", - "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", - "description": "PathPlanner's powerful robot-side vendor library", - "website": "https://pathplanner.dev/pathplannerlib.html" - }, - { - "path": "2025/DogLog-2025.0.0.json", - "name": "DogLog", - "version": "2025.0.0", - "uuid": "65592ce1-2251-4a31-8e4b-2df20dacebe4", - "description": "Simpler logging for FRC", - "website": "https://doglog.dev/" - }, - { - "path": "2025/REVLib-2025.0.0-beta-1.json", - "name": "REVLib", - "version": "2025.0.0-beta-1", - "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", - "description": "Library for all REV devices including SPARK Flex, SPARK MAX, and Color Sensor V3", - "website": "https://docs.revrobotics.com/brushless/revlib/revlib-overview" - } + { + "path": "2025/NavX-2025.1.1-beta-1.json", + "name": "Studica", + "version": "2025.1.1-beta-1", + "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", + "description": "Libraries for NavX-MXP and NavX-Micro", + "website": "https://pdocs.kauailabs.com/navx-mxp/software/roborio-libraries/" + }, + { + "path": "2025/Studica-2025.1.1-beta-2.json", + "name": "Studica", + "version": "2025.1.1-beta-2", + "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", + "description": "Libraries for NavX and other Studica Products", + "website": "https://github.com/Studica-Robotics/NavX" + }, + { + "path": "2025/Phoenix6-25.0.0-beta-1.json", + "name": "CTRE-Phoenix (v6)", + "version": "25.0.0-beta-1", + "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", + "description": "Libraries for Phoenix 6 devices", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/Phoenix6-25.0.0-beta-2.json", + "name": "CTRE-Phoenix (v6)", + "version": "25.0.0-beta-2", + "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", + "description": "Libraries for Phoenix 6 devices", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/Phoenix6-replay-25.0.0-beta-1.json", + "name": "CTRE-Phoenix Replay (v6)", + "version": "25.0.0-beta-1", + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "description": "Libraries for Phoenix 6 devices with Hoot Replay", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/Phoenix6-replay-25.0.0-beta-2.json", + "name": "CTRE-Phoenix Replay (v6)", + "version": "25.0.0-beta-2", + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "description": "Libraries for Phoenix 6 devices with Hoot Replay", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/Phoenix5-5.34.0-beta-1.json", + "name": "CTRE-Phoenix (v5)", + "version": "5.34.0-beta-1", + "uuid": "ab676553-b602-441f-a38d-f1296eff6537", + "description": "Libraries for Phoenix 5 devices", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/Phoenix5-5.34.0-beta-2.json", + "name": "CTRE-Phoenix (v5)", + "version": "5.34.0-beta-2", + "uuid": "ab676553-b602-441f-a38d-f1296eff6537", + "description": "Libraries for Phoenix 5 devices", + "website": "https://docs.ctr-electronics.com/" + }, + { + "path": "2025/PathplannerLib-2025.0.0-beta-3.json", + "name": "PathplannerLib", + "version": "2025.0.0-beta-3", + "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", + "description": "PathPlanner's powerful robot-side vendor library", + "website": "https://pathplanner.dev/pathplannerlib.html" + }, + { + "path": "2025/PathplannerLib-2025.0.0-beta-3.1.json", + "name": "PathplannerLib", + "version": "2025.0.0-beta-3.1", + "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", + "description": "PathPlanner's powerful robot-side vendor library", + "website": "https://pathplanner.dev/pathplannerlib.html" + }, + { + "path": "2025/DogLog-2025.0.0.json", + "name": "DogLog", + "version": "2025.0.0", + "uuid": "65592ce1-2251-4a31-8e4b-2df20dacebe4", + "description": "Simpler logging for FRC", + "website": "https://doglog.dev/" + }, + { + "path": "2025/REVLib-2025.0.0-beta-1.json", + "name": "REVLib", + "version": "2025.0.0-beta-1", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "description": "Library for all REV devices including SPARK Flex, SPARK MAX, and Color Sensor V3", + "website": "https://docs.revrobotics.com/brushless/revlib/revlib-overview" + } ] \ No newline at end of file diff --git a/fixup_year.py b/fixup_year.py new file mode 100644 index 0000000..774216b --- /dev/null +++ b/fixup_year.py @@ -0,0 +1,24 @@ +import sys +import json + +if __name__ == "__main__": + (_, year, version) = sys.argv + print(f"Fixing up year {year} version {version}") + + with open(f"{year}.json", 'r') as f: + current_year: list = json.load(f) + current_year = [dep for dep in current_year if dep['version'] != version] + print(current_year) + current_year.append( + { + "path": f"{year}/photonlib-{version}.json", + "name": "PhotonLib", + "version": version, + "uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004", + "description": "PhotonVision is the free, fast, and easy-to-use vision processing solution for the FIRST Robotics Competition.", + "website": "https://docs.photonvision.org/en/latest/docs/programming/photonlib/adding-vendordep.html" + } + ) + print(current_year) + with open(f"{year}.json", 'w') as f: + json.dump(current_year, f, indent=4) \ No newline at end of file