Skip to content

Commit

Permalink
auto-generate MAVLink messages files
Browse files Browse the repository at this point in the history
  • Loading branch information
ES-Alexander authored and patrickelectric committed Jan 9, 2025
1 parent 6cceeb9 commit c909eec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8' # Set the Python version you need
python-version: '3.11' # Set the Python version you need

- name: Install dependencies
run: |
python -m pip install --upgrade pip GitPython packaging lxml emit xmltodict
python -m pip install --upgrade pip GitPython packaging lxml emit xmltodict pymavlink
# Add any other dependencies here
- name: Run Python script
run: |
python scripts/run_param_parse.py
python scripts/run_parsers.py
python scripts/json_from_xml.py
- name: Commit and push if changed
Expand Down
22 changes: 20 additions & 2 deletions scripts/run_param_parse.py → scripts/run_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def run(self):
tag_names = [tag.path[len('refs/tags/'):] for tag in self.repository.tags]
last_ground_change = Groundskeeper.get_last_ground_change(git.Repo(Path(__file__).parent.parent))

# Prepare for MAVLink parsing - always use the latest script (since it might cover new messages)
shutil.copy(f'{self.repository_path}/Tools/scripts/mavlink_parse.py', self.temp_folder)

# Get only valid tag names
tags = [
{
Expand Down Expand Up @@ -123,11 +126,14 @@ def run(self):
print("Ignoring old version")
continue

self.repository.git.checkout(tag_reference)
# Ignore local changes (they're automated anyway)
self.repository.git.checkout(tag_reference, force=True)
tag_date = Groundskeeper.get_last_ground_change(self.repository)
if last_ground_change > tag_date:
print(f"Version already generated for {tag_date}")
continue

# Run parameters parser
try:
subprocess.run([f'{self.repository_path}/Tools/autotest/param_metadata/param_parse.py', '--vehicle', vehicle_type], cwd=self.repository_path)
except Exception as exception:
Expand All @@ -146,7 +152,19 @@ def run(self):
shutil.copy2(data, dest)
os.remove(data)

# Run MAVLink messages parser
vehicle = f'{"Ardu" if vehicle_type != "Rover" else ""}{vehicle_type}'
try:
# The parser expects to be run from its normal place in the repository
script_folder = f'{self.repository_path}/Tools/scripts/'
script_file = script_folder + 'mavlink_parse.py'
shutil.copy(f'{self.temp_folder}/mavlink_parse.py', script_file)
subprocess.run([script_file, '-cguq', '--header', 'ardupilot_wiki', '--format', 'rst',
'--filename', f'{dest}/MAVLinkMessages.rst', '--branch', folder_name, '--vehicle', vehicle],
cwd=script_folder)
except Exception as exception:
print(exception)


G = Groundskeeper()
G.run()
G.run()

0 comments on commit c909eec

Please sign in to comment.