From 2fe3eed458b88d2da729b4970b58e2370a3dbc01 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:29:23 +0100 Subject: [PATCH] Compare SDK methods to staged PR (#2146) --- .github/workflows/check-methods.yml | 15 +++++++++++---- .github/workflows/check_python_methods.py | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check-methods.yml b/.github/workflows/check-methods.yml index 54d912ea6e..03df2242a7 100644 --- a/.github/workflows/check-methods.yml +++ b/.github/workflows/check-methods.yml @@ -1,6 +1,12 @@ name: Check Python SDK method coverage # This action works with pull requests and pushes +on: + workflow_run: + workflows: ["pr-deploy-and-comment"] + branches: [main] + types: + - completed on: pull_request: push: @@ -9,6 +15,7 @@ on: jobs: python-methods: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest continue-on-error: true @@ -17,8 +24,8 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.9' - cache: 'pip' # caching pip dependencies - - run: pip install beautifulsoup4 markdownify + python-version: "3.9" + cache: "pip" # caching pip dependencies + - run: pip install beautifulsoup4 markdownify argparse - name: "Check Python SDK method coverage" - run: python3 .github/workflows/check_python_methods.py \ No newline at end of file + run: python3 .github/workflows/check_python_methods.py --pr ${{ github.event.number }} diff --git a/.github/workflows/check_python_methods.py b/.github/workflows/check_python_methods.py index fd8461a4a0..dcbd30dc96 100644 --- a/.github/workflows/check_python_methods.py +++ b/.github/workflows/check_python_methods.py @@ -3,8 +3,14 @@ import sys import markdownify import urllib.parse +import argparse +parser = argparse.ArgumentParser() +parser.add_argument('--pr', type=str, required=False) + +args = parser.parse_args() + services = ["motion", "navigation", "sensors", "slam", "vision", "mlmodel"] components = ["arm", "base", "board", "camera", "encoder", "gantry", "generic", "gripper", "input", "movement_sensor", "power_sensor", "sensor"] @@ -185,10 +191,16 @@ def parse(type, names): # Parse the Docs site's service page - if type == "app" or type == "robot": - soup2 = make_soup(f"https://docs.viam.com/program/apis/{service}/") + if args.pr: + if type == "app" or type == "robot": + soup2 = make_soup(f"https://docs-test.viam.dev/{pr_num}/public/program/apis/{service}/") + else: + soup2 = make_soup(f"https://docs-test.viam.dev/{pr_num}/public/{type}/{service}/") else: - soup2 = make_soup(f"https://docs.viam.com/{type}/{service}/") + if type == "app" or type == "robot": + soup2 = make_soup(f"https://docs.viam.com/program/apis/{service}/") + else: + soup2 = make_soup(f"https://docs.viam.com/{type}/{service}/") # Find all links on Docs site soup all_links = soup2.find_all('a')