Skip to content

Commit

Permalink
ci fingerprint tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewb1 committed Oct 1, 2023
1 parent 917c7f3 commit 593e177
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/fingerprint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: fingerprint bot

on:
issue_comment:
types: [created, edited, deleted]

jobs:
fingerprint:
if: contains(github.event.comment.body, '/fingerprint')
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/workflows/setup-with-retry
- name: fingerprint
- name: create pull request
run: gh pr create -B base_branch -H branch_to_merge --title 'Merge branch_to_merge into base_branch' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 13 additions & 11 deletions selfdrive/debug/auto_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ def add_fw_versions(brand, platform, new_fw_versions):
f.write(values_py)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto fingerprint from a route")
parser.add_argument("route", help="The route name to use")
parser.add_argument("platform", help="The platform, or leave empty to auto-determine using fuzzy", default=None, nargs='?')
args = parser.parse_args()

route = Route(args.route)
def auto_fingerprint(route, platform):
route = Route(route)
lr = MultiLogIterator(route.qlog_paths())

carFw = None
Expand All @@ -65,7 +61,7 @@ def add_fw_versions(brand, platform, new_fw_versions):
if carFw is None:
raise Exception("No fw versions in the provided route...")

if args.platform is None: # attempt to auto-determine platform with other fuzzy fingerprints
if platform is None: # attempt to auto-determine platform with other fuzzy fingerprints
_, possible_platforms = match_fw_to_car(carFw, log=False)

if len(possible_platforms) != 1:
Expand All @@ -79,9 +75,6 @@ def add_fw_versions(brand, platform, new_fw_versions):
else:
platform = list(possible_platforms)[0]

else:
platform = args.platform

print("Attempting to add fw version for: ", platform)

brand = PLATFORM_TO_BRAND[platform]
Expand All @@ -102,4 +95,13 @@ def add_fw_versions(brand, platform, new_fw_versions):
if not new_fw_versions:
print("No new fw versions found...")

add_fw_versions(brand, platform, new_fw_versions)
add_fw_versions(brand, platform, new_fw_versions)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto fingerprint from a route")
parser.add_argument("route", help="The route name to use")
parser.add_argument("platform", help="The platform, or leave empty to auto-determine using fuzzy", default=None, nargs='?')
args = parser.parse_args()

auto_fingerprint(args.route, args.platform)
36 changes: 36 additions & 0 deletions selfdrive/debug/ci_fingerprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import argparse
import shlex

from openpilot.selfdrive.debug.auto_fingerprint import auto_fingerprint


FINGERPRINT_COMMAND = "/fingerprint"


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
parser.add_argument("comment", help="Github comment", type=str)
args = parser.parse_args()
comment = args.comment

for line in comment.split("\n"):
if FINGERPRINT_COMMAND in line:
start = line.index(FINGERPRINT_COMMAND)

split = shlex.split(line[start:])

if len(split) not in [2,3]:
raise Exception(f"Invalid number of arguments: {split}")

if len(split) == 2:
_, route = split
platform = None
if len(split) == 3:
_, route, platform = split

auto_fingerprint(route, platform)

exit(0)

raise Exception(f"{FINGERPRINT_COMMAND} is required to call this job")

0 comments on commit 593e177

Please sign in to comment.